diff --git a/garden_of_glass/src/main/java/vazkii/botania/common/GardenOfGlass.java b/garden_of_glass/src/main/java/vazkii/botania/common/GardenOfGlass.java index d78b7de33..bd7ccbb2c 100644 --- a/garden_of_glass/src/main/java/vazkii/botania/common/GardenOfGlass.java +++ b/garden_of_glass/src/main/java/vazkii/botania/common/GardenOfGlass.java @@ -1,8 +1,15 @@ +/* + * This class is 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 + */ package vazkii.botania.common; import net.minecraftforge.fml.common.Mod; @Mod("gardenofglass") -public class GardenOfGlass -{ +public class GardenOfGlass { } diff --git a/src/main/java/vazkii/botania/api/BotaniaAPI.java b/src/main/java/vazkii/botania/api/BotaniaAPI.java index 8910ab249..d85d3a68e 100644 --- a/src/main/java/vazkii/botania/api/BotaniaAPI.java +++ b/src/main/java/vazkii/botania/api/BotaniaAPI.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 14, 2014, 6:15:28 PM (GMT)] */ package vazkii.botania.api; @@ -27,6 +25,7 @@ import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityInject; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.IRegistryDelegate; + import vazkii.botania.api.brew.Brew; import vazkii.botania.api.internal.DummyMethodHandler; import vazkii.botania.api.internal.IInternalMethodHandler; @@ -41,6 +40,7 @@ import vazkii.botania.api.recipe.RecipeRuneAltar; import vazkii.botania.common.core.handler.PixieHandler; import javax.annotation.Nonnull; + import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; @@ -51,17 +51,15 @@ public final class BotaniaAPI { return 94; } - @CapabilityInject(IFloatingFlower.class) - public static Capability FLOATING_FLOWER_CAP; + @CapabilityInject(IFloatingFlower.class) public static Capability FLOATING_FLOWER_CAP; - @CapabilityInject(IExoflameHeatable.class) - public static Capability EXOFLAME_HEATABLE_CAP; + @CapabilityInject(IExoflameHeatable.class) public static Capability EXOFLAME_HEATABLE_CAP; public static final Map brewMap = new LinkedHashMap<>(); /* - * These maps are not meant to be mutated! - */ + * These maps are not meant to be mutated! + */ public static Map petalRecipes = Collections.emptyMap(); public static Map pureDaisyRecipes = Collections.emptyMap(); public static Map manaInfusionRecipes = Collections.emptyMap(); @@ -74,9 +72,10 @@ public final class BotaniaAPI { public static Map, Function> paintableBlocks = Collections.emptyMap(); - private static final int[] MAX_DAMAGE_ARRAY = new int[]{13, 15, 16, 11}; + private static final int[] MAX_DAMAGE_ARRAY = new int[] { 13, 15, 16, 11 }; public static final IArmorMaterial MANASTEEL_ARMOR_MAT = new IArmorMaterial() { private final int[] damageReduction = { 2, 5, 6, 2 }; + @Override public int getDurability(EquipmentSlotType slotIn) { return 16 * MAX_DAMAGE_ARRAY[slotIn.getIndex()]; @@ -149,6 +148,7 @@ public final class BotaniaAPI { public static final IArmorMaterial ELEMENTIUM_ARMOR_MAT = new IArmorMaterial() { private final int[] damageReduction = { 2, 5, 6, 2 }; + @Override public int getDurability(EquipmentSlotType slotIn) { return 18 * MAX_DAMAGE_ARRAY[slotIn.getIndex()]; @@ -221,6 +221,7 @@ public final class BotaniaAPI { public static final IArmorMaterial TERRASTEEL_ARMOR_MAT = new IArmorMaterial() { private final int[] damageReduction = { 3, 6, 8, 3 }; + @Override public int getDurability(EquipmentSlotType slotIn) { return 34 * MAX_DAMAGE_ARRAY[slotIn.getIndex()]; @@ -292,6 +293,7 @@ public final class BotaniaAPI { }; public static final IArmorMaterial MANAWEAVE_ARMOR_MAT = new IArmorMaterial() { private final int[] damageReduction = { 1, 2, 2, 1 }; + @Override public int getDurability(EquipmentSlotType slotIn) { return 5 * MAX_DAMAGE_ARRAY[slotIn.getIndex()]; @@ -337,6 +339,7 @@ public final class BotaniaAPI { * The internal method handler in use. * DO NOT OVERWRITE THIS OR YOU'RE GOING TO FEEL MY WRATH WHEN I UPDATE THE API. * The fact I have to write that means some moron already tried, don't be that moron. + * * @see IInternalMethodHandler */ public static volatile IInternalMethodHandler internalHandler = new DummyMethodHandler(); @@ -354,8 +357,9 @@ public final class BotaniaAPI { * it's not in the map. */ public static Brew getBrewFromKey(String key) { - if(brewMap.containsKey(key)) + if (brewMap.containsKey(key)) { return brewMap.get(key); + } return fallbackBrew; } diff --git a/src/main/java/vazkii/botania/api/BotaniaAPIClient.java b/src/main/java/vazkii/botania/api/BotaniaAPIClient.java index 12219dba8..7b4ea01a6 100644 --- a/src/main/java/vazkii/botania/api/BotaniaAPIClient.java +++ b/src/main/java/vazkii/botania/api/BotaniaAPIClient.java @@ -1,18 +1,20 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 */ package vazkii.botania.api; import com.google.common.collect.Maps; + import net.minecraft.client.renderer.model.ModelResourceLocation; import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.item.IFloatingFlower; import java.util.Collections; @@ -26,8 +28,7 @@ public final class BotaniaAPIClient { private static final Map islandTypeModels = Maps.newHashMap(); - private BotaniaAPIClient() { - } + private BotaniaAPIClient() {} /** * Registers your model for island type islandType here. diff --git a/src/main/java/vazkii/botania/api/ColorHelper.java b/src/main/java/vazkii/botania/api/ColorHelper.java index 7f2594e3f..e07baa591 100644 --- a/src/main/java/vazkii/botania/api/ColorHelper.java +++ b/src/main/java/vazkii/botania/api/ColorHelper.java @@ -1,159 +1,168 @@ +/* + * This class is 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 + */ package vazkii.botania.api; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; + import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.item.DyeColor; import net.minecraftforge.registries.IRegistryDelegate; public final class ColorHelper { - public static final BiMap> STAINED_GLASS_MAP = HashBiMap.create(); - public static final BiMap> STAINED_GLASS_PANE_MAP = HashBiMap.create(); - public static final BiMap> TERRACOTTA_MAP = HashBiMap.create(); - public static final BiMap> GLAZED_TERRACOTTA_MAP = HashBiMap.create(); - public static final BiMap> WOOL_MAP = HashBiMap.create(); - public static final BiMap> CARPET_MAP = HashBiMap.create(); - public static final BiMap> CONCRETE_MAP = HashBiMap.create(); - public static final BiMap> CONCRETE_POWDER_MAP = HashBiMap.create(); - - public static void init() { - STAINED_GLASS_MAP.put(DyeColor.WHITE, Blocks.WHITE_STAINED_GLASS.delegate); - STAINED_GLASS_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_STAINED_GLASS.delegate); - STAINED_GLASS_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_STAINED_GLASS.delegate); - STAINED_GLASS_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_STAINED_GLASS.delegate); - STAINED_GLASS_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_STAINED_GLASS.delegate); - STAINED_GLASS_MAP.put(DyeColor.LIME, Blocks.LIME_STAINED_GLASS.delegate); - STAINED_GLASS_MAP.put(DyeColor.PINK, Blocks.PINK_STAINED_GLASS.delegate); - STAINED_GLASS_MAP.put(DyeColor.GRAY, Blocks.GRAY_STAINED_GLASS.delegate); - STAINED_GLASS_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_STAINED_GLASS.delegate); - STAINED_GLASS_MAP.put(DyeColor.CYAN, Blocks.CYAN_STAINED_GLASS.delegate); - STAINED_GLASS_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_STAINED_GLASS.delegate); - STAINED_GLASS_MAP.put(DyeColor.BLUE, Blocks.BLUE_STAINED_GLASS.delegate); - STAINED_GLASS_MAP.put(DyeColor.BROWN, Blocks.BROWN_STAINED_GLASS.delegate); - STAINED_GLASS_MAP.put(DyeColor.GREEN, Blocks.GREEN_STAINED_GLASS.delegate); - STAINED_GLASS_MAP.put(DyeColor.RED, Blocks.RED_STAINED_GLASS.delegate); - STAINED_GLASS_MAP.put(DyeColor.BLACK, Blocks.BLACK_STAINED_GLASS.delegate); - - STAINED_GLASS_PANE_MAP.put(DyeColor.WHITE, Blocks.WHITE_STAINED_GLASS_PANE.delegate); - STAINED_GLASS_PANE_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_STAINED_GLASS_PANE.delegate); - STAINED_GLASS_PANE_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_STAINED_GLASS_PANE.delegate); - STAINED_GLASS_PANE_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_STAINED_GLASS_PANE.delegate); - STAINED_GLASS_PANE_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_STAINED_GLASS_PANE.delegate); - STAINED_GLASS_PANE_MAP.put(DyeColor.LIME, Blocks.LIME_STAINED_GLASS_PANE.delegate); - STAINED_GLASS_PANE_MAP.put(DyeColor.PINK, Blocks.PINK_STAINED_GLASS_PANE.delegate); - STAINED_GLASS_PANE_MAP.put(DyeColor.GRAY, Blocks.GRAY_STAINED_GLASS_PANE.delegate); - STAINED_GLASS_PANE_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_STAINED_GLASS_PANE.delegate); - STAINED_GLASS_PANE_MAP.put(DyeColor.CYAN, Blocks.CYAN_STAINED_GLASS_PANE.delegate); - STAINED_GLASS_PANE_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_STAINED_GLASS_PANE.delegate); - STAINED_GLASS_PANE_MAP.put(DyeColor.BLUE, Blocks.BLUE_STAINED_GLASS_PANE.delegate); - STAINED_GLASS_PANE_MAP.put(DyeColor.BROWN, Blocks.BROWN_STAINED_GLASS_PANE.delegate); - STAINED_GLASS_PANE_MAP.put(DyeColor.GREEN, Blocks.GREEN_STAINED_GLASS_PANE.delegate); - STAINED_GLASS_PANE_MAP.put(DyeColor.RED, Blocks.RED_STAINED_GLASS_PANE.delegate); - STAINED_GLASS_PANE_MAP.put(DyeColor.BLACK, Blocks.BLACK_STAINED_GLASS_PANE.delegate); - - TERRACOTTA_MAP.put(DyeColor.WHITE, Blocks.WHITE_TERRACOTTA.delegate); - TERRACOTTA_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_TERRACOTTA.delegate); - TERRACOTTA_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_TERRACOTTA.delegate); - TERRACOTTA_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_TERRACOTTA.delegate); - TERRACOTTA_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_TERRACOTTA.delegate); - TERRACOTTA_MAP.put(DyeColor.LIME, Blocks.LIME_TERRACOTTA.delegate); - TERRACOTTA_MAP.put(DyeColor.PINK, Blocks.PINK_TERRACOTTA.delegate); - TERRACOTTA_MAP.put(DyeColor.GRAY, Blocks.GRAY_TERRACOTTA.delegate); - TERRACOTTA_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_TERRACOTTA.delegate); - TERRACOTTA_MAP.put(DyeColor.CYAN, Blocks.CYAN_TERRACOTTA.delegate); - TERRACOTTA_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_TERRACOTTA.delegate); - TERRACOTTA_MAP.put(DyeColor.BLUE, Blocks.BLUE_TERRACOTTA.delegate); - TERRACOTTA_MAP.put(DyeColor.BROWN, Blocks.BROWN_TERRACOTTA.delegate); - TERRACOTTA_MAP.put(DyeColor.GREEN, Blocks.GREEN_TERRACOTTA.delegate); - TERRACOTTA_MAP.put(DyeColor.RED, Blocks.RED_TERRACOTTA.delegate); - TERRACOTTA_MAP.put(DyeColor.BLACK, Blocks.BLACK_TERRACOTTA.delegate); - - GLAZED_TERRACOTTA_MAP.put(DyeColor.WHITE, Blocks.WHITE_GLAZED_TERRACOTTA.delegate); - GLAZED_TERRACOTTA_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_GLAZED_TERRACOTTA.delegate); - GLAZED_TERRACOTTA_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_GLAZED_TERRACOTTA.delegate); - GLAZED_TERRACOTTA_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_GLAZED_TERRACOTTA.delegate); - GLAZED_TERRACOTTA_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_GLAZED_TERRACOTTA.delegate); - GLAZED_TERRACOTTA_MAP.put(DyeColor.LIME, Blocks.LIME_GLAZED_TERRACOTTA.delegate); - GLAZED_TERRACOTTA_MAP.put(DyeColor.PINK, Blocks.PINK_GLAZED_TERRACOTTA.delegate); - GLAZED_TERRACOTTA_MAP.put(DyeColor.GRAY, Blocks.GRAY_GLAZED_TERRACOTTA.delegate); - GLAZED_TERRACOTTA_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_GLAZED_TERRACOTTA.delegate); - GLAZED_TERRACOTTA_MAP.put(DyeColor.CYAN, Blocks.CYAN_GLAZED_TERRACOTTA.delegate); - GLAZED_TERRACOTTA_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_GLAZED_TERRACOTTA.delegate); - GLAZED_TERRACOTTA_MAP.put(DyeColor.BLUE, Blocks.BLUE_GLAZED_TERRACOTTA.delegate); - GLAZED_TERRACOTTA_MAP.put(DyeColor.BROWN, Blocks.BROWN_GLAZED_TERRACOTTA.delegate); - GLAZED_TERRACOTTA_MAP.put(DyeColor.GREEN, Blocks.GREEN_GLAZED_TERRACOTTA.delegate); - GLAZED_TERRACOTTA_MAP.put(DyeColor.RED, Blocks.RED_GLAZED_TERRACOTTA.delegate); - GLAZED_TERRACOTTA_MAP.put(DyeColor.BLACK, Blocks.BLACK_GLAZED_TERRACOTTA.delegate); - - WOOL_MAP.put(DyeColor.WHITE, Blocks.WHITE_WOOL.delegate); - WOOL_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_WOOL.delegate); - WOOL_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_WOOL.delegate); - WOOL_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_WOOL.delegate); - WOOL_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_WOOL.delegate); - WOOL_MAP.put(DyeColor.LIME, Blocks.LIME_WOOL.delegate); - WOOL_MAP.put(DyeColor.PINK, Blocks.PINK_WOOL.delegate); - WOOL_MAP.put(DyeColor.GRAY, Blocks.GRAY_WOOL.delegate); - WOOL_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_WOOL.delegate); - WOOL_MAP.put(DyeColor.CYAN, Blocks.CYAN_WOOL.delegate); - WOOL_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_WOOL.delegate); - WOOL_MAP.put(DyeColor.BLUE, Blocks.BLUE_WOOL.delegate); - WOOL_MAP.put(DyeColor.BROWN, Blocks.BROWN_WOOL.delegate); - WOOL_MAP.put(DyeColor.GREEN, Blocks.GREEN_WOOL.delegate); - WOOL_MAP.put(DyeColor.RED, Blocks.RED_WOOL.delegate); - WOOL_MAP.put(DyeColor.BLACK, Blocks.BLACK_WOOL.delegate); - - CARPET_MAP.put(DyeColor.WHITE, Blocks.WHITE_CARPET.delegate); - CARPET_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_CARPET.delegate); - CARPET_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_CARPET.delegate); - CARPET_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_CARPET.delegate); - CARPET_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_CARPET.delegate); - CARPET_MAP.put(DyeColor.LIME, Blocks.LIME_CARPET.delegate); - CARPET_MAP.put(DyeColor.PINK, Blocks.PINK_CARPET.delegate); - CARPET_MAP.put(DyeColor.GRAY, Blocks.GRAY_CARPET.delegate); - CARPET_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_CARPET.delegate); - CARPET_MAP.put(DyeColor.CYAN, Blocks.CYAN_CARPET.delegate); - CARPET_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_CARPET.delegate); - CARPET_MAP.put(DyeColor.BLUE, Blocks.BLUE_CARPET.delegate); - CARPET_MAP.put(DyeColor.BROWN, Blocks.BROWN_CARPET.delegate); - CARPET_MAP.put(DyeColor.GREEN, Blocks.GREEN_CARPET.delegate); - CARPET_MAP.put(DyeColor.RED, Blocks.RED_CARPET.delegate); - CARPET_MAP.put(DyeColor.BLACK, Blocks.BLACK_CARPET.delegate); - - CONCRETE_MAP.put(DyeColor.WHITE, Blocks.WHITE_CONCRETE.delegate); - CONCRETE_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_CONCRETE.delegate); - CONCRETE_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_CONCRETE.delegate); - CONCRETE_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_CONCRETE.delegate); - CONCRETE_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_CONCRETE.delegate); - CONCRETE_MAP.put(DyeColor.LIME, Blocks.LIME_CONCRETE.delegate); - CONCRETE_MAP.put(DyeColor.PINK, Blocks.PINK_CONCRETE.delegate); - CONCRETE_MAP.put(DyeColor.GRAY, Blocks.GRAY_CONCRETE.delegate); - CONCRETE_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_CONCRETE.delegate); - CONCRETE_MAP.put(DyeColor.CYAN, Blocks.CYAN_CONCRETE.delegate); - CONCRETE_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_CONCRETE.delegate); - CONCRETE_MAP.put(DyeColor.BLUE, Blocks.BLUE_CONCRETE.delegate); - CONCRETE_MAP.put(DyeColor.BROWN, Blocks.BROWN_CONCRETE.delegate); - CONCRETE_MAP.put(DyeColor.GREEN, Blocks.GREEN_CONCRETE.delegate); - CONCRETE_MAP.put(DyeColor.RED, Blocks.RED_CONCRETE.delegate); - CONCRETE_MAP.put(DyeColor.BLACK, Blocks.BLACK_CONCRETE.delegate); - - CONCRETE_POWDER_MAP.put(DyeColor.WHITE, Blocks.WHITE_CONCRETE_POWDER.delegate); - CONCRETE_POWDER_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_CONCRETE_POWDER.delegate); - CONCRETE_POWDER_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_CONCRETE_POWDER.delegate); - CONCRETE_POWDER_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_CONCRETE_POWDER.delegate); - CONCRETE_POWDER_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_CONCRETE_POWDER.delegate); - CONCRETE_POWDER_MAP.put(DyeColor.LIME, Blocks.LIME_CONCRETE_POWDER.delegate); - CONCRETE_POWDER_MAP.put(DyeColor.PINK, Blocks.PINK_CONCRETE_POWDER.delegate); - CONCRETE_POWDER_MAP.put(DyeColor.GRAY, Blocks.GRAY_CONCRETE_POWDER.delegate); - CONCRETE_POWDER_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_CONCRETE_POWDER.delegate); - CONCRETE_POWDER_MAP.put(DyeColor.CYAN, Blocks.CYAN_CONCRETE_POWDER.delegate); - CONCRETE_POWDER_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_CONCRETE_POWDER.delegate); - CONCRETE_POWDER_MAP.put(DyeColor.BLUE, Blocks.BLUE_CONCRETE_POWDER.delegate); - CONCRETE_POWDER_MAP.put(DyeColor.BROWN, Blocks.BROWN_CONCRETE_POWDER.delegate); - CONCRETE_POWDER_MAP.put(DyeColor.GREEN, Blocks.GREEN_CONCRETE_POWDER.delegate); - CONCRETE_POWDER_MAP.put(DyeColor.RED, Blocks.RED_CONCRETE_POWDER.delegate); - CONCRETE_POWDER_MAP.put(DyeColor.BLACK, Blocks.BLACK_CONCRETE_POWDER.delegate); - } + public static final BiMap> STAINED_GLASS_MAP = HashBiMap.create(); + public static final BiMap> STAINED_GLASS_PANE_MAP = HashBiMap.create(); + public static final BiMap> TERRACOTTA_MAP = HashBiMap.create(); + public static final BiMap> GLAZED_TERRACOTTA_MAP = HashBiMap.create(); + public static final BiMap> WOOL_MAP = HashBiMap.create(); + public static final BiMap> CARPET_MAP = HashBiMap.create(); + public static final BiMap> CONCRETE_MAP = HashBiMap.create(); + public static final BiMap> CONCRETE_POWDER_MAP = HashBiMap.create(); - private ColorHelper() {} + public static void init() { + STAINED_GLASS_MAP.put(DyeColor.WHITE, Blocks.WHITE_STAINED_GLASS.delegate); + STAINED_GLASS_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_STAINED_GLASS.delegate); + STAINED_GLASS_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_STAINED_GLASS.delegate); + STAINED_GLASS_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_STAINED_GLASS.delegate); + STAINED_GLASS_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_STAINED_GLASS.delegate); + STAINED_GLASS_MAP.put(DyeColor.LIME, Blocks.LIME_STAINED_GLASS.delegate); + STAINED_GLASS_MAP.put(DyeColor.PINK, Blocks.PINK_STAINED_GLASS.delegate); + STAINED_GLASS_MAP.put(DyeColor.GRAY, Blocks.GRAY_STAINED_GLASS.delegate); + STAINED_GLASS_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_STAINED_GLASS.delegate); + STAINED_GLASS_MAP.put(DyeColor.CYAN, Blocks.CYAN_STAINED_GLASS.delegate); + STAINED_GLASS_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_STAINED_GLASS.delegate); + STAINED_GLASS_MAP.put(DyeColor.BLUE, Blocks.BLUE_STAINED_GLASS.delegate); + STAINED_GLASS_MAP.put(DyeColor.BROWN, Blocks.BROWN_STAINED_GLASS.delegate); + STAINED_GLASS_MAP.put(DyeColor.GREEN, Blocks.GREEN_STAINED_GLASS.delegate); + STAINED_GLASS_MAP.put(DyeColor.RED, Blocks.RED_STAINED_GLASS.delegate); + STAINED_GLASS_MAP.put(DyeColor.BLACK, Blocks.BLACK_STAINED_GLASS.delegate); + + STAINED_GLASS_PANE_MAP.put(DyeColor.WHITE, Blocks.WHITE_STAINED_GLASS_PANE.delegate); + STAINED_GLASS_PANE_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_STAINED_GLASS_PANE.delegate); + STAINED_GLASS_PANE_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_STAINED_GLASS_PANE.delegate); + STAINED_GLASS_PANE_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_STAINED_GLASS_PANE.delegate); + STAINED_GLASS_PANE_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_STAINED_GLASS_PANE.delegate); + STAINED_GLASS_PANE_MAP.put(DyeColor.LIME, Blocks.LIME_STAINED_GLASS_PANE.delegate); + STAINED_GLASS_PANE_MAP.put(DyeColor.PINK, Blocks.PINK_STAINED_GLASS_PANE.delegate); + STAINED_GLASS_PANE_MAP.put(DyeColor.GRAY, Blocks.GRAY_STAINED_GLASS_PANE.delegate); + STAINED_GLASS_PANE_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_STAINED_GLASS_PANE.delegate); + STAINED_GLASS_PANE_MAP.put(DyeColor.CYAN, Blocks.CYAN_STAINED_GLASS_PANE.delegate); + STAINED_GLASS_PANE_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_STAINED_GLASS_PANE.delegate); + STAINED_GLASS_PANE_MAP.put(DyeColor.BLUE, Blocks.BLUE_STAINED_GLASS_PANE.delegate); + STAINED_GLASS_PANE_MAP.put(DyeColor.BROWN, Blocks.BROWN_STAINED_GLASS_PANE.delegate); + STAINED_GLASS_PANE_MAP.put(DyeColor.GREEN, Blocks.GREEN_STAINED_GLASS_PANE.delegate); + STAINED_GLASS_PANE_MAP.put(DyeColor.RED, Blocks.RED_STAINED_GLASS_PANE.delegate); + STAINED_GLASS_PANE_MAP.put(DyeColor.BLACK, Blocks.BLACK_STAINED_GLASS_PANE.delegate); + + TERRACOTTA_MAP.put(DyeColor.WHITE, Blocks.WHITE_TERRACOTTA.delegate); + TERRACOTTA_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_TERRACOTTA.delegate); + TERRACOTTA_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_TERRACOTTA.delegate); + TERRACOTTA_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_TERRACOTTA.delegate); + TERRACOTTA_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_TERRACOTTA.delegate); + TERRACOTTA_MAP.put(DyeColor.LIME, Blocks.LIME_TERRACOTTA.delegate); + TERRACOTTA_MAP.put(DyeColor.PINK, Blocks.PINK_TERRACOTTA.delegate); + TERRACOTTA_MAP.put(DyeColor.GRAY, Blocks.GRAY_TERRACOTTA.delegate); + TERRACOTTA_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_TERRACOTTA.delegate); + TERRACOTTA_MAP.put(DyeColor.CYAN, Blocks.CYAN_TERRACOTTA.delegate); + TERRACOTTA_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_TERRACOTTA.delegate); + TERRACOTTA_MAP.put(DyeColor.BLUE, Blocks.BLUE_TERRACOTTA.delegate); + TERRACOTTA_MAP.put(DyeColor.BROWN, Blocks.BROWN_TERRACOTTA.delegate); + TERRACOTTA_MAP.put(DyeColor.GREEN, Blocks.GREEN_TERRACOTTA.delegate); + TERRACOTTA_MAP.put(DyeColor.RED, Blocks.RED_TERRACOTTA.delegate); + TERRACOTTA_MAP.put(DyeColor.BLACK, Blocks.BLACK_TERRACOTTA.delegate); + + GLAZED_TERRACOTTA_MAP.put(DyeColor.WHITE, Blocks.WHITE_GLAZED_TERRACOTTA.delegate); + GLAZED_TERRACOTTA_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_GLAZED_TERRACOTTA.delegate); + GLAZED_TERRACOTTA_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_GLAZED_TERRACOTTA.delegate); + GLAZED_TERRACOTTA_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_GLAZED_TERRACOTTA.delegate); + GLAZED_TERRACOTTA_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_GLAZED_TERRACOTTA.delegate); + GLAZED_TERRACOTTA_MAP.put(DyeColor.LIME, Blocks.LIME_GLAZED_TERRACOTTA.delegate); + GLAZED_TERRACOTTA_MAP.put(DyeColor.PINK, Blocks.PINK_GLAZED_TERRACOTTA.delegate); + GLAZED_TERRACOTTA_MAP.put(DyeColor.GRAY, Blocks.GRAY_GLAZED_TERRACOTTA.delegate); + GLAZED_TERRACOTTA_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_GLAZED_TERRACOTTA.delegate); + GLAZED_TERRACOTTA_MAP.put(DyeColor.CYAN, Blocks.CYAN_GLAZED_TERRACOTTA.delegate); + GLAZED_TERRACOTTA_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_GLAZED_TERRACOTTA.delegate); + GLAZED_TERRACOTTA_MAP.put(DyeColor.BLUE, Blocks.BLUE_GLAZED_TERRACOTTA.delegate); + GLAZED_TERRACOTTA_MAP.put(DyeColor.BROWN, Blocks.BROWN_GLAZED_TERRACOTTA.delegate); + GLAZED_TERRACOTTA_MAP.put(DyeColor.GREEN, Blocks.GREEN_GLAZED_TERRACOTTA.delegate); + GLAZED_TERRACOTTA_MAP.put(DyeColor.RED, Blocks.RED_GLAZED_TERRACOTTA.delegate); + GLAZED_TERRACOTTA_MAP.put(DyeColor.BLACK, Blocks.BLACK_GLAZED_TERRACOTTA.delegate); + + WOOL_MAP.put(DyeColor.WHITE, Blocks.WHITE_WOOL.delegate); + WOOL_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_WOOL.delegate); + WOOL_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_WOOL.delegate); + WOOL_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_WOOL.delegate); + WOOL_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_WOOL.delegate); + WOOL_MAP.put(DyeColor.LIME, Blocks.LIME_WOOL.delegate); + WOOL_MAP.put(DyeColor.PINK, Blocks.PINK_WOOL.delegate); + WOOL_MAP.put(DyeColor.GRAY, Blocks.GRAY_WOOL.delegate); + WOOL_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_WOOL.delegate); + WOOL_MAP.put(DyeColor.CYAN, Blocks.CYAN_WOOL.delegate); + WOOL_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_WOOL.delegate); + WOOL_MAP.put(DyeColor.BLUE, Blocks.BLUE_WOOL.delegate); + WOOL_MAP.put(DyeColor.BROWN, Blocks.BROWN_WOOL.delegate); + WOOL_MAP.put(DyeColor.GREEN, Blocks.GREEN_WOOL.delegate); + WOOL_MAP.put(DyeColor.RED, Blocks.RED_WOOL.delegate); + WOOL_MAP.put(DyeColor.BLACK, Blocks.BLACK_WOOL.delegate); + + CARPET_MAP.put(DyeColor.WHITE, Blocks.WHITE_CARPET.delegate); + CARPET_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_CARPET.delegate); + CARPET_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_CARPET.delegate); + CARPET_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_CARPET.delegate); + CARPET_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_CARPET.delegate); + CARPET_MAP.put(DyeColor.LIME, Blocks.LIME_CARPET.delegate); + CARPET_MAP.put(DyeColor.PINK, Blocks.PINK_CARPET.delegate); + CARPET_MAP.put(DyeColor.GRAY, Blocks.GRAY_CARPET.delegate); + CARPET_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_CARPET.delegate); + CARPET_MAP.put(DyeColor.CYAN, Blocks.CYAN_CARPET.delegate); + CARPET_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_CARPET.delegate); + CARPET_MAP.put(DyeColor.BLUE, Blocks.BLUE_CARPET.delegate); + CARPET_MAP.put(DyeColor.BROWN, Blocks.BROWN_CARPET.delegate); + CARPET_MAP.put(DyeColor.GREEN, Blocks.GREEN_CARPET.delegate); + CARPET_MAP.put(DyeColor.RED, Blocks.RED_CARPET.delegate); + CARPET_MAP.put(DyeColor.BLACK, Blocks.BLACK_CARPET.delegate); + + CONCRETE_MAP.put(DyeColor.WHITE, Blocks.WHITE_CONCRETE.delegate); + CONCRETE_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_CONCRETE.delegate); + CONCRETE_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_CONCRETE.delegate); + CONCRETE_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_CONCRETE.delegate); + CONCRETE_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_CONCRETE.delegate); + CONCRETE_MAP.put(DyeColor.LIME, Blocks.LIME_CONCRETE.delegate); + CONCRETE_MAP.put(DyeColor.PINK, Blocks.PINK_CONCRETE.delegate); + CONCRETE_MAP.put(DyeColor.GRAY, Blocks.GRAY_CONCRETE.delegate); + CONCRETE_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_CONCRETE.delegate); + CONCRETE_MAP.put(DyeColor.CYAN, Blocks.CYAN_CONCRETE.delegate); + CONCRETE_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_CONCRETE.delegate); + CONCRETE_MAP.put(DyeColor.BLUE, Blocks.BLUE_CONCRETE.delegate); + CONCRETE_MAP.put(DyeColor.BROWN, Blocks.BROWN_CONCRETE.delegate); + CONCRETE_MAP.put(DyeColor.GREEN, Blocks.GREEN_CONCRETE.delegate); + CONCRETE_MAP.put(DyeColor.RED, Blocks.RED_CONCRETE.delegate); + CONCRETE_MAP.put(DyeColor.BLACK, Blocks.BLACK_CONCRETE.delegate); + + CONCRETE_POWDER_MAP.put(DyeColor.WHITE, Blocks.WHITE_CONCRETE_POWDER.delegate); + CONCRETE_POWDER_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_CONCRETE_POWDER.delegate); + CONCRETE_POWDER_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_CONCRETE_POWDER.delegate); + CONCRETE_POWDER_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_CONCRETE_POWDER.delegate); + CONCRETE_POWDER_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_CONCRETE_POWDER.delegate); + CONCRETE_POWDER_MAP.put(DyeColor.LIME, Blocks.LIME_CONCRETE_POWDER.delegate); + CONCRETE_POWDER_MAP.put(DyeColor.PINK, Blocks.PINK_CONCRETE_POWDER.delegate); + CONCRETE_POWDER_MAP.put(DyeColor.GRAY, Blocks.GRAY_CONCRETE_POWDER.delegate); + CONCRETE_POWDER_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_CONCRETE_POWDER.delegate); + CONCRETE_POWDER_MAP.put(DyeColor.CYAN, Blocks.CYAN_CONCRETE_POWDER.delegate); + CONCRETE_POWDER_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_CONCRETE_POWDER.delegate); + CONCRETE_POWDER_MAP.put(DyeColor.BLUE, Blocks.BLUE_CONCRETE_POWDER.delegate); + CONCRETE_POWDER_MAP.put(DyeColor.BROWN, Blocks.BROWN_CONCRETE_POWDER.delegate); + CONCRETE_POWDER_MAP.put(DyeColor.GREEN, Blocks.GREEN_CONCRETE_POWDER.delegate); + CONCRETE_POWDER_MAP.put(DyeColor.RED, Blocks.RED_CONCRETE_POWDER.delegate); + CONCRETE_POWDER_MAP.put(DyeColor.BLACK, Blocks.BLACK_CONCRETE_POWDER.delegate); + } + + private ColorHelper() {} } diff --git a/src/main/java/vazkii/botania/api/boss/IBotaniaBoss.java b/src/main/java/vazkii/botania/api/boss/IBotaniaBoss.java index 7ac704ab3..e522717c5 100644 --- a/src/main/java/vazkii/botania/api/boss/IBotaniaBoss.java +++ b/src/main/java/vazkii/botania/api/boss/IBotaniaBoss.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Oct 29, 2014, 6:09:48 PM (GMT)] */ package vazkii.botania.api.boss; @@ -14,6 +12,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.world.server.ServerBossInfo; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.internal.ShaderCallback; import java.awt.*; @@ -49,6 +48,7 @@ public interface IBotaniaBoss { /** * A callback for when this boss's boss bar renders, you can do additional rendering * here if needed. + * * @return How tall your auxiliary renders were */ @OnlyIn(Dist.CLIENT) @@ -58,6 +58,7 @@ public interface IBotaniaBoss { * Get the serverside UUID of the {@link ServerBossInfo} instance tracking this boss * Note that this is NOT the entity's UUID, nor is it the clientside UUID of the BossInfoServer instance! * You will most likely need to sync this yourself using IEntityAdditionalSpawnData or similar. + * * @return The uuid. */ public UUID getBossInfoUuid(); @@ -66,15 +67,18 @@ public interface IBotaniaBoss { * The Shader Program to use for this boss's bar. Return 0 case * you don't want a shader to be used. You can use separate shaders * for the background and foreground. - * @param background True if rendering the background of the boss bar, - * false if rendering the bar itself that shows the HP. - * @return OpenGL program ID of the shader to use + * + * @param background True if rendering the background of the boss bar, + * false if rendering the bar itself that shows the HP. + * @return OpenGL program ID of the shader to use */ public int getBossBarShaderProgram(boolean background); /** * A callback for the shader, used to pass in uniforms. Return null for no callback. - * @return a ShaderCallback to use. If getBossBarShaderProgram returns an invalid shader the result of this method is ignored. + * + * @return a ShaderCallback to use. If getBossBarShaderProgram returns an invalid shader the result of this method + * is ignored. */ public ShaderCallback getBossBarShaderCallback(boolean background, int shader); diff --git a/src/main/java/vazkii/botania/api/brew/Brew.java b/src/main/java/vazkii/botania/api/brew/Brew.java index 824ac5b49..64662df19 100644 --- a/src/main/java/vazkii/botania/api/brew/Brew.java +++ b/src/main/java/vazkii/botania/api/brew/Brew.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 1, 2014, 6:22:54 PM (GMT)] */ package vazkii.botania.api.brew; import com.google.common.collect.ImmutableList; + import net.minecraft.item.ItemStack; import net.minecraft.potion.EffectInstance; @@ -30,10 +29,10 @@ public class Brew { private boolean canInfuseIncense = true; /** - * @param name The unlocalized name of this potion. - * @param color The color for the potion to be rendered in the bottle, note that it will get - * changed a bit when it renders (for more or less brightness) to give a fancy effect. - * @param cost The cost, in Mana for this brew. + * @param name The unlocalized name of this potion. + * @param color The color for the potion to be rendered in the bottle, note that it will get + * changed a bit when it renders (for more or less brightness) to give a fancy effect. + * @param cost The cost, in Mana for this brew. * @param effects A list of effects to apply to the player when they drink it. */ public Brew(String key, String name, int color, int cost, EffectInstance... effects) { @@ -91,7 +90,7 @@ public class Brew { } /** - * Gets the display color for the ItemStack passed in. Note that for + * Gets the display color for the ItemStack passed in. Note that for * the lexicon, this passes in a botania Managlass Vial or an * Alfglass Flask at all times. */ diff --git a/src/main/java/vazkii/botania/api/brew/IBrewContainer.java b/src/main/java/vazkii/botania/api/brew/IBrewContainer.java index 36f659b6b..9e9ad5d1c 100644 --- a/src/main/java/vazkii/botania/api/brew/IBrewContainer.java +++ b/src/main/java/vazkii/botania/api/brew/IBrewContainer.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 1, 2014, 6:26:40 PM (GMT)] */ package vazkii.botania.api.brew; diff --git a/src/main/java/vazkii/botania/api/brew/IBrewItem.java b/src/main/java/vazkii/botania/api/brew/IBrewItem.java index 1ae2badae..3b5aae185 100644 --- a/src/main/java/vazkii/botania/api/brew/IBrewItem.java +++ b/src/main/java/vazkii/botania/api/brew/IBrewItem.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 1, 2014, 9:20:33 PM (GMT)] */ package vazkii.botania.api.brew; diff --git a/src/main/java/vazkii/botania/api/capability/FloatingFlowerImpl.java b/src/main/java/vazkii/botania/api/capability/FloatingFlowerImpl.java index e8682ec75..d587e98e6 100644 --- a/src/main/java/vazkii/botania/api/capability/FloatingFlowerImpl.java +++ b/src/main/java/vazkii/botania/api/capability/FloatingFlowerImpl.java @@ -1,23 +1,32 @@ +/* + * This class is 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 + */ package vazkii.botania.api.capability; import net.minecraft.item.ItemStack; + import vazkii.botania.api.item.IFloatingFlower; public class FloatingFlowerImpl implements IFloatingFlower { - private IslandType type = IslandType.GRASS; + private IslandType type = IslandType.GRASS; - @Override - public ItemStack getDisplayStack() { - return ItemStack.EMPTY; - } + @Override + public ItemStack getDisplayStack() { + return ItemStack.EMPTY; + } - @Override - public IslandType getIslandType() { - return type; - } + @Override + public IslandType getIslandType() { + return type; + } - @Override - public void setIslandType(IslandType type) { - this.type = type; - } + @Override + public void setIslandType(IslandType type) { + this.type = type; + } } diff --git a/src/main/java/vazkii/botania/api/corporea/CorporeaHelper.java b/src/main/java/vazkii/botania/api/corporea/CorporeaHelper.java index b2ba17093..e684878f7 100644 --- a/src/main/java/vazkii/botania/api/corporea/CorporeaHelper.java +++ b/src/main/java/vazkii/botania/api/corporea/CorporeaHelper.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 14, 2015, 3:28:54 PM (GMT)] */ package vazkii.botania.api.corporea; import com.google.common.base.Predicates; import com.google.common.collect.ImmutableList; + import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -20,6 +19,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; + import vazkii.botania.api.BotaniaAPI; import java.util.ArrayList; @@ -50,24 +50,29 @@ public final class CorporeaHelper { */ public static List getInventoriesOnNetwork(ICorporeaSpark spark) { ICorporeaSpark master = spark.getMaster(); - if(master == null) + if (master == null) { return empty; + } List network = master.getConnections(); - if(cachedNetworks.containsKey(network)) { + if (cachedNetworks.containsKey(network)) { List cache = cachedNetworks.get(network); - if(cache != null) + if (cache != null) { return cache; + } } List inventories = new ArrayList<>(); - if(network != null) - for(ICorporeaSpark otherSpark : network) - if(otherSpark != null) { + if (network != null) { + for (ICorporeaSpark otherSpark : network) { + if (otherSpark != null) { InvWithLocation inv = otherSpark.getSparkInventory(); - if(inv != null) + if (inv != null) { inventories.add(inv); + } } + } + } cachedNetworks.put(network, inventories); return inventories; @@ -99,8 +104,9 @@ public final class CorporeaHelper { public static int getCountInNetwork(ICorporeaRequestMatcher matcher, Map inventories) { int count = 0; - for(int value : inventories.values()) + for (int value : inventories.values()) { count += value; + } return count; } @@ -129,6 +135,7 @@ public final class CorporeaHelper { if (request.foundItems > 0) { countMap.put(inv.getWrappedObject(), request.foundItems); } + } return countMap; @@ -167,19 +174,22 @@ public final class CorporeaHelper { * This will remove the items from the adequate inventories unless the "doit" parameter is false. * Returns a new list of ItemStacks of the items acquired or an empty list if none was found. * Case itemCount is -1 it'll find EVERY item it can. - *

+ *
+ *
* The "matcher" parameter has to be an ItemStack or a String, if the first it'll check if the * two stacks are similar using the "checkNBT" parameter, else it'll check if the name of the item * equals or matches (case a regex is passed in) the matcher string. - *

+ *
+ *
* When requesting counting of items, individual stacks may exceed maxStackSize for * purposes of counting huge amounts. */ public static List requestItem(ICorporeaRequestMatcher matcher, int itemCount, ICorporeaSpark spark, boolean doit) { List stacks = new ArrayList<>(); CorporeaRequestEvent event = new CorporeaRequestEvent(matcher, itemCount, spark, doit); - if(MinecraftForge.EVENT_BUS.post(event)) + if (MinecraftForge.EVENT_BUS.post(event)) { return stacks; + } List inventories = getInventoriesOnNetwork(spark); @@ -187,25 +197,26 @@ public final class CorporeaHelper { Map interceptors = new HashMap(); CorporeaRequest request = new CorporeaRequest(matcher, itemCount); - for(IWrappedInventory inv : inventoriesW) { + for (IWrappedInventory inv : inventoriesW) { ICorporeaSpark invSpark = inv.getSpark(); InvWithLocation originalInventory = inv.getWrappedObject(); - if(originalInventory.world.getTileEntity(originalInventory.pos) instanceof ICorporeaInterceptor) { + if (originalInventory.world.getTileEntity(originalInventory.pos) instanceof ICorporeaInterceptor) { ICorporeaInterceptor interceptor = (ICorporeaInterceptor) originalInventory.world.getTileEntity(originalInventory.pos); interceptor.interceptRequest(matcher, itemCount, invSpark, spark, stacks, inventories, doit); interceptors.put(interceptor, invSpark); } - if(doit) { + if (doit) { stacks.addAll(inv.extractItems(request)); } else { stacks.addAll(inv.countItems(request)); } } - for(ICorporeaInterceptor interceptor : interceptors.keySet()) + for (ICorporeaInterceptor interceptor : interceptors.keySet()) { interceptor.interceptRequestLast(matcher, itemCount, interceptors.get(interceptor), spark, stacks, inventories, doit); + } lastRequestMatches = request.foundItems; lastRequestExtractions = request.extractedItems; @@ -245,13 +256,18 @@ public final class CorporeaHelper { public static void clearCache() { cachedNetworks.clear(); } - - /** - * Returns the comparator strength for a corporea request that corporea crystal cubes and retainers use, following the usual "each step up requires double the items" formula. + + /** + * Returns the comparator strength for a corporea request that corporea crystal cubes and retainers use, following + * the usual "each step up requires double the items" formula. */ public static int signalStrengthForRequestSize(int requestSize) { - if(requestSize <= 0) return 0; - else if (requestSize >= 16384) return 15; - else return Math.min(15, MathHelper.log2(requestSize) + 1); + if (requestSize <= 0) { + return 0; + } else if (requestSize >= 16384) { + return 15; + } else { + return Math.min(15, MathHelper.log2(requestSize) + 1); + } } } diff --git a/src/main/java/vazkii/botania/api/corporea/CorporeaIndexRequestEvent.java b/src/main/java/vazkii/botania/api/corporea/CorporeaIndexRequestEvent.java index 99e50a1da..61d54eb4a 100644 --- a/src/main/java/vazkii/botania/api/corporea/CorporeaIndexRequestEvent.java +++ b/src/main/java/vazkii/botania/api/corporea/CorporeaIndexRequestEvent.java @@ -1,11 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 - * */ package vazkii.botania.api.corporea; @@ -13,17 +12,17 @@ import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; -/** +/** * CorporeaIndexRequestEvent is fired when a player attempts to request an item from a corporea index. * If the event is cancelled, the request will not be performed. - * */ + */ @Cancelable public class CorporeaIndexRequestEvent extends Event { public final ServerPlayerEntity requester; public ICorporeaRequestMatcher request; public int requestCount; public ICorporeaSpark indexSpark; - + public CorporeaIndexRequestEvent(ServerPlayerEntity requester, ICorporeaRequestMatcher request, int requestCount, ICorporeaSpark indexSpark) { this.requester = requester; this.request = request; diff --git a/src/main/java/vazkii/botania/api/corporea/CorporeaRequest.java b/src/main/java/vazkii/botania/api/corporea/CorporeaRequest.java index e83d14d07..602f8a96a 100644 --- a/src/main/java/vazkii/botania/api/corporea/CorporeaRequest.java +++ b/src/main/java/vazkii/botania/api/corporea/CorporeaRequest.java @@ -1,11 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 - * */ package vazkii.botania.api.corporea; diff --git a/src/main/java/vazkii/botania/api/corporea/CorporeaRequestDefaultMatchers.java b/src/main/java/vazkii/botania/api/corporea/CorporeaRequestDefaultMatchers.java index 7f2137136..a3a6699cf 100644 --- a/src/main/java/vazkii/botania/api/corporea/CorporeaRequestDefaultMatchers.java +++ b/src/main/java/vazkii/botania/api/corporea/CorporeaRequestDefaultMatchers.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Dec 22, 2019, 11:13:14 PM (GMT)] */ package vazkii.botania.api.corporea; @@ -14,21 +12,24 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; + import org.apache.commons.lang3.text.WordUtils; + import vazkii.botania.common.core.helper.ItemNBTHelper; import java.util.regex.Pattern; /** * An interface for a Corporea Request matcher. Accepts an ItemStack and returns whether it fulfills the request. - * Needs to be registered over in {@link vazkii.botania.common.block.tile.corporea.TileCorporeaRetainer#addCorporeaRequestMatcher}. + * Needs to be registered over in + * {@link vazkii.botania.common.block.tile.corporea.TileCorporeaRetainer#addCorporeaRequestMatcher}. */ public final class CorporeaRequestDefaultMatchers { public static class CorporeaStringMatcher implements ICorporeaRequestMatcher { private static final Pattern patternControlCode = Pattern.compile("(?i)\\u00A7[0-9A-FK-OR]"); - public static final String[] WILDCARD_STRINGS = { "...", "~", "+", "?" , "*" }; + public static final String[] WILDCARD_STRINGS = { "...", "~", "+", "?", "*" }; private static final String TAG_REQUEST_CONTENTS = "requestContents"; private static final String TAG_REQUEST_CONTAINS = "requestContains"; @@ -37,22 +38,23 @@ public final class CorporeaRequestDefaultMatchers { public CorporeaStringMatcher(String expression) { boolean contains = false; - for(String wc : WILDCARD_STRINGS) { - if(expression.endsWith(wc)) { + for (String wc : WILDCARD_STRINGS) { + if (expression.endsWith(wc)) { contains = true; expression = expression.substring(0, expression.length() - wc.length()); - } - else if(expression.startsWith(wc)) { + } else if (expression.startsWith(wc)) { contains = true; expression = expression.substring(wc.length()); } - if(contains) + if (contains) { break; + } } this.expression = expression; this.contains = contains; } + private CorporeaStringMatcher(String expression, boolean contains) { this.expression = expression; this.contains = contains; @@ -60,14 +62,15 @@ public final class CorporeaRequestDefaultMatchers { @Override public boolean isStackValid(ItemStack stack) { - if(stack.isEmpty()) + if (stack.isEmpty()) { return false; + } String name = stripControlCodes(stack.getDisplayName().getString().toLowerCase().trim()); return equalOrContain(name) - || equalOrContain(name + "s") - || equalOrContain(name + "es") - || name.endsWith("y") && equalOrContain(name.substring(0, name.length() - 1) + "ies"); + || equalOrContain(name + "s") + || equalOrContain(name + "es") + || name.endsWith("y") && equalOrContain(name.substring(0, name.length() - 1) + "ies"); } public static ICorporeaRequestMatcher createFromNBT(CompoundNBT tag) { diff --git a/src/main/java/vazkii/botania/api/corporea/CorporeaRequestEvent.java b/src/main/java/vazkii/botania/api/corporea/CorporeaRequestEvent.java index 55fc9ab62..196761294 100644 --- a/src/main/java/vazkii/botania/api/corporea/CorporeaRequestEvent.java +++ b/src/main/java/vazkii/botania/api/corporea/CorporeaRequestEvent.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 30, 2015, 2:55:57 PM (GMT)] */ package vazkii.botania.api.corporea; @@ -34,5 +32,4 @@ public class CorporeaRequestEvent extends Event { realRequest = real; } - } diff --git a/src/main/java/vazkii/botania/api/corporea/ICorporeaInterceptor.java b/src/main/java/vazkii/botania/api/corporea/ICorporeaInterceptor.java index e8a2b7c02..bc4bfeb24 100644 --- a/src/main/java/vazkii/botania/api/corporea/ICorporeaInterceptor.java +++ b/src/main/java/vazkii/botania/api/corporea/ICorporeaInterceptor.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 19, 2015, 6:23:31 PM (GMT)] */ package vazkii.botania.api.corporea; diff --git a/src/main/java/vazkii/botania/api/corporea/ICorporeaRequestMatcher.java b/src/main/java/vazkii/botania/api/corporea/ICorporeaRequestMatcher.java index d7c9b3ce0..c6e18448e 100644 --- a/src/main/java/vazkii/botania/api/corporea/ICorporeaRequestMatcher.java +++ b/src/main/java/vazkii/botania/api/corporea/ICorporeaRequestMatcher.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Dec 22, 2019, 11:13:14 PM (GMT)] */ package vazkii.botania.api.corporea; @@ -16,8 +14,10 @@ import net.minecraft.util.text.ITextComponent; /** * An interface for a Corporea Request matcher. Accepts an ItemStack and returns whether it fulfills the request. - * Needs to be registered over in {@link vazkii.botania.common.block.tile.corporea.TileCorporeaRetainer#addCorporeaRequestMatcher}. - * Needs one additional (static) method for deserialization, which can't really go here because Java doesn't like static abstract's. + * Needs to be registered over in + * {@link vazkii.botania.common.block.tile.corporea.TileCorporeaRetainer#addCorporeaRequestMatcher}. + * Needs one additional (static) method for deserialization, which can't really go here because Java doesn't like static + * abstract's. */ public interface ICorporeaRequestMatcher { diff --git a/src/main/java/vazkii/botania/api/corporea/ICorporeaRequestor.java b/src/main/java/vazkii/botania/api/corporea/ICorporeaRequestor.java index 751362724..83a016f71 100644 --- a/src/main/java/vazkii/botania/api/corporea/ICorporeaRequestor.java +++ b/src/main/java/vazkii/botania/api/corporea/ICorporeaRequestor.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 28, 2015, 11:25:48 AM (GMT)] */ package vazkii.botania.api.corporea; @@ -18,8 +16,8 @@ package vazkii.botania.api.corporea; public interface ICorporeaRequestor { /* - * Executes the passed in request. - */ + * Executes the passed in request. + */ public void doCorporeaRequest(ICorporeaRequestMatcher request, int count, ICorporeaSpark spark); } diff --git a/src/main/java/vazkii/botania/api/corporea/ICorporeaSpark.java b/src/main/java/vazkii/botania/api/corporea/ICorporeaSpark.java index 7a16ae3c8..36195bf9d 100644 --- a/src/main/java/vazkii/botania/api/corporea/ICorporeaSpark.java +++ b/src/main/java/vazkii/botania/api/corporea/ICorporeaSpark.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 13, 2015, 10:53:05 PM (GMT)] */ package vazkii.botania.api.corporea; @@ -26,7 +24,8 @@ public interface ICorporeaSpark { * which is the one that initiated the chain call, the referrer which passed the call to this instance * and the List of sparks connected. Normal behavior should be to find any sparks around that are not * already present in the list of connections and add them to it, passing the function call to them. - *

+ *
+ *
* The connections List and the master Spark should be kept in this instance as pointers for use in * getConnections() and getMaster() and passed in to any subsequent registerConnections calls on sparks * found nearby. This is only called whenever a new spark is added or removed from and to the network, diff --git a/src/main/java/vazkii/botania/api/corporea/IWrappedInventory.java b/src/main/java/vazkii/botania/api/corporea/IWrappedInventory.java index 626c377c7..8844775c2 100644 --- a/src/main/java/vazkii/botania/api/corporea/IWrappedInventory.java +++ b/src/main/java/vazkii/botania/api/corporea/IWrappedInventory.java @@ -1,11 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 - * */ package vazkii.botania.api.corporea; @@ -16,7 +15,6 @@ import java.util.List; /** * This interface wraps IInventory corporea works with in order to provide * compatibility with different storage mods. - * */ public interface IWrappedInventory { @@ -28,11 +26,11 @@ public interface IWrappedInventory { /** * Counts items in the inventory matching the request * - * @param request - * - specifies what should be found - * @return List of ItemStack, individual stacks may exceed maxStackSize for - * purposes of counting huge amounts. To get final count requestor - * should sum stackSize of all stacks. + * @param request + * - specifies what should be found + * @return List of ItemStack, individual stacks may exceed maxStackSize for + * purposes of counting huge amounts. To get final count requestor + * should sum stackSize of all stacks. */ List countItems(CorporeaRequest request); @@ -49,8 +47,8 @@ public interface IWrappedInventory { * {@link CorporeaRequest#extractedItems} are updated to reflect how many * items were found and extracted. * - * @param request - * @return List of ItemStacks to be delivered to the destination. + * @param request + * @return List of ItemStacks to be delivered to the destination. */ List extractItems(CorporeaRequest request); } diff --git a/src/main/java/vazkii/botania/api/corporea/InvWithLocation.java b/src/main/java/vazkii/botania/api/corporea/InvWithLocation.java index e5af2cd98..7eb51d84c 100644 --- a/src/main/java/vazkii/botania/api/corporea/InvWithLocation.java +++ b/src/main/java/vazkii/botania/api/corporea/InvWithLocation.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.api.corporea; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/vazkii/botania/api/imc/IMC.java b/src/main/java/vazkii/botania/api/imc/IMC.java index bc22d077b..d9b9ef89b 100644 --- a/src/main/java/vazkii/botania/api/imc/IMC.java +++ b/src/main/java/vazkii/botania/api/imc/IMC.java @@ -1,39 +1,38 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 06, 2019] */ package vazkii.botania.api.imc; /** * This class defines the IMC methods accepted by Botania and their expected argument types + * * @see net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent * @see net.minecraftforge.fml.event.lifecycle.InterModProcessEvent * @see net.minecraftforge.fml.InterModComms */ public class IMC { - /** - * Maps a block tag to its weight in world generation. This is used for the Orechid flower.
- * The argument should be a {@link OreWeightMessage}, any other types are ignored.
- * Check the Botania source to see default values.
- */ - public static final String REGISTER_ORE_WEIGHT = "register_ore_weight"; + /** + * Maps a block tag to its weight in world generation. This is used for the Orechid flower.
+ * The argument should be a {@link OreWeightMessage}, any other types are ignored.
+ * Check the Botania source to see default values.
+ */ + public static final String REGISTER_ORE_WEIGHT = "register_ore_weight"; - /** - * Maps a block tag to its weight in nether world generation. This is used for the Orechid flower.
- * The argument should be a {@link OreWeightMessage}, any other types are ignored.
- * Check the Botania source to see default values.
- */ - public static final String REGISTER_NETHER_ORE_WEIGHT = "register_nether_ore_weight"; + /** + * Maps a block tag to its weight in nether world generation. This is used for the Orechid flower.
+ * The argument should be a {@link OreWeightMessage}, any other types are ignored.
+ * Check the Botania source to see default values.
+ */ + public static final String REGISTER_NETHER_ORE_WEIGHT = "register_nether_ore_weight"; - /** - * Registers a block as paintable under the paint lens.
- * The argument should be a {@link PaintableBlockMessage}, any other types are ignored. - */ - public static final String REGISTER_PAINTABLE_BLOCK = "register_paintable_block"; + /** + * Registers a block as paintable under the paint lens.
+ * The argument should be a {@link PaintableBlockMessage}, any other types are ignored. + */ + public static final String REGISTER_PAINTABLE_BLOCK = "register_paintable_block"; } diff --git a/src/main/java/vazkii/botania/api/imc/OreWeightMessage.java b/src/main/java/vazkii/botania/api/imc/OreWeightMessage.java index cbffbec8d..08b02cefc 100644 --- a/src/main/java/vazkii/botania/api/imc/OreWeightMessage.java +++ b/src/main/java/vazkii/botania/api/imc/OreWeightMessage.java @@ -1,25 +1,33 @@ +/* + * This class is 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 + */ package vazkii.botania.api.imc; import net.minecraft.util.ResourceLocation; public class OreWeightMessage { - private final ResourceLocation blockTag; - private final Integer weight; + private final ResourceLocation blockTag; + private final Integer weight; - /** - * @param blockTag ID of a block tag to register - * @param weight Weight of the tag - */ - public OreWeightMessage(ResourceLocation blockTag, Integer weight) { - this.blockTag = blockTag; - this.weight = weight; - } + /** + * @param blockTag ID of a block tag to register + * @param weight Weight of the tag + */ + public OreWeightMessage(ResourceLocation blockTag, Integer weight) { + this.blockTag = blockTag; + this.weight = weight; + } - public ResourceLocation getOre() { - return blockTag; - } + public ResourceLocation getOre() { + return blockTag; + } - public Integer getWeight() { - return weight; - } + public Integer getWeight() { + return weight; + } } diff --git a/src/main/java/vazkii/botania/api/imc/PaintableBlockMessage.java b/src/main/java/vazkii/botania/api/imc/PaintableBlockMessage.java index 7a1380886..a1117d584 100644 --- a/src/main/java/vazkii/botania/api/imc/PaintableBlockMessage.java +++ b/src/main/java/vazkii/botania/api/imc/PaintableBlockMessage.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.api.imc; import net.minecraft.block.Block; @@ -7,27 +15,27 @@ import net.minecraftforge.registries.IRegistryDelegate; import java.util.function.Function; public class PaintableBlockMessage { - private final IRegistryDelegate block; - private final Function transformer; + private final IRegistryDelegate block; + private final Function transformer; - public PaintableBlockMessage(Function transformer, Block block) { - this(transformer, block.delegate); - } + public PaintableBlockMessage(Function transformer, Block block) { + this(transformer, block.delegate); + } - /** - * @param transformer Lookup function from color to destination block - * @param block The block being converted - */ - public PaintableBlockMessage(Function transformer, IRegistryDelegate block) { - this.block = block; - this.transformer = transformer; - } + /** + * @param transformer Lookup function from color to destination block + * @param block The block being converted + */ + public PaintableBlockMessage(Function transformer, IRegistryDelegate block) { + this.block = block; + this.transformer = transformer; + } - public IRegistryDelegate getBlock() { - return block; - } + public IRegistryDelegate getBlock() { + return block; + } - public Function getTransformer() { - return transformer; - } + public Function getTransformer() { + return transformer; + } } diff --git a/src/main/java/vazkii/botania/api/internal/DummyManaNetwork.java b/src/main/java/vazkii/botania/api/internal/DummyManaNetwork.java index 11d9dc41c..434ecdbc4 100644 --- a/src/main/java/vazkii/botania/api/internal/DummyManaNetwork.java +++ b/src/main/java/vazkii/botania/api/internal/DummyManaNetwork.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 7, 2014, 3:47:43 PM (GMT)] */ package vazkii.botania.api.internal; import com.google.common.collect.ImmutableSet; + import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; diff --git a/src/main/java/vazkii/botania/api/internal/DummyMethodHandler.java b/src/main/java/vazkii/botania/api/internal/DummyMethodHandler.java index be6ee3df1..8b24b5dec 100644 --- a/src/main/java/vazkii/botania/api/internal/DummyMethodHandler.java +++ b/src/main/java/vazkii/botania/api/internal/DummyMethodHandler.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 14, 2014, 6:43:03 PM (GMT)] */ package vazkii.botania.api.internal; @@ -19,6 +17,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.items.IItemHandlerModifiable; + import vazkii.botania.api.corporea.IWrappedInventory; import vazkii.botania.api.corporea.InvWithLocation; import vazkii.botania.api.subtile.TileEntitySpecialFlower; @@ -79,7 +78,7 @@ public class DummyMethodHandler implements IInternalMethodHandler { return 0; } - @Override + @Override public List wrapInventory(List inventories) { return null; } diff --git a/src/main/java/vazkii/botania/api/internal/IInternalMethodHandler.java b/src/main/java/vazkii/botania/api/internal/IInternalMethodHandler.java index c3be8e1e6..28e55561f 100644 --- a/src/main/java/vazkii/botania/api/internal/IInternalMethodHandler.java +++ b/src/main/java/vazkii/botania/api/internal/IInternalMethodHandler.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 14, 2014, 6:34:34 PM (GMT)] */ package vazkii.botania.api.internal; @@ -21,6 +19,7 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.items.IItemHandlerModifiable; + import vazkii.botania.api.corporea.IWrappedInventory; import vazkii.botania.api.corporea.InvWithLocation; import vazkii.botania.api.subtile.TileEntitySpecialFlower; diff --git a/src/main/java/vazkii/botania/api/internal/IManaBurst.java b/src/main/java/vazkii/botania/api/internal/IManaBurst.java index 58dcdcff1..ea3816315 100644 --- a/src/main/java/vazkii/botania/api/internal/IManaBurst.java +++ b/src/main/java/vazkii/botania/api/internal/IManaBurst.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 31, 2014, 4:36:13 PM (GMT)] */ package vazkii.botania.api.internal; diff --git a/src/main/java/vazkii/botania/api/internal/IManaNetwork.java b/src/main/java/vazkii/botania/api/internal/IManaNetwork.java index 6e9789d19..eeced744e 100644 --- a/src/main/java/vazkii/botania/api/internal/IManaNetwork.java +++ b/src/main/java/vazkii/botania/api/internal/IManaNetwork.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 7, 2014, 3:39:48 PM (GMT)] */ package vazkii.botania.api.internal; @@ -18,6 +16,7 @@ import java.util.Set; /** * A basic interface for a world's Mana Network. + * * @see IInternalMethodHandler#getManaNetworkInstance() */ public interface IManaNetwork { @@ -34,8 +33,9 @@ public interface IManaNetwork { * A way of getting the dimension is via world.provider.dimensionId
* Note that this function *can* get performance intensive, it's reccomended you * call it sparingly and take cache of the value returned. + * * @param limit The maximum distance the closest block can be, if the closest block - * is farther away than that, null will be returned instead. + * is farther away than that, null will be returned instead. */ public TileEntity getClosestCollector(BlockPos pos, World world, int limit); @@ -45,8 +45,9 @@ public interface IManaNetwork { * A way of getting the dimension is via world.provider.dimensionId
* Note that this function *can* get performance intensive, it's reccomended you * call it sparingly and take cache of the value returned. + * * @param limit The maximum distance the closest block can be, if the closest block - * is farther away than that, null will be returned instead. + * is farther away than that, null will be returned instead. */ public TileEntity getClosestPool(BlockPos pos, World world, int limit); diff --git a/src/main/java/vazkii/botania/api/internal/ShaderCallback.java b/src/main/java/vazkii/botania/api/internal/ShaderCallback.java index f158f662b..9be876ad8 100644 --- a/src/main/java/vazkii/botania/api/internal/ShaderCallback.java +++ b/src/main/java/vazkii/botania/api/internal/ShaderCallback.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Oct 29, 2014, 6:31:35 PM (GMT)] */ package vazkii.botania.api.internal; diff --git a/src/main/java/vazkii/botania/api/internal/VanillaPacketDispatcher.java b/src/main/java/vazkii/botania/api/internal/VanillaPacketDispatcher.java index 78ab98ab2..31fcb0543 100644 --- a/src/main/java/vazkii/botania/api/internal/VanillaPacketDispatcher.java +++ b/src/main/java/vazkii/botania/api/internal/VanillaPacketDispatcher.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 9, 2015, 9:38:44 PM (GMT)] */ package vazkii.botania.api.internal; @@ -24,8 +22,8 @@ public final class VanillaPacketDispatcher { SUpdateTileEntityPacket packet = tile.getUpdatePacket(); BlockPos pos = tile.getPos(); - if(packet != null && tile.getWorld() instanceof ServerWorld) { - ((ServerChunkProvider)tile.getWorld().getChunkProvider()).chunkManager + if (packet != null && tile.getWorld() instanceof ServerWorld) { + ((ServerChunkProvider) tile.getWorld().getChunkProvider()).chunkManager .getTrackingPlayers(new ChunkPos(pos), false) .forEach(e -> e.connection.sendPacket(packet)); } @@ -33,8 +31,9 @@ public final class VanillaPacketDispatcher { public static void dispatchTEToNearbyPlayers(World world, BlockPos pos) { TileEntity tile = world.getTileEntity(pos); - if(tile != null) + if (tile != null) { dispatchTEToNearbyPlayers(tile); + } } } diff --git a/src/main/java/vazkii/botania/api/item/AccessoryRenderHelper.java b/src/main/java/vazkii/botania/api/item/AccessoryRenderHelper.java index 43816f7aa..1ac6a8762 100644 --- a/src/main/java/vazkii/botania/api/item/AccessoryRenderHelper.java +++ b/src/main/java/vazkii/botania/api/item/AccessoryRenderHelper.java @@ -1,6 +1,15 @@ +/* + * This class is 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 + */ package vazkii.botania.api.item; import com.mojang.blaze3d.matrix.MatrixStack; + import net.minecraft.client.renderer.Vector3f; import net.minecraft.entity.LivingEntity; @@ -9,66 +18,67 @@ import net.minecraft.entity.LivingEntity; */ public final class AccessoryRenderHelper { - /** - * Rotates the render for a bauble correctly if the player is sneaking. - */ - public static void rotateIfSneaking(MatrixStack ms, LivingEntity player) { - if(player.isCrouching()) - applySneakingRotation(ms); - } + /** + * Rotates the render for a bauble correctly if the player is sneaking. + */ + public static void rotateIfSneaking(MatrixStack ms, LivingEntity player) { + if (player.isCrouching()) { + applySneakingRotation(ms); + } + } - /** - * Rotates the render for a bauble correctly for a sneaking player. - */ - public static void applySneakingRotation(MatrixStack ms) { - ms.translate(0F, 0.2F, 0F); - ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(90F / (float) Math.PI)); - } + /** + * Rotates the render for a bauble correctly for a sneaking player. + */ + public static void applySneakingRotation(MatrixStack ms) { + ms.translate(0F, 0.2F, 0F); + ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(90F / (float) Math.PI)); + } - /** - * Shifts the render for a bauble correctly to the head, including sneaking rotation. - */ - public static void translateToHeadLevel(MatrixStack ms, LivingEntity player, float partialTicks) { + /** + * Shifts the render for a bauble correctly to the head, including sneaking rotation. + */ + public static void translateToHeadLevel(MatrixStack ms, LivingEntity player, float partialTicks) { - float yaw = player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * partialTicks; - float yawOffset = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialTicks; - float pitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * partialTicks; + float yaw = player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * partialTicks; + float yawOffset = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialTicks; + float pitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * partialTicks; - ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-yawOffset)); - ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(yaw - 270)); - ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(pitch)); + ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-yawOffset)); + ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(yaw - 270)); + ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(pitch)); - ms.translate(0, -player.getEyeHeight(), 0); + ms.translate(0, -player.getEyeHeight(), 0); // if (player.shouldRenderSneaking()) TODO Sneaking needs a different adjustment now // GlStateManager.translatef(0.25F * MathHelper.sin(player.rotationPitch * (float) Math.PI / 180), 0.25F * MathHelper.cos(player.rotationPitch * (float) Math.PI / 180), 0F); - } + } - /** - * Shifts the render for a bauble correctly to the face. - * Use for renders after calling {@link AccessoryRenderHelper#translateToHeadLevel}. - */ - public static void translateToFace(MatrixStack ms) { - ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(90)); - ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(180)); - ms.translate(0f, -4.35f, -1.27f); - } + /** + * Shifts the render for a bauble correctly to the face. + * Use for renders after calling {@link AccessoryRenderHelper#translateToHeadLevel}. + */ + public static void translateToFace(MatrixStack ms) { + ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(90)); + ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(180)); + ms.translate(0f, -4.35f, -1.27f); + } - /** - * Scales down the render to a correct size. - * Use for any render. - */ - public static void defaultTransforms(MatrixStack ms) { - ms.translate(0.0, 3.0, 1.0); - ms.scale(0.55F, 0.55F, 0.55F); - } + /** + * Scales down the render to a correct size. + * Use for any render. + */ + public static void defaultTransforms(MatrixStack ms) { + ms.translate(0.0, 3.0, 1.0); + ms.scale(0.55F, 0.55F, 0.55F); + } - /** - * Shifts the render for a bauble correctly to the chest. - * Use for renders after calling {@link AccessoryRenderHelper#rotateIfSneaking}. - */ - public static void translateToChest(MatrixStack ms) { - ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(180)); - ms.translate(0F, -3.2F, -0.85F); - } + /** + * Shifts the render for a bauble correctly to the chest. + * Use for renders after calling {@link AccessoryRenderHelper#rotateIfSneaking}. + */ + public static void translateToChest(MatrixStack ms) { + ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(180)); + ms.translate(0F, -3.2F, -0.85F); + } } diff --git a/src/main/java/vazkii/botania/api/item/IAncientWillContainer.java b/src/main/java/vazkii/botania/api/item/IAncientWillContainer.java index fbe7f5511..527ee4eb4 100644 --- a/src/main/java/vazkii/botania/api/item/IAncientWillContainer.java +++ b/src/main/java/vazkii/botania/api/item/IAncientWillContainer.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 30, 2015, 11:24:54 PM (GMT)] */ package vazkii.botania.api.item; diff --git a/src/main/java/vazkii/botania/api/item/IAvatarTile.java b/src/main/java/vazkii/botania/api/item/IAvatarTile.java index ee88ef823..0749328b8 100644 --- a/src/main/java/vazkii/botania/api/item/IAvatarTile.java +++ b/src/main/java/vazkii/botania/api/item/IAvatarTile.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Oct 24, 2015, 7:00:21 PM (GMT)] */ package vazkii.botania.api.item; import net.minecraft.util.Direction; import net.minecraftforge.items.IItemHandler; + import vazkii.botania.api.mana.IManaReceiver; /** @@ -21,6 +20,7 @@ public interface IAvatarTile extends IManaReceiver { /** * Gets the avatar's inventory + * * @return An IItemhandler representing the avatar's inventory */ public IItemHandler getInventory(); @@ -41,5 +41,4 @@ public interface IAvatarTile extends IManaReceiver { */ public boolean isEnabled(); - } diff --git a/src/main/java/vazkii/botania/api/item/IAvatarWieldable.java b/src/main/java/vazkii/botania/api/item/IAvatarWieldable.java index fbcf817f2..a5d8463bc 100644 --- a/src/main/java/vazkii/botania/api/item/IAvatarWieldable.java +++ b/src/main/java/vazkii/botania/api/item/IAvatarWieldable.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Oct 24, 2015, 6:45:50 PM (GMT)] */ package vazkii.botania.api.item; diff --git a/src/main/java/vazkii/botania/api/item/IBlockProvider.java b/src/main/java/vazkii/botania/api/item/IBlockProvider.java index 4a8f38044..599309203 100644 --- a/src/main/java/vazkii/botania/api/item/IBlockProvider.java +++ b/src/main/java/vazkii/botania/api/item/IBlockProvider.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 20, 2015, 10:31:54 PM (GMT)] */ package vazkii.botania.api.item; diff --git a/src/main/java/vazkii/botania/api/item/IBurstViewerBauble.java b/src/main/java/vazkii/botania/api/item/IBurstViewerBauble.java index 1dfec9889..a29e46e30 100644 --- a/src/main/java/vazkii/botania/api/item/IBurstViewerBauble.java +++ b/src/main/java/vazkii/botania/api/item/IBurstViewerBauble.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 24, 2015, 3:08:40 PM (GMT)] */ package vazkii.botania.api.item; diff --git a/src/main/java/vazkii/botania/api/item/ICosmeticAttachable.java b/src/main/java/vazkii/botania/api/item/ICosmeticAttachable.java index c5b5d772a..c33c3df11 100644 --- a/src/main/java/vazkii/botania/api/item/ICosmeticAttachable.java +++ b/src/main/java/vazkii/botania/api/item/ICosmeticAttachable.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 22, 2015, 8:31:39 PM (GMT)] */ package vazkii.botania.api.item; diff --git a/src/main/java/vazkii/botania/api/item/ICosmeticBauble.java b/src/main/java/vazkii/botania/api/item/ICosmeticBauble.java index 9a78db223..ead79925b 100644 --- a/src/main/java/vazkii/botania/api/item/ICosmeticBauble.java +++ b/src/main/java/vazkii/botania/api/item/ICosmeticBauble.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 22, 2015, 2:02:02 PM (GMT)] */ package vazkii.botania.api.item; diff --git a/src/main/java/vazkii/botania/api/item/IExoflameHeatable.java b/src/main/java/vazkii/botania/api/item/IExoflameHeatable.java index 04d9847f5..ba73d4d11 100644 --- a/src/main/java/vazkii/botania/api/item/IExoflameHeatable.java +++ b/src/main/java/vazkii/botania/api/item/IExoflameHeatable.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 30, 2014, 4:28:29 PM (GMT)] */ package vazkii.botania.api.item; diff --git a/src/main/java/vazkii/botania/api/item/IFloatingFlower.java b/src/main/java/vazkii/botania/api/item/IFloatingFlower.java index b044ede13..93d44fdbe 100644 --- a/src/main/java/vazkii/botania/api/item/IFloatingFlower.java +++ b/src/main/java/vazkii/botania/api/item/IFloatingFlower.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 17, 2014, 6:05:18 PM (GMT)] */ package vazkii.botania.api.item; @@ -17,6 +15,7 @@ import net.minecraft.util.Direction; import net.minecraftforge.common.capabilities.Capability; import javax.annotation.Nullable; + import java.util.HashMap; import java.util.Map; @@ -45,9 +44,9 @@ public interface IFloatingFlower { @Override public void readNBT(Capability capability, IFloatingFlower instance, Direction side, INBT nbt) { - if(nbt instanceof CompoundNBT) { + if (nbt instanceof CompoundNBT) { IslandType t = IslandType.ofType(((CompoundNBT) nbt).getString("islandType")); - if(t != null) { + if (t != null) { instance.setIslandType(t); } } @@ -73,12 +72,15 @@ public interface IFloatingFlower { /** * Instantiates and registers a new floating flower island type * Note that you need to register the model for this island type, see BotaniaAPIClient + * * @param name The name of this floating flower island type */ public IslandType(String name) { typeName = name; synchronized (registry) { - if (registry.containsKey(name)) throw new IllegalArgumentException(name+" already registered!"); + if (registry.containsKey(name)) { + throw new IllegalArgumentException(name + " already registered!"); + } registry.put(name, this); } } diff --git a/src/main/java/vazkii/botania/api/item/IFlowerPlaceable.java b/src/main/java/vazkii/botania/api/item/IFlowerPlaceable.java index d1d037aee..092c77a8d 100644 --- a/src/main/java/vazkii/botania/api/item/IFlowerPlaceable.java +++ b/src/main/java/vazkii/botania/api/item/IFlowerPlaceable.java @@ -1,15 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [17/11/2015, 20:10:53 (GMT)] */ package vazkii.botania.api.item; + import net.minecraft.item.BlockItemUseContext; + import vazkii.botania.api.subtile.TileEntitySpecialFlower; /** @@ -18,8 +18,8 @@ import vazkii.botania.api.subtile.TileEntitySpecialFlower; public interface IFlowerPlaceable { /** - * @param ctx The placement context, aiming downwards towards the downward neighbor position - * @return Whether the block was placed successfully + * @param ctx The placement context, aiming downwards towards the downward neighbor position + * @return Whether the block was placed successfully */ boolean tryPlace(TileEntitySpecialFlower flower, BlockItemUseContext ctx); } diff --git a/src/main/java/vazkii/botania/api/item/IFlowerlessBiome.java b/src/main/java/vazkii/botania/api/item/IFlowerlessBiome.java index a822fe5b0..402249506 100644 --- a/src/main/java/vazkii/botania/api/item/IFlowerlessBiome.java +++ b/src/main/java/vazkii/botania/api/item/IFlowerlessBiome.java @@ -1,14 +1,13 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [? (GMT)] */ package vazkii.botania.api.item; + import net.minecraft.world.IWorld; /** @@ -19,4 +18,4 @@ public interface IFlowerlessBiome { * @return Should this world be allowed to generate flowers? */ public boolean canGenerateFlowers(IWorld world, int x, int z); -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/api/item/IFlowerlessWorld.java b/src/main/java/vazkii/botania/api/item/IFlowerlessWorld.java index cb34a92ce..61fe2920d 100644 --- a/src/main/java/vazkii/botania/api/item/IFlowerlessWorld.java +++ b/src/main/java/vazkii/botania/api/item/IFlowerlessWorld.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [? (GMT)] */ package vazkii.botania.api.item; diff --git a/src/main/java/vazkii/botania/api/item/IHornHarvestable.java b/src/main/java/vazkii/botania/api/item/IHornHarvestable.java index 609864392..841c21d46 100644 --- a/src/main/java/vazkii/botania/api/item/IHornHarvestable.java +++ b/src/main/java/vazkii/botania/api/item/IHornHarvestable.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Oct 24, 2015, 11:16:00 PM (GMT)] */ package vazkii.botania.api.item; diff --git a/src/main/java/vazkii/botania/api/item/IHourglassTrigger.java b/src/main/java/vazkii/botania/api/item/IHourglassTrigger.java index a759a9e17..4c9743b1b 100644 --- a/src/main/java/vazkii/botania/api/item/IHourglassTrigger.java +++ b/src/main/java/vazkii/botania/api/item/IHourglassTrigger.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [28/09/2016, 20:01:14 (GMT)] */ package vazkii.botania.api.item; diff --git a/src/main/java/vazkii/botania/api/item/IManaDissolvable.java b/src/main/java/vazkii/botania/api/item/IManaDissolvable.java index 5d46bed0d..754cf5e5e 100644 --- a/src/main/java/vazkii/botania/api/item/IManaDissolvable.java +++ b/src/main/java/vazkii/botania/api/item/IManaDissolvable.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 18, 2015, 12:10:00 AM (GMT)] */ package vazkii.botania.api.item; import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.ItemStack; + import vazkii.botania.api.mana.IManaPool; /** diff --git a/src/main/java/vazkii/botania/api/item/IManaProficiencyArmor.java b/src/main/java/vazkii/botania/api/item/IManaProficiencyArmor.java index e9a0c99ea..4cd673aa3 100644 --- a/src/main/java/vazkii/botania/api/item/IManaProficiencyArmor.java +++ b/src/main/java/vazkii/botania/api/item/IManaProficiencyArmor.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 28, 2015, 9:04:53 PM (GMT)] */ package vazkii.botania.api.item; @@ -15,6 +13,7 @@ import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; + import vazkii.botania.api.mana.ManaProficiencyEvent; /** @@ -33,13 +32,14 @@ public interface IManaProficiencyArmor { static boolean hasProficiency(PlayerEntity player, ItemStack rod) { boolean proficient = false; - for(EquipmentSlotType e: EquipmentSlotType.values()) { - if(e.getSlotType() != EquipmentSlotType.Group.ARMOR) + for (EquipmentSlotType e : EquipmentSlotType.values()) { + if (e.getSlotType() != EquipmentSlotType.Group.ARMOR) { continue; + } ItemStack armor = player.getItemStackFromSlot(e); - if(!armor.isEmpty()) { + if (!armor.isEmpty()) { Item item = armor.getItem(); - if(item instanceof IManaProficiencyArmor && ((IManaProficiencyArmor) item).shouldGiveProficiency(armor, e, player, rod)) { + if (item instanceof IManaProficiencyArmor && ((IManaProficiencyArmor) item).shouldGiveProficiency(armor, e, player, rod)) { proficient = true; break; } diff --git a/src/main/java/vazkii/botania/api/item/IPetalApothecary.java b/src/main/java/vazkii/botania/api/item/IPetalApothecary.java index 861420860..021d4ad29 100644 --- a/src/main/java/vazkii/botania/api/item/IPetalApothecary.java +++ b/src/main/java/vazkii/botania/api/item/IPetalApothecary.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 30, 2014, 4:22:15 PM (GMT)] */ package vazkii.botania.api.item; diff --git a/src/main/java/vazkii/botania/api/item/IPhantomInkable.java b/src/main/java/vazkii/botania/api/item/IPhantomInkable.java index 36d727309..6d9fd494d 100644 --- a/src/main/java/vazkii/botania/api/item/IPhantomInkable.java +++ b/src/main/java/vazkii/botania/api/item/IPhantomInkable.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 17, 2015, 4:57:44 PM (GMT)] */ package vazkii.botania.api.item; diff --git a/src/main/java/vazkii/botania/api/item/IRelic.java b/src/main/java/vazkii/botania/api/item/IRelic.java index 2bd0fff60..09c534356 100644 --- a/src/main/java/vazkii/botania/api/item/IRelic.java +++ b/src/main/java/vazkii/botania/api/item/IRelic.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 29, 2015, 7:17:41 PM (GMT)] */ package vazkii.botania.api.item; @@ -14,6 +12,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import javax.annotation.Nullable; + import java.util.UUID; /** diff --git a/src/main/java/vazkii/botania/api/item/ISequentialBreaker.java b/src/main/java/vazkii/botania/api/item/ISequentialBreaker.java index 76e2c0641..9ea18f1c2 100644 --- a/src/main/java/vazkii/botania/api/item/ISequentialBreaker.java +++ b/src/main/java/vazkii/botania/api/item/ISequentialBreaker.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 30, 2015, 2:46:05 PM (GMT)] */ package vazkii.botania.api.item; diff --git a/src/main/java/vazkii/botania/api/item/ISortableTool.java b/src/main/java/vazkii/botania/api/item/ISortableTool.java index 231686940..0826da25f 100644 --- a/src/main/java/vazkii/botania/api/item/ISortableTool.java +++ b/src/main/java/vazkii/botania/api/item/ISortableTool.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 23, 2015, 7:03:48 PM (GMT)] */ package vazkii.botania.api.item; @@ -22,17 +20,19 @@ public interface ISortableTool { * Gets the priority that this tool should have when being sorted. The * tool with the highest priority will be picked. The way this is specified * should be (tool-level) * 100 + (tool-modifier) * 10 + (efficiency-level). - *

+ *
+ *
* For example, a Manasteel Pickaxe is tool-level 10 and it doesn't have * modifiers. Assuming Efficiency 4, the priority should be 10 * 100 + 4 = 1004. * This will rate higher than a similar pickaxe with Efficiency 3.
* A Terra Shatterer has a modifier, its rank and is tool-level 20. With Efficiency * 5 and rank B (2) the priority should be 20 * 100 + 2 * 10 + 5 = 2025. - *

+ *
+ *
* All intermediate tool levels are there for other mod tools that wish to occupy the spots inbetween. * Of course, you don't have to always adhere to this. Tools like the Vitreous Pickaxe don't, * that one in particular is priority 0 so it's never picked. */ public int getSortingPriority(ItemStack stack); -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/api/item/IWireframeCoordinateListProvider.java b/src/main/java/vazkii/botania/api/item/IWireframeCoordinateListProvider.java index 7a8194b63..cdedb4521 100644 --- a/src/main/java/vazkii/botania/api/item/IWireframeCoordinateListProvider.java +++ b/src/main/java/vazkii/botania/api/item/IWireframeCoordinateListProvider.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 29, 2015, 11:30:41 PM (GMT)] */ package vazkii.botania.api.item; @@ -15,6 +13,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import javax.annotation.Nullable; + import java.util.List; /** @@ -33,6 +32,7 @@ public interface IWireframeCoordinateListProvider { /** * Gets a wireframe to draw thicker than the rest. * This is useful to indicate the precedence of some position over the others. + * * @return The position of a single wireframe to draw thicker than all the others. */ @Nullable @@ -40,5 +40,4 @@ public interface IWireframeCoordinateListProvider { return null; } - } diff --git a/src/main/java/vazkii/botania/api/item/TinyPotatoRenderEvent.java b/src/main/java/vazkii/botania/api/item/TinyPotatoRenderEvent.java index ab068462c..8312db09c 100644 --- a/src/main/java/vazkii/botania/api/item/TinyPotatoRenderEvent.java +++ b/src/main/java/vazkii/botania/api/item/TinyPotatoRenderEvent.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 25, 2015, 8:02:41 PM (GMT)] */ package vazkii.botania.api.item; import com.mojang.blaze3d.matrix.MatrixStack; + import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.text.ITextComponent; @@ -38,4 +37,4 @@ public class TinyPotatoRenderEvent extends Event { this.light = light; this.overlay = overlay; } -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/api/mana/BurstProperties.java b/src/main/java/vazkii/botania/api/mana/BurstProperties.java index 384fc962c..a8372fcfa 100644 --- a/src/main/java/vazkii/botania/api/mana/BurstProperties.java +++ b/src/main/java/vazkii/botania/api/mana/BurstProperties.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 31, 2014, 3:49:30 PM (GMT)] */ package vazkii.botania.api.mana; diff --git a/src/main/java/vazkii/botania/api/mana/IClientManaHandler.java b/src/main/java/vazkii/botania/api/mana/IClientManaHandler.java index 0b652ff1e..d1623c641 100644 --- a/src/main/java/vazkii/botania/api/mana/IClientManaHandler.java +++ b/src/main/java/vazkii/botania/api/mana/IClientManaHandler.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 2, 2014, 5:26:02 PM (GMT)] */ package vazkii.botania.api.mana; diff --git a/src/main/java/vazkii/botania/api/mana/ICompositableLens.java b/src/main/java/vazkii/botania/api/mana/ICompositableLens.java index 29d17c098..31e13180f 100644 --- a/src/main/java/vazkii/botania/api/mana/ICompositableLens.java +++ b/src/main/java/vazkii/botania/api/mana/ICompositableLens.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 23, 2015, 10:30:34 AM (GMT)] */ package vazkii.botania.api.mana; @@ -28,5 +26,3 @@ public interface ICompositableLens extends ILens { public boolean isCombinable(ItemStack stack); } - - diff --git a/src/main/java/vazkii/botania/api/mana/ICreativeManaProvider.java b/src/main/java/vazkii/botania/api/mana/ICreativeManaProvider.java index 3d152133f..530fb0215 100644 --- a/src/main/java/vazkii/botania/api/mana/ICreativeManaProvider.java +++ b/src/main/java/vazkii/botania/api/mana/ICreativeManaProvider.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 25, 2014, 7:34:00 PM (GMT)] */ package vazkii.botania.api.mana; @@ -22,4 +20,3 @@ public interface ICreativeManaProvider { public boolean isCreative(ItemStack stack); } - diff --git a/src/main/java/vazkii/botania/api/mana/IDirectioned.java b/src/main/java/vazkii/botania/api/mana/IDirectioned.java index 04568f4a0..d9a18070d 100644 --- a/src/main/java/vazkii/botania/api/mana/IDirectioned.java +++ b/src/main/java/vazkii/botania/api/mana/IDirectioned.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [15/11/2015, 19:27:07 (GMT)] */ package vazkii.botania.api.mana; @@ -29,12 +27,14 @@ public interface IDirectioned { /** * Set the X rotation + * * @param rot X rotation, in degrees */ public void setRotationX(float rot); /** * Set the Y rotation + * * @param rot Y rotation, in degrees */ public void setRotationY(float rot); diff --git a/src/main/java/vazkii/botania/api/mana/IKeyLocked.java b/src/main/java/vazkii/botania/api/mana/IKeyLocked.java index 6ed598db3..cb7b9bd70 100644 --- a/src/main/java/vazkii/botania/api/mana/IKeyLocked.java +++ b/src/main/java/vazkii/botania/api/mana/IKeyLocked.java @@ -1,22 +1,20 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 11, 2014, 4:29:32 PM (GMT)] */ package vazkii.botania.api.mana; /** * A TileEntity that implements this interface has an IO key lock. This - * interface defines an input and output key.

- * + * interface defines an input and output key.
+ *
* A Spreader can only shoot mana into a IKeyLocked interfaced TE if the Input - * key of the TE is equal to the Output key of the Spreader.

- * + * key of the TE is equal to the Output key of the Spreader.
+ *
* A Spreader can only pull mana from a IKeyLocked interfaced IManaPool TE if the * Output key of the IManaPool is equal to the Input key of the Spreader. */ diff --git a/src/main/java/vazkii/botania/api/mana/ILaputaImmobile.java b/src/main/java/vazkii/botania/api/mana/ILaputaImmobile.java index 1b91011e0..1ffd560a6 100644 --- a/src/main/java/vazkii/botania/api/mana/ILaputaImmobile.java +++ b/src/main/java/vazkii/botania/api/mana/ILaputaImmobile.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 26, 2014, 9:51:58 PM (GMT)] */ package vazkii.botania.api.mana; diff --git a/src/main/java/vazkii/botania/api/mana/ILens.java b/src/main/java/vazkii/botania/api/mana/ILens.java index 13c2577ad..ac7c2261a 100644 --- a/src/main/java/vazkii/botania/api/mana/ILens.java +++ b/src/main/java/vazkii/botania/api/mana/ILens.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 31, 2014, 3:03:04 PM (GMT)] */ package vazkii.botania.api.mana; diff --git a/src/main/java/vazkii/botania/api/mana/ILensControl.java b/src/main/java/vazkii/botania/api/mana/ILensControl.java index 55669327b..2e05f1963 100644 --- a/src/main/java/vazkii/botania/api/mana/ILensControl.java +++ b/src/main/java/vazkii/botania/api/mana/ILensControl.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [15/11/2015, 21:00:32 (GMT)] */ package vazkii.botania.api.mana; diff --git a/src/main/java/vazkii/botania/api/mana/ILensEffect.java b/src/main/java/vazkii/botania/api/mana/ILensEffect.java index 798302725..1ca43e994 100644 --- a/src/main/java/vazkii/botania/api/mana/ILensEffect.java +++ b/src/main/java/vazkii/botania/api/mana/ILensEffect.java @@ -1,18 +1,17 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 14, 2014, 7:30:00 PM (GMT)] */ package vazkii.botania.api.mana; import net.minecraft.entity.projectile.ThrowableEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.math.RayTraceResult; + import vazkii.botania.api.internal.IManaBurst; /** @@ -30,6 +29,7 @@ public interface ILensEffect { /** * Called when a mana burst fired from a mana spreader with this focus collides against * any block. This is called after the collision is handled. + * * @return True to kill the burst. False to keep it alive. */ public boolean collideBurst(IManaBurst burst, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack); @@ -52,5 +52,5 @@ public interface ILensEffect { public default int getManaToTransfer(IManaBurst burst, ThrowableEntity entity, ItemStack stack, IManaReceiver receiver) { return burst.getMana(); } - + } diff --git a/src/main/java/vazkii/botania/api/mana/IManaBlock.java b/src/main/java/vazkii/botania/api/mana/IManaBlock.java index 63d098ef2..6e95905ee 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaBlock.java +++ b/src/main/java/vazkii/botania/api/mana/IManaBlock.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 22, 2014, 4:59:05 PM (GMT)] */ package vazkii.botania.api.mana; diff --git a/src/main/java/vazkii/botania/api/mana/IManaCollector.java b/src/main/java/vazkii/botania/api/mana/IManaCollector.java index 6fca30a60..a39939eff 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaCollector.java +++ b/src/main/java/vazkii/botania/api/mana/IManaCollector.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 22, 2014, 5:01:19 PM (GMT)] */ package vazkii.botania.api.mana; @@ -14,11 +12,12 @@ import vazkii.botania.api.internal.IManaBurst; /** * Any TileEntity that implements this is considered a mana collector, by - * which nearby generating flowers will pump mana into it.

- * + * which nearby generating flowers will pump mana into it.
+ *
* Implementation Instructions:
* - Override invalidate() and onChunkUnload(), calling ManaNetworkEvent.removeCollector(this); on both.
- * - On the first tick of update() (or onLoad() in Forge build 1606 or higher), call ManaNetworkEvent.addCollector(this); + * - On the first tick of update() (or onLoad() in Forge build 1606 or higher), call + * ManaNetworkEvent.addCollector(this); */ public interface IManaCollector extends IManaReceiver { diff --git a/src/main/java/vazkii/botania/api/mana/IManaCollisionGhost.java b/src/main/java/vazkii/botania/api/mana/IManaCollisionGhost.java index 9f7ef03ab..748266dd1 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaCollisionGhost.java +++ b/src/main/java/vazkii/botania/api/mana/IManaCollisionGhost.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 10, 2014, 7:49:19 PM (GMT)] */ package vazkii.botania.api.mana; diff --git a/src/main/java/vazkii/botania/api/mana/IManaDiscountArmor.java b/src/main/java/vazkii/botania/api/mana/IManaDiscountArmor.java index 8172f9d3d..35bae4ac6 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaDiscountArmor.java +++ b/src/main/java/vazkii/botania/api/mana/IManaDiscountArmor.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 28, 2015, 9:22:53 PM (GMT)] */ package vazkii.botania.api.mana; diff --git a/src/main/java/vazkii/botania/api/mana/IManaGivingItem.java b/src/main/java/vazkii/botania/api/mana/IManaGivingItem.java index 57f506dfc..e6fc332de 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaGivingItem.java +++ b/src/main/java/vazkii/botania/api/mana/IManaGivingItem.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [08/12/2015, 18:10:29 (GMT)] */ package vazkii.botania.api.mana; diff --git a/src/main/java/vazkii/botania/api/mana/IManaItem.java b/src/main/java/vazkii/botania/api/mana/IManaItem.java index 9dfcf5525..ad7c51c74 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaItem.java +++ b/src/main/java/vazkii/botania/api/mana/IManaItem.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 6, 2014, 9:07:40 AM (GMT)] */ package vazkii.botania.api.mana; @@ -36,8 +34,9 @@ public interface IManaItem { /** * Can this item receive mana from a mana Pool? + * * @param pool The pool it's receiving mana from, can be casted to IManaPool. - * @see IManaPool#isOutputtingPower() + * @see IManaPool#isOutputtingPower() */ public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool); @@ -48,10 +47,11 @@ public interface IManaItem { /** * Can this item export mana to a mana Pool? + * * @param pool The pool it's exporting mana to, can be casted to IManaPool. - * @see IManaPool#isOutputtingPower() + * @see IManaPool#isOutputtingPower() */ - public boolean canExportManaToPool(ItemStack stack,TileEntity pool); + public boolean canExportManaToPool(ItemStack stack, TileEntity pool); /** * Can this item export mana to another item? diff --git a/src/main/java/vazkii/botania/api/mana/IManaPool.java b/src/main/java/vazkii/botania/api/mana/IManaPool.java index 8ac989317..7af763bf0 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaPool.java +++ b/src/main/java/vazkii/botania/api/mana/IManaPool.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 22, 2014, 5:03:09 PM (GMT)] */ package vazkii.botania.api.mana; @@ -15,8 +13,8 @@ import net.minecraft.item.DyeColor; /** * Any TileEntity that implements this is considered a Mana Pool, * by which nearby functional flowers will pull mana from it.
- * Mana Distributors will also accept it as valid output.

- * + * Mana Distributors will also accept it as valid output.
+ *
* Implementation Instructions:
* - Override invalidate() and onChunkUnload(), calling ManaNetworkEvent.removePool(this); on both.
* - On the first tick of onUpdate(), call ManaNetworkEvent.addPool(this); @@ -36,6 +34,7 @@ public interface IManaPool extends IManaReceiver { /** * Sets the color of this pool. + * * @param color The color to set. */ public void setColor(DyeColor color); diff --git a/src/main/java/vazkii/botania/api/mana/IManaReceiver.java b/src/main/java/vazkii/botania/api/mana/IManaReceiver.java index 441a8e5b5..155259590 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaReceiver.java +++ b/src/main/java/vazkii/botania/api/mana/IManaReceiver.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 22, 2014, 4:55:00 PM (GMT)] */ package vazkii.botania.api.mana; diff --git a/src/main/java/vazkii/botania/api/mana/IManaSpreader.java b/src/main/java/vazkii/botania/api/mana/IManaSpreader.java index b35c337b8..15d9d1813 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaSpreader.java +++ b/src/main/java/vazkii/botania/api/mana/IManaSpreader.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 18, 2015, 7:30:00 PM (GMT)] */ package vazkii.botania.api.mana; diff --git a/src/main/java/vazkii/botania/api/mana/IManaTooltipDisplay.java b/src/main/java/vazkii/botania/api/mana/IManaTooltipDisplay.java index b62093a98..6795414e8 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaTooltipDisplay.java +++ b/src/main/java/vazkii/botania/api/mana/IManaTooltipDisplay.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Oct 23, 2015, 3:54:03 PM (GMT)] */ package vazkii.botania.api.mana; diff --git a/src/main/java/vazkii/botania/api/mana/IManaTrigger.java b/src/main/java/vazkii/botania/api/mana/IManaTrigger.java index 477c0cef0..a45dcc7f1 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaTrigger.java +++ b/src/main/java/vazkii/botania/api/mana/IManaTrigger.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 16, 2014, 7:52:53 PM (GMT)] */ package vazkii.botania.api.mana; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import vazkii.botania.api.internal.IManaBurst; /** diff --git a/src/main/java/vazkii/botania/api/mana/IManaUsingItem.java b/src/main/java/vazkii/botania/api/mana/IManaUsingItem.java index 0356f8307..b9f66e2e9 100644 --- a/src/main/java/vazkii/botania/api/mana/IManaUsingItem.java +++ b/src/main/java/vazkii/botania/api/mana/IManaUsingItem.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 25, 2014, 7:32:10 PM (GMT)] */ package vazkii.botania.api.mana; diff --git a/src/main/java/vazkii/botania/api/mana/IPingable.java b/src/main/java/vazkii/botania/api/mana/IPingable.java index b40b9cfa5..743cdee23 100644 --- a/src/main/java/vazkii/botania/api/mana/IPingable.java +++ b/src/main/java/vazkii/botania/api/mana/IPingable.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 19, 2015, 9:52:05 PM (GMT)] */ package vazkii.botania.api.mana; diff --git a/src/main/java/vazkii/botania/api/mana/IPoolOverlayProvider.java b/src/main/java/vazkii/botania/api/mana/IPoolOverlayProvider.java index 72c7f9591..8c344f6be 100644 --- a/src/main/java/vazkii/botania/api/mana/IPoolOverlayProvider.java +++ b/src/main/java/vazkii/botania/api/mana/IPoolOverlayProvider.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 2, 2014, 6:36:54 PM (GMT)] */ package vazkii.botania.api.mana; diff --git a/src/main/java/vazkii/botania/api/mana/IThrottledPacket.java b/src/main/java/vazkii/botania/api/mana/IThrottledPacket.java index b909e3fa8..ffcb2e275 100644 --- a/src/main/java/vazkii/botania/api/mana/IThrottledPacket.java +++ b/src/main/java/vazkii/botania/api/mana/IThrottledPacket.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 12, 2015, 3:08:09 PM (GMT)] */ package vazkii.botania.api.mana; diff --git a/src/main/java/vazkii/botania/api/mana/ITinyPlanetExcempt.java b/src/main/java/vazkii/botania/api/mana/ITinyPlanetExcempt.java index ab591e4e7..af2270bd5 100644 --- a/src/main/java/vazkii/botania/api/mana/ITinyPlanetExcempt.java +++ b/src/main/java/vazkii/botania/api/mana/ITinyPlanetExcempt.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 22, 2014, 2:26:14 PM (GMT)] */ package vazkii.botania.api.mana; diff --git a/src/main/java/vazkii/botania/api/mana/ManaDiscountEvent.java b/src/main/java/vazkii/botania/api/mana/ManaDiscountEvent.java index 8f8b6d0e8..f3c610684 100644 --- a/src/main/java/vazkii/botania/api/mana/ManaDiscountEvent.java +++ b/src/main/java/vazkii/botania/api/mana/ManaDiscountEvent.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 25, 2016, 9:02:12 PM (GMT)] */ package vazkii.botania.api.mana; @@ -19,7 +17,7 @@ public class ManaDiscountEvent extends Event { private final PlayerEntity entityPlayer; private float discount; private ItemStack tool; - + public ManaDiscountEvent(PlayerEntity entityPlayer, float discount, ItemStack tool) { this.entityPlayer = entityPlayer; this.discount = discount; diff --git a/src/main/java/vazkii/botania/api/mana/ManaItemHandler.java b/src/main/java/vazkii/botania/api/mana/ManaItemHandler.java index ec58023b7..00e1769d4 100644 --- a/src/main/java/vazkii/botania/api/mana/ManaItemHandler.java +++ b/src/main/java/vazkii/botania/api/mana/ManaItemHandler.java @@ -1,29 +1,26 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 13, 2014, 5:32:24 PM (GMT)] */ package vazkii.botania.api.mana; import com.google.common.collect.Iterables; + import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; + import vazkii.botania.api.BotaniaAPI; import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; import java.util.List; -import java.util.Map; -import java.util.Map.Entry; public final class ManaItemHandler { @@ -31,20 +28,22 @@ public final class ManaItemHandler { * Gets a list containing all mana-holding items in a player's inventory. * Also includes a call to ManaItemsEvent, so other mods can add items from * their player-associated inventories. + * * @return The list of items */ public static List getManaItems(PlayerEntity player) { - if (player == null) + if (player == null) { return Collections.emptyList(); + } List toReturn = new ArrayList<>(); player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent(mainInv -> { int size = mainInv.getSlots(); - for(int slot = 0; slot < size; slot++) { + for (int slot = 0; slot < size; slot++) { ItemStack stackInSlot = mainInv.getStackInSlot(slot); - if(!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof IManaItem) { + if (!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof IManaItem) { toReturn.add(stackInSlot); } } @@ -57,23 +56,25 @@ public final class ManaItemHandler { /** * Gets a list containing all mana-holding items in a player's accessories inventory. + * * @return The list of items */ public static List getManaAccesories(PlayerEntity player) { - if (player == null) + if (player == null) { return Collections.emptyList(); + } IItemHandler acc = BotaniaAPI.internalHandler.getAccessoriesInventory(player); - if (acc == null) + if (acc == null) { return Collections.emptyList(); - + } List toReturn = new ArrayList<>(acc.getSlots()); - for(int slot = 0; slot < acc.getSlots(); slot++) { + for (int slot = 0; slot < acc.getSlots(); slot++) { ItemStack stackInSlot = acc.getStackInSlot(slot); - if(!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof IManaItem) { + if (!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof IManaItem) { toReturn.add(stackInSlot); } } @@ -83,29 +84,35 @@ public final class ManaItemHandler { /** * Requests mana from items in a given player's inventory. - * @param manaToGet How much mana is to be requested, if less mana exists than this amount, - * the amount of mana existent will be returned instead, if you want exact values use requestManaExact. - * @param remove If true, the mana will be removed from the target item. Set to false to just check. - * @return The amount of mana received from the request. + * + * @param manaToGet How much mana is to be requested, if less mana exists than this amount, + * the amount of mana existent will be returned instead, if you want exact values use + * requestManaExact. + * @param remove If true, the mana will be removed from the target item. Set to false to just check. + * @return The amount of mana received from the request. */ public static int requestMana(ItemStack stack, PlayerEntity player, int manaToGet, boolean remove) { - if(stack.isEmpty()) + if (stack.isEmpty()) { return 0; + } List items = getManaItems(player); List acc = getManaAccesories(player); for (ItemStack stackInSlot : Iterables.concat(items, acc)) { - if(stackInSlot == stack) + if (stackInSlot == stack) { continue; + } IManaItem manaItem = (IManaItem) stackInSlot.getItem(); - if(manaItem.canExportManaToItem(stackInSlot, stack) && manaItem.getMana(stackInSlot) > 0) { - if(stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canReceiveManaFromItem(stack, stackInSlot)) + if (manaItem.canExportManaToItem(stackInSlot, stack) && manaItem.getMana(stackInSlot) > 0) { + if (stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canReceiveManaFromItem(stack, stackInSlot)) { continue; + } int mana = Math.min(manaToGet, manaItem.getMana(stackInSlot)); - if(remove) + if (remove) { manaItem.addMana(stackInSlot, -mana); + } return mana; } @@ -116,27 +123,32 @@ public final class ManaItemHandler { /** * Requests an exact amount of mana from items in a given player's inventory. - * @param manaToGet How much mana is to be requested, if less mana exists than this amount, - * false will be returned instead, and nothing will happen. - * @param remove If true, the mana will be removed from the target item. Set to false to just check. - * @return If the request was succesful. + * + * @param manaToGet How much mana is to be requested, if less mana exists than this amount, + * false will be returned instead, and nothing will happen. + * @param remove If true, the mana will be removed from the target item. Set to false to just check. + * @return If the request was succesful. */ public static boolean requestManaExact(ItemStack stack, PlayerEntity player, int manaToGet, boolean remove) { - if(stack.isEmpty()) + if (stack.isEmpty()) { return false; + } List items = getManaItems(player); List acc = getManaAccesories(player); for (ItemStack stackInSlot : Iterables.concat(items, acc)) { - if(stackInSlot == stack) + if (stackInSlot == stack) { continue; + } IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem(); - if(manaItemSlot.canExportManaToItem(stackInSlot, stack) && manaItemSlot.getMana(stackInSlot) > manaToGet) { - if(stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canReceiveManaFromItem(stack, stackInSlot)) + if (manaItemSlot.canExportManaToItem(stackInSlot, stack) && manaItemSlot.getMana(stackInSlot) > manaToGet) { + if (stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canReceiveManaFromItem(stack, stackInSlot)) { continue; + } - if(remove) + if (remove) { manaItemSlot.addMana(stackInSlot, -manaToGet); + } return true; } @@ -148,32 +160,38 @@ public final class ManaItemHandler { /** * Dispatches mana to items in a given player's inventory. Note that this method * does not automatically remove mana from the item which is exporting. - * @param manaToSend How much mana is to be sent. - * @param add If true, the mana will be added from the target item. Set to false to just check. - * @return The amount of mana actually sent. + * + * @param manaToSend How much mana is to be sent. + * @param add If true, the mana will be added from the target item. Set to false to just check. + * @return The amount of mana actually sent. */ public static int dispatchMana(ItemStack stack, PlayerEntity player, int manaToSend, boolean add) { - if(stack.isEmpty()) + if (stack.isEmpty()) { return 0; + } List items = getManaItems(player); List acc = getManaAccesories(player); for (ItemStack stackInSlot : Iterables.concat(items, acc)) { - if(stackInSlot == stack) + if (stackInSlot == stack) { continue; + } IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem(); - if(manaItemSlot.canReceiveManaFromItem(stackInSlot, stack)) { - if(stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canExportManaToItem(stack, stackInSlot)) + if (manaItemSlot.canReceiveManaFromItem(stackInSlot, stack)) { + if (stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canExportManaToItem(stack, stackInSlot)) { continue; + } int received; - if(manaItemSlot.getMana(stackInSlot) + manaToSend <= manaItemSlot.getMaxMana(stackInSlot)) + if (manaItemSlot.getMana(stackInSlot) + manaToSend <= manaItemSlot.getMaxMana(stackInSlot)) { received = manaToSend; - else received = manaToSend - (manaItemSlot.getMana(stackInSlot) + manaToSend - manaItemSlot.getMaxMana(stackInSlot)); + } else { + received = manaToSend - (manaItemSlot.getMana(stackInSlot) + manaToSend - manaItemSlot.getMaxMana(stackInSlot)); + } - - if(add) + if (add) { manaItemSlot.addMana(stackInSlot, manaToSend); + } return received; } @@ -185,26 +203,31 @@ public final class ManaItemHandler { /** * Dispatches an exact amount of mana to items in a given player's inventory. Note that this method * does not automatically remove mana from the item which is exporting. - * @param manaToSend How much mana is to be sent. - * @param add If true, the mana will be added from the target item. Set to false to just check. - * @return If an item received the mana sent. + * + * @param manaToSend How much mana is to be sent. + * @param add If true, the mana will be added from the target item. Set to false to just check. + * @return If an item received the mana sent. */ public static boolean dispatchManaExact(ItemStack stack, PlayerEntity player, int manaToSend, boolean add) { - if(stack.isEmpty()) + if (stack.isEmpty()) { return false; + } List items = getManaItems(player); List acc = getManaAccesories(player); for (ItemStack stackInSlot : Iterables.concat(items, acc)) { - if(stackInSlot == stack) + if (stackInSlot == stack) { continue; + } IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem(); - if(manaItemSlot.getMana(stackInSlot) + manaToSend <= manaItemSlot.getMaxMana(stackInSlot) && manaItemSlot.canReceiveManaFromItem(stackInSlot, stack)) { - if(stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canExportManaToItem(stack, stackInSlot)) + if (manaItemSlot.getMana(stackInSlot) + manaToSend <= manaItemSlot.getMaxMana(stackInSlot) && manaItemSlot.canReceiveManaFromItem(stackInSlot, stack)) { + if (stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canExportManaToItem(stack, stackInSlot)) { continue; + } - if(add) + if (add) { manaItemSlot.addMana(stackInSlot, manaToSend); + } return true; } @@ -216,10 +239,12 @@ public final class ManaItemHandler { /** * Requests mana from items in a given player's inventory. This version also * checks for IManaDiscountArmor items equipped to lower the cost. - * @param manaToGet How much mana is to be requested, if less mana exists than this amount, - * the amount of mana existent will be returned instead, if you want exact values use requestManaExact. - * @param remove If true, the mana will be removed from the target item. Set to false to just check. - * @return The amount of mana received from the request. + * + * @param manaToGet How much mana is to be requested, if less mana exists than this amount, + * the amount of mana existent will be returned instead, if you want exact values use + * requestManaExact. + * @param remove If true, the mana will be removed from the target item. Set to false to just check. + * @return The amount of mana received from the request. */ public static int requestManaForTool(ItemStack stack, PlayerEntity player, int manaToGet, boolean remove) { float multiplier = Math.max(0F, 1F - getFullDiscountForTools(player, stack)); @@ -230,27 +255,29 @@ public final class ManaItemHandler { /** * Requests an exact amount of mana from items in a given player's inventory. This version also * checks for IManaDiscountArmor items equipped to lower the cost. - * @param manaToGet How much mana is to be requested, if less mana exists than this amount, - * false will be returned instead, and nothing will happen. - * @param remove If true, the mana will be removed from the target item. Set to false to just check. - * @return If the request was succesful. + * + * @param manaToGet How much mana is to be requested, if less mana exists than this amount, + * false will be returned instead, and nothing will happen. + * @param remove If true, the mana will be removed from the target item. Set to false to just check. + * @return If the request was succesful. */ public static boolean requestManaExactForTool(ItemStack stack, PlayerEntity player, int manaToGet, boolean remove) { float multiplier = Math.max(0F, 1F - getFullDiscountForTools(player, stack)); int cost = (int) (manaToGet * multiplier); return requestManaExact(stack, player, cost, remove); } - + /** * Gets the sum of all the discounts on IManaDiscountArmor items equipped * on the player passed in. This discount can vary based on what the passed tool is. */ public static float getFullDiscountForTools(PlayerEntity player, ItemStack tool) { float discount = 0F; - for(int i = 0; i < player.inventory.armorInventory.size(); i++) { + for (int i = 0; i < player.inventory.armorInventory.size(); i++) { ItemStack armor = player.inventory.armorInventory.get(i); - if(!armor.isEmpty() && armor.getItem() instanceof IManaDiscountArmor) + if (!armor.isEmpty() && armor.getItem() instanceof IManaDiscountArmor) { discount += ((IManaDiscountArmor) armor.getItem()).getDiscount(armor, i, player, tool); + } } ManaDiscountEvent event = new ManaDiscountEvent(player, discount, tool); diff --git a/src/main/java/vazkii/botania/api/mana/ManaItemsEvent.java b/src/main/java/vazkii/botania/api/mana/ManaItemsEvent.java index e68c0df64..a189b8d30 100644 --- a/src/main/java/vazkii/botania/api/mana/ManaItemsEvent.java +++ b/src/main/java/vazkii/botania/api/mana/ManaItemsEvent.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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, 2016, 11:59:12 PM (GMT)] */ package vazkii.botania.api.mana; diff --git a/src/main/java/vazkii/botania/api/mana/ManaNetworkEvent.java b/src/main/java/vazkii/botania/api/mana/ManaNetworkEvent.java index 389af2347..fde5eedab 100644 --- a/src/main/java/vazkii/botania/api/mana/ManaNetworkEvent.java +++ b/src/main/java/vazkii/botania/api/mana/ManaNetworkEvent.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 22, 2014, 5:04:30 PM (GMT)] */ package vazkii.botania.api.mana; diff --git a/src/main/java/vazkii/botania/api/mana/ManaProficiencyEvent.java b/src/main/java/vazkii/botania/api/mana/ManaProficiencyEvent.java index 58631a2bf..8d73a97e9 100644 --- a/src/main/java/vazkii/botania/api/mana/ManaProficiencyEvent.java +++ b/src/main/java/vazkii/botania/api/mana/ManaProficiencyEvent.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Oct 4, 2016, 10:46:12 PM (GMT)] */ package vazkii.botania.api.mana; @@ -25,19 +23,19 @@ public class ManaProficiencyEvent extends Event { this.rod = rod; this.proficient = proficient; } - + public PlayerEntity getEntityPlayer() { return entityPlayer; } - + public ItemStack getRod() { return rod; } - + public boolean isProficient() { return proficient; } - + public void setProficient(boolean proficient) { this.proficient = proficient; } diff --git a/src/main/java/vazkii/botania/api/mana/spark/ISparkAttachable.java b/src/main/java/vazkii/botania/api/mana/spark/ISparkAttachable.java index 8421bd49c..a49920c05 100644 --- a/src/main/java/vazkii/botania/api/mana/spark/ISparkAttachable.java +++ b/src/main/java/vazkii/botania/api/mana/spark/ISparkAttachable.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 21, 2014, 5:44:13 PM (GMT)] */ package vazkii.botania.api.mana.spark; import net.minecraft.item.ItemStack; + import vazkii.botania.api.mana.IManaReceiver; /** diff --git a/src/main/java/vazkii/botania/api/mana/spark/ISparkEntity.java b/src/main/java/vazkii/botania/api/mana/spark/ISparkEntity.java index 95444d48a..0c938324a 100644 --- a/src/main/java/vazkii/botania/api/mana/spark/ISparkEntity.java +++ b/src/main/java/vazkii/botania/api/mana/spark/ISparkEntity.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 21, 2014, 5:44:07 PM (GMT)] */ package vazkii.botania.api.mana.spark; diff --git a/src/main/java/vazkii/botania/api/mana/spark/SparkHelper.java b/src/main/java/vazkii/botania/api/mana/spark/SparkHelper.java index f0f65d26b..034092b2e 100644 --- a/src/main/java/vazkii/botania/api/mana/spark/SparkHelper.java +++ b/src/main/java/vazkii/botania/api/mana/spark/SparkHelper.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 21, 2014, 7:16:11 PM (GMT)] */ package vazkii.botania.api.mana.spark; import com.google.common.base.Predicates; + import net.minecraft.entity.Entity; import net.minecraft.item.DyeColor; import net.minecraft.util.math.AxisAlignedBB; diff --git a/src/main/java/vazkii/botania/api/mana/spark/SparkUpgradeType.java b/src/main/java/vazkii/botania/api/mana/spark/SparkUpgradeType.java index c6d4d99f5..9d4832d92 100644 --- a/src/main/java/vazkii/botania/api/mana/spark/SparkUpgradeType.java +++ b/src/main/java/vazkii/botania/api/mana/spark/SparkUpgradeType.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.api.mana.spark; public enum SparkUpgradeType { diff --git a/src/main/java/vazkii/botania/api/recipe/ElvenPortalUpdateEvent.java b/src/main/java/vazkii/botania/api/recipe/ElvenPortalUpdateEvent.java index f1ecd54ac..1c9be5d9e 100644 --- a/src/main/java/vazkii/botania/api/recipe/ElvenPortalUpdateEvent.java +++ b/src/main/java/vazkii/botania/api/recipe/ElvenPortalUpdateEvent.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 17, 2015, 4:58:30 PM (GMT)] */ package vazkii.botania.api.recipe; diff --git a/src/main/java/vazkii/botania/api/recipe/ICustomApothecaryColor.java b/src/main/java/vazkii/botania/api/recipe/ICustomApothecaryColor.java index 4594a220f..8d9cceddb 100644 --- a/src/main/java/vazkii/botania/api/recipe/ICustomApothecaryColor.java +++ b/src/main/java/vazkii/botania/api/recipe/ICustomApothecaryColor.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 15, 2014, 2:36:35 PM (GMT)] */ package vazkii.botania.api.recipe; diff --git a/src/main/java/vazkii/botania/api/recipe/IElvenItem.java b/src/main/java/vazkii/botania/api/recipe/IElvenItem.java index e614014d0..0f88762de 100644 --- a/src/main/java/vazkii/botania/api/recipe/IElvenItem.java +++ b/src/main/java/vazkii/botania/api/recipe/IElvenItem.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.api.recipe; import net.minecraft.item.ItemStack; diff --git a/src/main/java/vazkii/botania/api/recipe/IModRecipe.java b/src/main/java/vazkii/botania/api/recipe/IModRecipe.java index cc97be60c..776dc47ca 100644 --- a/src/main/java/vazkii/botania/api/recipe/IModRecipe.java +++ b/src/main/java/vazkii/botania/api/recipe/IModRecipe.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.api.recipe; import net.minecraft.item.ItemStack; @@ -10,7 +18,7 @@ import java.util.List; * Implementation detail, you shouldn't need to use this. */ public interface IModRecipe { - List getInputs(); - ItemStack getOutput(); - ResourceLocation getId(); + List getInputs(); + ItemStack getOutput(); + ResourceLocation getId(); } diff --git a/src/main/java/vazkii/botania/api/recipe/RecipeBrew.java b/src/main/java/vazkii/botania/api/recipe/RecipeBrew.java index 5a032ddd6..e4748b179 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipeBrew.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipeBrew.java @@ -1,22 +1,22 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 1, 2014, 8:52:00 PM (GMT)] */ package vazkii.botania.api.recipe; import com.google.common.collect.ImmutableList; + import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.item.crafting.Ingredient; import net.minecraft.network.PacketBuffer; import net.minecraft.util.ResourceLocation; import net.minecraftforge.items.IItemHandler; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.brew.Brew; import vazkii.botania.api.brew.IBrewContainer; @@ -39,28 +39,31 @@ public class RecipeBrew { public boolean matches(IItemHandler inv) { List inputsMissing = new ArrayList<>(inputs); - for(int i = 0; i < inv.getSlots(); i++) { + for (int i = 0; i < inv.getSlots(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(stack.isEmpty()) + if (stack.isEmpty()) { break; + } - if(stack.getItem() instanceof IBrewContainer) + if (stack.getItem() instanceof IBrewContainer) { continue; + } boolean matchedOne = false; Iterator iter = inputsMissing.iterator(); while (iter.hasNext()) { Ingredient input = iter.next(); - if(input.test(stack)) { + if (input.test(stack)) { iter.remove(); matchedOne = true; break; } } - if(!matchedOne) + if (!matchedOne) { return false; + } } return inputsMissing.isEmpty(); @@ -83,8 +86,9 @@ public class RecipeBrew { } public ItemStack getOutput(ItemStack stack) { - if(stack.isEmpty() || !(stack.getItem() instanceof IBrewContainer)) + if (stack.isEmpty() || !(stack.getItem() instanceof IBrewContainer)) { return new ItemStack(Items.GLASS_BOTTLE); // Fallback... + } IBrewContainer container = (IBrewContainer) stack.getItem(); return container.getItemForBrew(brew, stack); diff --git a/src/main/java/vazkii/botania/api/recipe/RecipeElvenTrade.java b/src/main/java/vazkii/botania/api/recipe/RecipeElvenTrade.java index 2e09f956f..03cbd4fa6 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipeElvenTrade.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipeElvenTrade.java @@ -1,6 +1,15 @@ +/* + * This class is 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 + */ package vazkii.botania.api.recipe; import com.google.common.collect.ImmutableList; + import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.network.PacketBuffer; @@ -27,34 +36,39 @@ public class RecipeElvenTrade { /** * Attempts to match the recipe - * @param stacks Entire contents of the portal's buffer - * @return {@link Optional#empty()} if recipe doesn't match, Optional with a set of items used by recipe otherwise + * + * @param stacks Entire contents of the portal's buffer + * @return {@link Optional#empty()} if recipe doesn't match, Optional with a set of items used by recipe + * otherwise */ public Optional> match(List stacks) { List inputsMissing = new ArrayList<>(inputs); List stacksToRemove = new ArrayList<>(); - for(ItemStack stack : stacks) { - if(stack.isEmpty()) { + for (ItemStack stack : stacks) { + if (stack.isEmpty()) { continue; } - if(inputsMissing.isEmpty()) + if (inputsMissing.isEmpty()) { break; + } int stackIndex = -1; for (int i = 0; i < inputsMissing.size(); i++) { Ingredient ingr = inputsMissing.get(i); if (ingr.test(stack)) { - if(!stacksToRemove.contains(stack)) + if (!stacksToRemove.contains(stack)) { stacksToRemove.add(stack); + } stackIndex = i; break; } } - if(stackIndex != -1) + if (stackIndex != -1) { inputsMissing.remove(stackIndex); + } } return inputsMissing.isEmpty() ? Optional.of(stacksToRemove) : Optional.empty(); @@ -64,8 +78,8 @@ public class RecipeElvenTrade { * If the recipe does not contain the item, it will be destroyed upon entering the portal. */ public boolean containsItem(ItemStack stack) { - for(Ingredient input : inputs) { - if(input.test(stack)) { + for (Ingredient input : inputs) { + if (input.test(stack)) { return true; } } diff --git a/src/main/java/vazkii/botania/api/recipe/RecipeManaInfusion.java b/src/main/java/vazkii/botania/api/recipe/RecipeManaInfusion.java index 470247bf8..dec4a7512 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipeManaInfusion.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipeManaInfusion.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 30, 2014, 5:57:07 PM (GMT)] */ package vazkii.botania.api.recipe; import com.google.common.base.Preconditions; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.item.ItemStack; @@ -22,18 +21,15 @@ import net.minecraftforge.registries.ObjectHolder; import javax.annotation.Nullable; public class RecipeManaInfusion { - @ObjectHolder("botania:alchemy_catalyst") - public static Block alchemy; + @ObjectHolder("botania:alchemy_catalyst") public static Block alchemy; - @ObjectHolder("botania:conjuration_catalyst") - public static Block conjuration; + @ObjectHolder("botania:conjuration_catalyst") public static Block conjuration; private final ResourceLocation id; private final ItemStack output; private final Ingredient input; private final int mana; - @Nullable - private BlockState catalystState; + @Nullable private BlockState catalystState; private final String group; public static RecipeManaInfusion conjuration(ResourceLocation id, ItemStack output, Ingredient input, int mana) { @@ -119,4 +115,3 @@ public class RecipeManaInfusion { return ret; } } - diff --git a/src/main/java/vazkii/botania/api/recipe/RecipePetals.java b/src/main/java/vazkii/botania/api/recipe/RecipePetals.java index 35239c078..f47384ffd 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipePetals.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipePetals.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 22, 2014, 2:02:44 PM (GMT)] */ package vazkii.botania.api.recipe; import com.google.common.collect.ImmutableList; + import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.network.PacketBuffer; @@ -34,24 +33,27 @@ public class RecipePetals implements IModRecipe { public boolean matches(IItemHandler inv) { List ingredientsMissing = new ArrayList<>(inputs); - for(int i = 0; i < inv.getSlots(); i++) { + for (int i = 0; i < inv.getSlots(); i++) { ItemStack input = inv.getStackInSlot(i); - if(input.isEmpty()) + if (input.isEmpty()) { break; + } int stackIndex = -1; - for(int j = 0; j < ingredientsMissing.size(); j++) { + for (int j = 0; j < ingredientsMissing.size(); j++) { Ingredient ingr = ingredientsMissing.get(j); - if(ingr.test(input)) { + if (ingr.test(input)) { stackIndex = j; break; } } - if(stackIndex != -1) + if (stackIndex != -1) { ingredientsMissing.remove(stackIndex); - else return false; + } else { + return false; + } } return ingredientsMissing.isEmpty(); diff --git a/src/main/java/vazkii/botania/api/recipe/RecipePureDaisy.java b/src/main/java/vazkii/botania/api/recipe/RecipePureDaisy.java index 1ca7733f3..1e07e93a4 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipePureDaisy.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipePureDaisy.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 17, 2015, 5:07:25 PM (GMT)] */ package vazkii.botania.api.recipe; import com.google.common.base.Preconditions; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.network.PacketBuffer; @@ -20,6 +19,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.registry.Registry; import net.minecraft.world.World; + import vazkii.botania.api.subtile.TileEntitySpecialFlower; public class RecipePureDaisy { @@ -39,7 +39,8 @@ public class RecipePureDaisy { * @param id The ID for this recipe. * @param input The input for the recipe. Can be a Block, BlockState, or Tag<Block>. * @param state The blockstate to be placed upon recipe completion. - * @param time The amount of time in ticks to complete this recipe. Note that this is ticks on your block, not total time. + * @param time The amount of time in ticks to complete this recipe. Note that this is ticks on your block, not + * total time. * The Pure Daisy only ticks one block at a time in a round robin fashion. */ public RecipePureDaisy(ResourceLocation id, Object input, BlockState state, int time) { @@ -48,11 +49,12 @@ public class RecipePureDaisy { this.input = input; this.outputState = state; this.time = time; - if(input != null + if (input != null && !(input instanceof Block) && !(input instanceof BlockState) - && !(input instanceof Tag && checkBlockTag((Tag) input))) + && !(input instanceof Tag && checkBlockTag((Tag) input))) { throw new IllegalArgumentException("input must be a Tag, Block, or IBlockState"); + } } private static boolean checkBlockTag(Tag tag) { @@ -63,11 +65,13 @@ public class RecipePureDaisy { * This gets called every tick, please be careful with your checks. */ public boolean matches(World world, BlockPos pos, TileEntitySpecialFlower pureDaisy, BlockState state) { - if(input instanceof Block) + if (input instanceof Block) { return state.getBlock() == input; + } - if(input instanceof BlockState) + if (input instanceof BlockState) { return state == input; + } return ((Tag) input).contains(state.getBlock()); } @@ -78,8 +82,9 @@ public class RecipePureDaisy { * it otherwise. You may return false to cancel the normal particles and do your own. */ public boolean set(World world, BlockPos pos, TileEntitySpecialFlower pureDaisy) { - if(!world.isRemote) + if (!world.isRemote) { world.setBlockState(pos, outputState); + } return true; } @@ -119,10 +124,17 @@ public class RecipePureDaisy { ResourceLocation id = buf.readResourceLocation(); Object input; switch (buf.readVarInt()) { - case 0: input = new BlockTags.Wrapper(buf.readResourceLocation()); break; - case 1: input = Registry.BLOCK.getByValue(buf.readVarInt()); break; - case 2: input = Block.getStateById(buf.readVarInt()); break; - default: throw new RuntimeException("Unknown input discriminator"); + case 0: + input = new BlockTags.Wrapper(buf.readResourceLocation()); + break; + case 1: + input = Registry.BLOCK.getByValue(buf.readVarInt()); + break; + case 2: + input = Block.getStateById(buf.readVarInt()); + break; + default: + throw new RuntimeException("Unknown input discriminator"); } BlockState output = Block.getStateById(buf.readVarInt()); int time = buf.readVarInt(); diff --git a/src/main/java/vazkii/botania/api/recipe/RecipeRuneAltar.java b/src/main/java/vazkii/botania/api/recipe/RecipeRuneAltar.java index 02fd3c3d0..b05cdf419 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipeRuneAltar.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipeRuneAltar.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 5, 2014, 1:41:14 PM (GMT)] */ package vazkii.botania.api.recipe; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; + import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.network.PacketBuffer; @@ -39,24 +38,27 @@ public class RecipeRuneAltar implements IModRecipe { public boolean matches(IItemHandler inv) { List ingredientsMissing = new ArrayList<>(inputs); - for(int i = 0; i < inv.getSlots(); i++) { + for (int i = 0; i < inv.getSlots(); i++) { ItemStack input = inv.getStackInSlot(i); - if(input.isEmpty()) + if (input.isEmpty()) { break; + } int stackIndex = -1; - for(int j = 0; j < ingredientsMissing.size(); j++) { + for (int j = 0; j < ingredientsMissing.size(); j++) { Ingredient ingr = ingredientsMissing.get(j); - if(ingr.test(input)) { + if (ingr.test(input)) { stackIndex = j; break; } } - if(stackIndex != -1) + if (stackIndex != -1) { ingredientsMissing.remove(stackIndex); - else return false; + } else { + return false; + } } return ingredientsMissing.isEmpty(); diff --git a/src/main/java/vazkii/botania/api/recipe/RegisterRecipesEvent.java b/src/main/java/vazkii/botania/api/recipe/RegisterRecipesEvent.java index 83af2de6c..a563a8e80 100644 --- a/src/main/java/vazkii/botania/api/recipe/RegisterRecipesEvent.java +++ b/src/main/java/vazkii/botania/api/recipe/RegisterRecipesEvent.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.api.recipe; import net.minecraftforge.eventbus.api.Event; @@ -7,52 +15,50 @@ import java.util.function.Consumer; /** * Fired on {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS} * whenever Botania wants to receive recipe registrations, i.e. on server start and every /reload. - * * The handles to register recipes are simple {@link Consumer}s that accept the recipe to register it. - * * This will be fired many times during the lifecycle of the game, it's highly encouraged you keep your event * handlers as stateless as possible. */ public class RegisterRecipesEvent extends Event { - private final Consumer pureDaisy; - private final Consumer manaInfusion; - private final Consumer brew; - private final Consumer elvenTrade; - private final Consumer apothecary; - private final Consumer runeAltar; + private final Consumer pureDaisy; + private final Consumer manaInfusion; + private final Consumer brew; + private final Consumer elvenTrade; + private final Consumer apothecary; + private final Consumer runeAltar; - public RegisterRecipesEvent(Consumer pureDaisy, Consumer manaInfusion, - Consumer brew, Consumer elvenTrade, - Consumer apothecary, Consumer runeAltar) { - this.pureDaisy = pureDaisy; - this.manaInfusion = manaInfusion; - this.brew = brew; - this.elvenTrade = elvenTrade; - this.apothecary = apothecary; - this.runeAltar = runeAltar; - } + public RegisterRecipesEvent(Consumer pureDaisy, Consumer manaInfusion, + Consumer brew, Consumer elvenTrade, + Consumer apothecary, Consumer runeAltar) { + this.pureDaisy = pureDaisy; + this.manaInfusion = manaInfusion; + this.brew = brew; + this.elvenTrade = elvenTrade; + this.apothecary = apothecary; + this.runeAltar = runeAltar; + } - public Consumer pureDaisy() { - return pureDaisy; - } + public Consumer pureDaisy() { + return pureDaisy; + } - public Consumer manaInfusion() { - return manaInfusion; - } + public Consumer manaInfusion() { + return manaInfusion; + } - public Consumer brew() { - return brew; - } + public Consumer brew() { + return brew; + } - public Consumer elvenTrade() { - return elvenTrade; - } + public Consumer elvenTrade() { + return elvenTrade; + } - public Consumer apothecary() { - return apothecary; - } + public Consumer apothecary() { + return apothecary; + } - public Consumer runeAltar() { - return runeAltar; - } + public Consumer runeAltar() { + return runeAltar; + } } diff --git a/src/main/java/vazkii/botania/api/state/BotaniaStateProps.java b/src/main/java/vazkii/botania/api/state/BotaniaStateProps.java index 5b100f27f..da123fd4d 100644 --- a/src/main/java/vazkii/botania/api/state/BotaniaStateProps.java +++ b/src/main/java/vazkii/botania/api/state/BotaniaStateProps.java @@ -1,19 +1,21 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 */ package vazkii.botania.api.state; import com.google.common.base.Predicates; + import net.minecraft.item.DyeColor; import net.minecraft.state.BooleanProperty; import net.minecraft.state.EnumProperty; import net.minecraft.util.Direction; import net.minecraftforge.client.model.data.ModelProperty; + import vazkii.botania.api.item.IFloatingFlower; import vazkii.botania.api.state.enums.AlfPortalState; import vazkii.botania.api.state.enums.CratePattern; @@ -45,7 +47,6 @@ public final class BotaniaStateProps { // BlockPrism public static final BooleanProperty HAS_LENS = BooleanProperty.create("has_lens"); - private BotaniaStateProps() { - } + private BotaniaStateProps() {} } diff --git a/src/main/java/vazkii/botania/api/state/enums/AlfPortalState.java b/src/main/java/vazkii/botania/api/state/enums/AlfPortalState.java index 91d52e25d..9f8cf45ae 100644 --- a/src/main/java/vazkii/botania/api/state/enums/AlfPortalState.java +++ b/src/main/java/vazkii/botania/api/state/enums/AlfPortalState.java @@ -1,8 +1,8 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 */ diff --git a/src/main/java/vazkii/botania/api/state/enums/CratePattern.java b/src/main/java/vazkii/botania/api/state/enums/CratePattern.java index 60440854b..4e51f9153 100644 --- a/src/main/java/vazkii/botania/api/state/enums/CratePattern.java +++ b/src/main/java/vazkii/botania/api/state/enums/CratePattern.java @@ -1,8 +1,8 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 */ @@ -10,6 +10,7 @@ package vazkii.botania.api.state.enums; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; + import net.minecraft.util.IStringSerializable; import java.util.List; @@ -17,35 +18,35 @@ import java.util.Locale; public enum CratePattern implements IStringSerializable { NONE(true, true, true, - true, true, true, - true, true, true), - CRAFTY_1_1( true, false, false, - false, false, false, - false, false, false), - CRAFTY_2_2( true, true, false, - true, true, false, - false, false, false), - CRAFTY_1_2( true, false, false, - true, false, false, - false, false, false), - CRAFTY_2_1( true, true, false, - false, false, false, - false, false, false), - CRAFTY_1_3( true, false, false, - true, false, false, - true, false, false), - CRAFTY_3_1( true, true, true, - false, false, false, - false, false, false), - CRAFTY_2_3( true, true, false, - true, true, false, - true, true, false), - CRAFTY_3_2( true, true, true, - true, true, true, - false, false, false), + true, true, true, + true, true, true), + CRAFTY_1_1(true, false, false, + false, false, false, + false, false, false), + CRAFTY_2_2(true, true, false, + true, true, false, + false, false, false), + CRAFTY_1_2(true, false, false, + true, false, false, + false, false, false), + CRAFTY_2_1(true, true, false, + false, false, false, + false, false, false), + CRAFTY_1_3(true, false, false, + true, false, false, + true, false, false), + CRAFTY_3_1(true, true, true, + false, false, false, + false, false, false), + CRAFTY_2_3(true, true, false, + true, true, false, + true, true, false), + CRAFTY_3_2(true, true, true, + true, true, true, + false, false, false), CRAFTY_DONUT(true, true, true, - true, false, true, - true, true, true); + true, false, true, + true, true, true); public final List openSlots; diff --git a/src/main/java/vazkii/botania/api/state/enums/LuminizerVariant.java b/src/main/java/vazkii/botania/api/state/enums/LuminizerVariant.java index 8ade0a003..37943e2f8 100644 --- a/src/main/java/vazkii/botania/api/state/enums/LuminizerVariant.java +++ b/src/main/java/vazkii/botania/api/state/enums/LuminizerVariant.java @@ -1,8 +1,8 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 */ diff --git a/src/main/java/vazkii/botania/api/subtile/RadiusDescriptor.java b/src/main/java/vazkii/botania/api/subtile/RadiusDescriptor.java index 5d832888c..ca8ea9837 100644 --- a/src/main/java/vazkii/botania/api/subtile/RadiusDescriptor.java +++ b/src/main/java/vazkii/botania/api/subtile/RadiusDescriptor.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 31, 2015, 2:59:19 PM (GMT)] */ package vazkii.botania.api.subtile; diff --git a/src/main/java/vazkii/botania/api/subtile/TileEntityFunctionalFlower.java b/src/main/java/vazkii/botania/api/subtile/TileEntityFunctionalFlower.java index 0fd2f34d1..912960879 100644 --- a/src/main/java/vazkii/botania/api/subtile/TileEntityFunctionalFlower.java +++ b/src/main/java/vazkii/botania/api/subtile/TileEntityFunctionalFlower.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 24, 2014, 8:03:44 PM (GMT)] */ package vazkii.botania.api.subtile; @@ -24,12 +22,11 @@ import net.minecraft.util.math.MathHelper; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.registries.ForgeRegistries; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.internal.IManaNetwork; import vazkii.botania.api.mana.IManaPool; -import java.awt.*; - /** * The basic class for a Functional Flower. */ @@ -70,7 +67,7 @@ public class TileEntityFunctionalFlower extends TileEntitySpecialFlower { linkPool(); - if(linkedPool != null && isValidBinding()) { + if (linkedPool != null && isValidBinding()) { IManaPool pool = (IManaPool) linkedPool; int manaInPool = pool.getCurrentMana(); int manaMissing = getMaxMana() - mana; @@ -79,36 +76,37 @@ public class TileEntityFunctionalFlower extends TileEntitySpecialFlower { addMana(manaToRemove); } - if(acceptsRedstone()) { + if (acceptsRedstone()) { redstoneSignal = 0; - for(Direction dir : Direction.values()) { + for (Direction dir : Direction.values()) { int redstoneSide = getWorld().getRedstonePower(getPos().offset(dir), dir); redstoneSignal = Math.max(redstoneSignal, redstoneSide); } } - if(getWorld().isRemote) { + if (getWorld().isRemote) { double particleChance = 1F - (double) mana / (double) getMaxMana() / 3.5F; int color = getColor(); float red = (color >> 16 & 0xFF) / 255F; float green = (color >> 8 & 0xFF) / 255F; float blue = (color & 0xFF) / 255F; - if(Math.random() > particleChance) - BotaniaAPI.internalHandler.sparkleFX(getWorld(), getPos().getX() + 0.3 + Math.random() * 0.5, getPos().getY() + 0.5 + Math.random() * 0.5, getPos().getZ() + 0.3 + Math.random() * 0.5, red, green, blue, (float) Math.random(), 5); + if (Math.random() > particleChance) { + BotaniaAPI.internalHandler.sparkleFX(getWorld(), getPos().getX() + 0.3 + Math.random() * 0.5, getPos().getY() + 0.5 + Math.random() * 0.5, getPos().getZ() + 0.3 + Math.random() * 0.5, red, green, blue, (float) Math.random(), 5); + } } } public void linkPool() { boolean needsNew = false; - if(linkedPool == null) { + if (linkedPool == null) { needsNew = true; - if(cachedPoolCoordinates != null) { + if (cachedPoolCoordinates != null) { needsNew = false; - if(getWorld().isBlockLoaded(cachedPoolCoordinates)) { + if (getWorld().isBlockLoaded(cachedPoolCoordinates)) { needsNew = true; TileEntity tileAt = getWorld().getTileEntity(cachedPoolCoordinates); - if(tileAt instanceof IManaPool && !tileAt.isRemoved()) { + if (tileAt instanceof IManaPool && !tileAt.isRemoved()) { linkedPool = tileAt; needsNew = false; } @@ -117,14 +115,15 @@ public class TileEntityFunctionalFlower extends TileEntitySpecialFlower { } } else { TileEntity tileAt = getWorld().getTileEntity(linkedPool.getPos()); - if(tileAt instanceof IManaPool) + if (tileAt instanceof IManaPool) { linkedPool = tileAt; + } } - if(needsNew && ticksExisted == 1) { // Only for new flowers + if (needsNew && ticksExisted == 1) { // Only for new flowers IManaNetwork network = BotaniaAPI.internalHandler.getManaNetworkInstance(); int size = network.getAllPoolsInWorld(getWorld()).size(); - if(BotaniaAPI.internalHandler.shouldForceCheck() || size != sizeLastCheck) { + if (BotaniaAPI.internalHandler.shouldForceCheck() || size != sizeLastCheck) { linkedPool = network.getClosestPool(getPos(), getWorld(), LINK_RANGE); sizeLastCheck = size; } @@ -149,13 +148,15 @@ public class TileEntityFunctionalFlower extends TileEntitySpecialFlower { @Override public boolean onWanded(PlayerEntity player, ItemStack wand) { - if(player == null) + if (player == null) { return false; + } knownMana = mana; SoundEvent evt = ForgeRegistries.SOUND_EVENTS.getValue(DING_SOUND_EVENT); - if(evt != null) + if (evt != null) { player.playSound(evt, 0.1F, 1F); + } return super.onWanded(player, wand); } @@ -185,7 +186,7 @@ public class TileEntityFunctionalFlower extends TileEntitySpecialFlower { super.writeToPacketNBT(cmp); cmp.putInt(TAG_MANA, mana); - if(cachedPoolCoordinates != null) { + if (cachedPoolCoordinates != null) { cmp.putInt(TAG_POOL_X, cachedPoolCoordinates.getX()); cmp.putInt(TAG_POOL_Y, cachedPoolCoordinates.getY()); cmp.putInt(TAG_POOL_Z, cachedPoolCoordinates.getZ()); @@ -202,8 +203,9 @@ public class TileEntityFunctionalFlower extends TileEntitySpecialFlower { @Override public BlockPos getBinding() { - if(linkedPool == null) + if (linkedPool == null) { return null; + } return linkedPool.getPos(); } @@ -218,9 +220,9 @@ public class TileEntityFunctionalFlower extends TileEntitySpecialFlower { range *= range; double dist = pos.distanceSq(getPos()); - if(range >= dist) { + if (range >= dist) { TileEntity tile = player.world.getTileEntity(pos); - if(tile instanceof IManaPool) { + if (tile instanceof IManaPool) { linkedPool = tile; return true; } diff --git a/src/main/java/vazkii/botania/api/subtile/TileEntityGeneratingFlower.java b/src/main/java/vazkii/botania/api/subtile/TileEntityGeneratingFlower.java index c9750ee28..b29d5761d 100644 --- a/src/main/java/vazkii/botania/api/subtile/TileEntityGeneratingFlower.java +++ b/src/main/java/vazkii/botania/api/subtile/TileEntityGeneratingFlower.java @@ -1,20 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 24, 2014, 8:03:36 PM (GMT)] */ package vazkii.botania.api.subtile; -import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.I18n; -import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; @@ -24,18 +20,14 @@ import net.minecraft.util.Direction; import net.minecraft.util.SoundEvent; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; -import net.minecraft.world.storage.loot.LootContext; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.registries.ForgeRegistries; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.internal.IManaNetwork; import vazkii.botania.api.mana.IManaCollector; -import java.awt.*; -import java.util.List; - /** * The basic class for a Generating Flower. */ @@ -78,32 +70,33 @@ public class TileEntityGeneratingFlower extends TileEntitySpecialFlower { linkCollector(); - if(canGeneratePassively()) { + if (canGeneratePassively()) { int delay = getDelayBetweenPassiveGeneration(); - if(delay > 0 && ticksExisted % delay == 0 && !getWorld().isRemote) { - if(shouldSyncPassiveGeneration()) + if (delay > 0 && ticksExisted % delay == 0 && !getWorld().isRemote) { + if (shouldSyncPassiveGeneration()) { sync(); + } addMana(getValueForPassiveGeneration()); } } emptyManaIntoCollector(); - if(acceptsRedstone()) { + if (acceptsRedstone()) { redstoneSignal = 0; - for(Direction dir : Direction.values()) { + for (Direction dir : Direction.values()) { int redstoneSide = getWorld().getRedstonePower(getPos().offset(dir), dir); redstoneSignal = Math.max(redstoneSignal, redstoneSide); } } - if(getWorld().isRemote) { + if (getWorld().isRemote) { double particleChance = 1F - (double) getMana() / (double) getMaxMana() / 3.5F; int color = getColor(); float red = (color >> 16 & 0xFF) / 255F; float green = (color >> 8 & 0xFF) / 255F; float blue = (color & 0xFF) / 255F; - if(Math.random() > particleChance) { + if (Math.random() > particleChance) { Vec3d offset = getWorld().getBlockState(getPos()).getOffset(getWorld(), getPos()); double x = getPos().getX() + offset.x; double y = getPos().getY() + offset.y; @@ -113,31 +106,33 @@ public class TileEntityGeneratingFlower extends TileEntitySpecialFlower { } boolean passive = isPassiveFlower(); - if(!getWorld().isRemote) { + if (!getWorld().isRemote) { int muhBalance = BotaniaAPI.internalHandler.getPassiveFlowerDecay(); - if(passive && muhBalance > 0 && passiveDecayTicks > muhBalance) { + if (passive && muhBalance > 0 && passiveDecayTicks > muhBalance) { getWorld().destroyBlock(getPos(), false); - if(Blocks.DEAD_BUSH.getDefaultState().isValidPosition(getWorld(), getPos())) + if (Blocks.DEAD_BUSH.getDefaultState().isValidPosition(getWorld(), getPos())) { getWorld().setBlockState(getPos(), Blocks.DEAD_BUSH.getDefaultState()); + } } } - if(passive) + if (passive) { passiveDecayTicks++; + } } public void linkCollector() { boolean needsNew = false; - if(linkedCollector == null) { + if (linkedCollector == null) { needsNew = true; - if(cachedCollectorCoordinates != null) { + if (cachedCollectorCoordinates != null) { needsNew = false; - if(getWorld().isBlockLoaded(cachedCollectorCoordinates)) { + if (getWorld().isBlockLoaded(cachedCollectorCoordinates)) { needsNew = true; TileEntity tileAt = getWorld().getTileEntity(cachedCollectorCoordinates); - if(tileAt instanceof IManaCollector && !tileAt.isRemoved()) { + if (tileAt instanceof IManaCollector && !tileAt.isRemoved()) { linkedCollector = tileAt; needsNew = false; } @@ -146,14 +141,15 @@ public class TileEntityGeneratingFlower extends TileEntitySpecialFlower { } } else { TileEntity tileAt = getWorld().getTileEntity(linkedCollector.getPos()); - if(tileAt instanceof IManaCollector) + if (tileAt instanceof IManaCollector) { linkedCollector = tileAt; + } } - if(needsNew && ticksExisted == 1) { // New flowers only + if (needsNew && ticksExisted == 1) { // New flowers only IManaNetwork network = BotaniaAPI.internalHandler.getManaNetworkInstance(); int size = network.getAllCollectorsInWorld(getWorld()).size(); - if(BotaniaAPI.internalHandler.shouldForceCheck() || size != sizeLastCheck) { + if (BotaniaAPI.internalHandler.shouldForceCheck() || size != sizeLastCheck) { linkedCollector = network.getClosestCollector(getPos(), getWorld(), LINK_RANGE); sizeLastCheck = size; } @@ -170,9 +166,9 @@ public class TileEntityGeneratingFlower extends TileEntitySpecialFlower { } public void emptyManaIntoCollector() { - if(linkedCollector != null && isValidBinding()) { + if (linkedCollector != null && isValidBinding()) { IManaCollector collector = (IManaCollector) linkedCollector; - if(!collector.isFull() && getMana() > 0) { + if (!collector.isFull() && getMana() > 0) { int manaval = Math.min(getMana(), collector.getMaxMana() - collector.getCurrentMana()); mana = getMana() - manaval; collector.recieveMana(manaval); @@ -202,16 +198,19 @@ public class TileEntityGeneratingFlower extends TileEntitySpecialFlower { @Override public boolean onWanded(PlayerEntity player, ItemStack wand) { - if(player == null) + if (player == null) { return false; + } - if(!player.world.isRemote) + if (!player.world.isRemote) { sync(); + } knownMana = getMana(); SoundEvent evt = ForgeRegistries.SOUND_EVENTS.getValue(DING_SOUND_EVENT); - if(evt != null) + if (evt != null) { player.playSound(evt, 0.1F, 1F); + } return super.onWanded(player, wand); } @@ -244,7 +243,7 @@ public class TileEntityGeneratingFlower extends TileEntitySpecialFlower { cmp.putInt(TAG_TICKS_EXISTED, ticksExisted); cmp.putInt(TAG_PASSIVE_DECAY_TICKS, passiveDecayTicks); - if(cachedCollectorCoordinates != null) { + if (cachedCollectorCoordinates != null) { cmp.putInt(TAG_COLLECTOR_X, cachedCollectorCoordinates.getX()); cmp.putInt(TAG_COLLECTOR_Y, cachedCollectorCoordinates.getY()); cmp.putInt(TAG_COLLECTOR_Z, cachedCollectorCoordinates.getZ()); @@ -261,8 +260,9 @@ public class TileEntityGeneratingFlower extends TileEntitySpecialFlower { @Override public BlockPos getBinding() { - if(linkedCollector == null) + if (linkedCollector == null) { return null; + } return linkedCollector.getPos(); } @@ -277,9 +277,9 @@ public class TileEntityGeneratingFlower extends TileEntitySpecialFlower { range *= range; double dist = pos.distanceSq(getPos()); - if(range >= dist) { + if (range >= dist) { TileEntity tile = player.world.getTileEntity(pos); - if(tile instanceof IManaCollector) { + if (tile instanceof IManaCollector) { linkedCollector = tile; return true; } @@ -288,7 +288,6 @@ public class TileEntityGeneratingFlower extends TileEntitySpecialFlower { return false; } - public boolean isValidBinding() { return linkedCollector != null && !linkedCollector.isRemoved() && getWorld().getTileEntity(linkedCollector.getPos()) == linkedCollector; } diff --git a/src/main/java/vazkii/botania/api/subtile/TileEntitySpecialFlower.java b/src/main/java/vazkii/botania/api/subtile/TileEntitySpecialFlower.java index 556201222..9b5a3e324 100644 --- a/src/main/java/vazkii/botania/api/subtile/TileEntitySpecialFlower.java +++ b/src/main/java/vazkii/botania/api/subtile/TileEntitySpecialFlower.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 24, 2014, 3:59:06 PM (GMT)] */ package vazkii.botania.api.subtile; @@ -41,6 +39,7 @@ import net.minecraftforge.client.model.data.ModelDataMap; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.registries.ForgeRegistries; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.capability.FloatingFlowerImpl; import vazkii.botania.api.internal.VanillaPacketDispatcher; @@ -53,6 +52,7 @@ import vazkii.botania.common.lib.ModTags; import javax.annotation.Nonnull; import javax.annotation.Nullable; + import java.util.List; /** @@ -68,7 +68,7 @@ public class TileEntitySpecialFlower extends TileEntity implements ITickableTile public ItemStack getDisplayStack() { ResourceLocation id = getType().getRegistryName(); Item item = ForgeRegistries.ITEMS.getValue(id); - if(item != null) { + if (item != null) { return new ItemStack(item); } else { return super.getDisplayStack(); @@ -95,9 +95,9 @@ public class TileEntitySpecialFlower extends TileEntity implements ITickableTile @Override public final void tick() { TileEntity tileBelow = world.getTileEntity(pos.down()); - if(tileBelow instanceof TileRedStringRelay) { + if (tileBelow instanceof TileRedStringRelay) { BlockPos coords = ((TileRedStringRelay) tileBelow).getBinding(); - if(coords != null) { + if (coords != null) { positionOverride = coords; tickFlower(); @@ -110,9 +110,9 @@ public class TileEntitySpecialFlower extends TileEntity implements ITickableTile } boolean special = isOnSpecialSoil(); - if(special) { + if (special) { this.overgrowth = true; - if(isOvergrowthAffected()) { + if (isOvergrowthAffected()) { tickFlower(); overgrowthBoost = true; } @@ -125,8 +125,8 @@ public class TileEntitySpecialFlower extends TileEntity implements ITickableTile @Nonnull @Override public LazyOptional getCapability(@Nonnull Capability cap, @Nullable Direction side) { - if(cap == BotaniaAPI.FLOATING_FLOWER_CAP) { - if(hasWorld() && getBlockState().isIn(ModTags.Blocks.SPECIAL_FLOATING_FLOWERS)) { + if (cap == BotaniaAPI.FLOATING_FLOWER_CAP) { + if (hasWorld() && getBlockState().isIn(ModTags.Blocks.SPECIAL_FLOATING_FLOWERS)) { return floatingDataCap.cast(); } } @@ -138,7 +138,7 @@ public class TileEntitySpecialFlower extends TileEntity implements ITickableTile } private boolean isOnSpecialSoil() { - if(isFloating()) { + if (isFloating()) { return false; } else { return world.getBlockState(pos.down()).getBlock() == ModBlocks.enchantedSoil; @@ -147,7 +147,7 @@ public class TileEntitySpecialFlower extends TileEntity implements ITickableTile /** * @return Where this flower's effects are centered at. This can differ from the true TE location due to - * red string spoofers. + * red string spoofers. */ public final BlockPos getEffectivePos() { return positionOverride != null ? positionOverride : getPos(); @@ -161,8 +161,9 @@ public class TileEntitySpecialFlower extends TileEntity implements ITickableTile @Override public final void read(CompoundNBT cmp) { super.read(cmp); - if(cmp.contains(TAG_TICKS_EXISTED)) + if (cmp.contains(TAG_TICKS_EXISTED)) { ticksExisted = cmp.getInt(TAG_TICKS_EXISTED); + } readFromPacketNBT(cmp); } @@ -186,7 +187,7 @@ public class TileEntitySpecialFlower extends TileEntity implements ITickableTile public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket packet) { IFloatingFlower.IslandType oldType = floatingData.getIslandType(); readFromPacketNBT(packet.getNbtCompound()); - if(oldType != floatingData.getIslandType() && isFloating()) { + if (oldType != floatingData.getIslandType() && isFloating()) { ModelDataManager.requestModelDataRefresh(this); world.notifyBlockUpdate(getPos(), getBlockState(), getBlockState(), 0); } @@ -204,8 +205,9 @@ public class TileEntitySpecialFlower extends TileEntity implements ITickableTile * Note: This method is also used to write to the world NBT. */ public void writeToPacketNBT(CompoundNBT cmp) { - if (isFloating()) + if (isFloating()) { cmp.put(TAG_FLOATING_DATA, BotaniaAPI.FLOATING_FLOWER_CAP.writeNBT(floatingData, null)); + } } /** @@ -214,8 +216,9 @@ public class TileEntitySpecialFlower extends TileEntity implements ITickableTile * to read from the world NBT. */ public void readFromPacketNBT(CompoundNBT cmp) { - if(cmp.contains(TAG_FLOATING_DATA)) + if (cmp.contains(TAG_FLOATING_DATA)) { BotaniaAPI.FLOATING_FLOWER_CAP.readNBT(floatingData, null, cmp.getCompound(TAG_FLOATING_DATA)); + } } public void sync() { @@ -238,7 +241,9 @@ public class TileEntitySpecialFlower extends TileEntity implements ITickableTile /** * Called when a player right clicks this sub tile. */ - public ActionResultType onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { return ActionResultType.PASS; } + public ActionResultType onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { + return ActionResultType.PASS; + } /** * Called when this sub tile is added to the world. @@ -327,18 +332,20 @@ public class TileEntitySpecialFlower extends TileEntity implements ITickableTile * needs to be on the floor equal to the value of this method.. */ public int getSlowdownFactor() { - if(isFloating()) { + if (isFloating()) { IFloatingFlower.IslandType type = floatingData.getIslandType(); - if(type == IFloatingFlower.IslandType.MYCEL) + if (type == IFloatingFlower.IslandType.MYCEL) { return SLOWDOWN_FACTOR_MYCEL; - else if(type == IFloatingFlower.IslandType.PODZOL) + } else if (type == IFloatingFlower.IslandType.PODZOL) { return SLOWDOWN_FACTOR_PODZOL; + } } else { Block below = world.getBlockState(getPos().down()).getBlock(); - if(below == Blocks.MYCELIUM) + if (below == Blocks.MYCELIUM) { return SLOWDOWN_FACTOR_MYCEL; + } - if(below == Blocks.PODZOL) { + if (below == Blocks.PODZOL) { return SLOWDOWN_FACTOR_PODZOL; } } @@ -349,7 +356,7 @@ public class TileEntitySpecialFlower extends TileEntity implements ITickableTile @Nonnull @Override public IModelData getModelData() { - if(isFloating()) { + if (isFloating()) { return new ModelDataMap.Builder() .withInitial(BotaniaStateProps.FLOATING_DATA, floatingData) .build(); diff --git a/src/main/java/vazkii/botania/api/wand/ICoordBoundItem.java b/src/main/java/vazkii/botania/api/wand/ICoordBoundItem.java index 8d3321f44..891066c72 100644 --- a/src/main/java/vazkii/botania/api/wand/ICoordBoundItem.java +++ b/src/main/java/vazkii/botania/api/wand/ICoordBoundItem.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.api.wand; import net.minecraft.item.ItemStack; @@ -6,6 +14,7 @@ import net.minecraft.util.math.BlockPos; /** * The item equivalent of ITileBound, renders when the * item is in hand. + * * @see ITileBound */ public interface ICoordBoundItem { diff --git a/src/main/java/vazkii/botania/api/wand/ITileBound.java b/src/main/java/vazkii/botania/api/wand/ITileBound.java index 3a995ce19..055519935 100644 --- a/src/main/java/vazkii/botania/api/wand/ITileBound.java +++ b/src/main/java/vazkii/botania/api/wand/ITileBound.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 24, 2014, 6:47:53 PM (GMT)] */ package vazkii.botania.api.wand; diff --git a/src/main/java/vazkii/botania/api/wand/IWandBindable.java b/src/main/java/vazkii/botania/api/wand/IWandBindable.java index 7adcd168b..75f32248a 100644 --- a/src/main/java/vazkii/botania/api/wand/IWandBindable.java +++ b/src/main/java/vazkii/botania/api/wand/IWandBindable.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Oct 9, 2014, 3:01:58 PM (GMT)] */ package vazkii.botania.api.wand; diff --git a/src/main/java/vazkii/botania/api/wand/IWandHUD.java b/src/main/java/vazkii/botania/api/wand/IWandHUD.java index 1bf25ac03..91d509ed9 100644 --- a/src/main/java/vazkii/botania/api/wand/IWandHUD.java +++ b/src/main/java/vazkii/botania/api/wand/IWandHUD.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 5, 2014, 1:34:44 PM (GMT)] */ package vazkii.botania.api.wand; diff --git a/src/main/java/vazkii/botania/api/wand/IWandable.java b/src/main/java/vazkii/botania/api/wand/IWandable.java index 0381cb3d3..4a6d22dd4 100644 --- a/src/main/java/vazkii/botania/api/wand/IWandable.java +++ b/src/main/java/vazkii/botania/api/wand/IWandable.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 22, 2014, 5:12:53 PM (GMT)] */ package vazkii.botania.api.wand; diff --git a/src/main/java/vazkii/botania/api/wand/IWireframeAABBProvider.java b/src/main/java/vazkii/botania/api/wand/IWireframeAABBProvider.java index 1fc3ba552..97c00d182 100644 --- a/src/main/java/vazkii/botania/api/wand/IWireframeAABBProvider.java +++ b/src/main/java/vazkii/botania/api/wand/IWireframeAABBProvider.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 19, 2014, 7:23:59 PM (GMT)] */ package vazkii.botania.api.wand; diff --git a/src/main/java/vazkii/botania/client/core/handler/AstrolabePreviewHandler.java b/src/main/java/vazkii/botania/client/core/handler/AstrolabePreviewHandler.java index 08b028e2a..d1b11aeea 100644 --- a/src/main/java/vazkii/botania/client/core/handler/AstrolabePreviewHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/AstrolabePreviewHandler.java @@ -1,42 +1,34 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [27/10/2016, 17:55:20 (GMT)] */ package vazkii.botania.client.core.handler; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GLX; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.Atlases; import net.minecraft.client.renderer.BlockRendererDispatcher; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.RenderTypeLookup; import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.ILightReader; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.helper.RenderHelper; -import vazkii.botania.client.core.helper.ShaderHelper; import vazkii.botania.common.item.ItemAstrolabe; import vazkii.botania.common.lib.LibMisc; @@ -53,13 +45,15 @@ public final class AstrolabePreviewHandler { for (PlayerEntity player : world.getPlayers()) { ItemStack currentStack = player.getHeldItemMainhand(); - if(currentStack.isEmpty() || !(currentStack.getItem() instanceof ItemAstrolabe)) + if (currentStack.isEmpty() || !(currentStack.getItem() instanceof ItemAstrolabe)) { currentStack = player.getHeldItemOffhand(); + } - if(!currentStack.isEmpty() && currentStack.getItem() instanceof ItemAstrolabe) { + if (!currentStack.isEmpty() && currentStack.getItem() instanceof ItemAstrolabe) { Block block = ItemAstrolabe.getBlock(currentStack); - if(block != Blocks.AIR) + if (block != Blocks.AIR) { renderPlayerLook(ms, buffer, player, currentStack); + } } } @@ -71,8 +65,9 @@ public final class AstrolabePreviewHandler { if (ItemAstrolabe.hasBlocks(stack, player, coords)) { BlockState state = ItemAstrolabe.getBlockState(stack); - for(BlockPos coord : coords) + for (BlockPos coord : coords) { renderBlockAt(ms, buffer, state, coord); + } } } @@ -88,9 +83,9 @@ public final class AstrolabePreviewHandler { ms.translate(pos.getX(), pos.getY(), pos.getZ()); IBakedModel model = brd.getModelForState(state); int color = Minecraft.getInstance().getBlockColors().getColor(state, null, null, 0); - float r = (float)(color >> 16 & 255) / 255.0F; - float g = (float)(color >> 8 & 255) / 255.0F; - float b = (float)(color & 255) / 255.0F; + float r = (float) (color >> 16 & 255) / 255.0F; + float g = (float) (color >> 8 & 255) / 255.0F; + float b = (float) (color & 255) / 255.0F; // always use entity translucent layer so blending is turned on brd.getBlockModelRenderer().render(ms.peek(), buffer, state, model, r, g, b, 0xF000F0, OverlayTexture.DEFAULT_UV); diff --git a/src/main/java/vazkii/botania/client/core/handler/BaubleRenderHandler.java b/src/main/java/vazkii/botania/client/core/handler/BaubleRenderHandler.java index c3c9b8d01..f04ed2f8f 100644 --- a/src/main/java/vazkii/botania/client/core/handler/BaubleRenderHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/BaubleRenderHandler.java @@ -1,18 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 27, 2014, 8:55:00 PM (GMT)] */ package vazkii.botania.client.core.handler; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GLX; -import com.mojang.blaze3d.platform.GlStateManager; + import net.minecraft.client.Minecraft; import net.minecraft.client.entity.player.AbstractClientPlayerEntity; import net.minecraft.client.renderer.IRenderTypeBuffer; @@ -21,16 +18,17 @@ import net.minecraft.client.renderer.entity.IEntityRenderer; import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.client.renderer.entity.model.PlayerModel; import net.minecraft.client.renderer.model.ItemCameraTransforms; -import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.potion.Effects; + import top.theillusivec4.curios.api.CuriosAPI; import top.theillusivec4.curios.api.capability.CuriosCapability; import top.theillusivec4.curios.api.inventory.CurioStackHandler; + import vazkii.botania.api.item.AccessoryRenderHelper; import vazkii.botania.api.item.ICosmeticAttachable; import vazkii.botania.api.item.IPhantomInkable; @@ -38,6 +36,7 @@ import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.item.ModItems; import javax.annotation.Nonnull; + import java.util.Map; public final class BaubleRenderHandler extends LayerRenderer> { @@ -61,23 +60,24 @@ public final class BaubleRenderHandler extends LayerRenderer { Map curios = handler.getCurioMap(); - for(Map.Entry e : curios.entrySet()) { - for(int i = 0; i < e.getValue().getSlots(); i++) { + for (Map.Entry e : curios.entrySet()) { + for (int i = 0; i < e.getValue().getSlots(); i++) { ItemStack stack = e.getValue().getStackInSlot(i); - if(!stack.isEmpty()) { + if (!stack.isEmpty()) { Item item = stack.getItem(); - if(item instanceof IPhantomInkable) { + if (item instanceof IPhantomInkable) { IPhantomInkable inkable = (IPhantomInkable) item; - if(inkable.hasPhantomInk(stack)) + if (inkable.hasPhantomInk(stack)) { continue; + } } - if(item instanceof ICosmeticAttachable) { + if (item instanceof ICosmeticAttachable) { ICosmeticAttachable attachable = (ICosmeticAttachable) item; ItemStack cosmetic = attachable.getCosmeticItem(stack); cosmetic.getCapability(CuriosCapability.ITEM).ifPresent(c -> { - if(c.hasRender(e.getKey(), player)) { + if (c.hasRender(e.getKey(), player)) { ms.push(); c.render(e.getKey(), ms, buffers, light, player, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch); ms.pop(); @@ -93,9 +93,9 @@ public final class BaubleRenderHandler extends LayerRenderer. It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 31, 2015, 3:16:02 PM (GMT)] */ package vazkii.botania.client.core.handler; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.Matrix4f; -import net.minecraft.client.renderer.RenderState; -import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -33,8 +28,7 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.ObfuscationReflectionHelper; -import org.lwjgl.opengl.GL11; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntitySpecialFlower; import vazkii.botania.client.core.helper.RenderHelper; @@ -46,6 +40,7 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nullable; + import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -62,8 +57,8 @@ public final class BlockHighlightRenderHandler { MatrixStack ms = event.getMatrixStack(); IRenderTypeBuffer.Impl buffers = IRenderTypeBuffer.immediate(Tessellator.getInstance().getBuffer()); /* Needed because RenderState.CullState doesn't actually disable if you pass false, it keeps the current state. - And we go into this method with cull enabled. - */ + And we go into this method with cull enabled. + */ RenderSystem.disableCull(); ms.push(); @@ -74,8 +69,9 @@ public final class BlockHighlightRenderHandler { ItemStack stackHeld = PlayerHelper.getFirstHeldItem(mc.player, ModItems.twigWand); if (!stackHeld.isEmpty() && ItemTwigWand.getBindMode(stackHeld)) { Optional coords = ItemTwigWand.getBindingAttempt(stackHeld); - if (coords.isPresent()) + if (coords.isPresent()) { bPos = coords.get(); + } } TileEntity tile = mc.world.getTileEntity(bPos); @@ -83,16 +79,18 @@ public final class BlockHighlightRenderHandler { TileEntitySpecialFlower subtile = (TileEntitySpecialFlower) tile; RadiusDescriptor descriptor = subtile.getRadius(); if (descriptor != null) { - if (descriptor.isCircle()) + if (descriptor.isCircle()) { renderCircle(ms, buffers, descriptor.getSubtileCoords(), descriptor.getCircleRadius()); - else renderRectangle(ms, buffers, descriptor.getAABB(), true, null, (byte) 32); + } else { + renderRectangle(ms, buffers, descriptor.getAABB(), true, null, (byte) 32); + } } } } double offY = -1.0 / 16 + 0.005; - for(Entity e : mc.world.getAllEntities()) - if(e instanceof EntityMagicLandmine) { + for (Entity e : mc.world.getAllEntities()) { + if (e instanceof EntityMagicLandmine) { BlockPos bpos = e.getPosition(); AxisAlignedBB aabb = new AxisAlignedBB(bpos).offset(0, offY, 0).grow(2.5, 0, 2.5); @@ -103,14 +101,16 @@ public final class BlockHighlightRenderHandler { int color = r << 16 | g << 8 | b; int alpha = 32; - if(e.ticksExisted < 8) + if (e.ticksExisted < 8) { alpha *= Math.min((e.ticksExisted + event.getPartialTicks()) / 8F, 1F); - else if(e.ticksExisted > 47) + } else if (e.ticksExisted > 47) { alpha *= Math.min(1F - (e.ticksExisted - 47 + event.getPartialTicks()) / 8F, 1F); + } renderRectangle(ms, buffers, aabb, false, color, (byte) alpha); offY += 0.001; } + } ms.pop(); buffers.draw(); @@ -124,8 +124,9 @@ public final class BlockHighlightRenderHandler { ms.push(); ms.translate(aabb.minX - renderPosX, aabb.minY - renderPosY, aabb.minZ - renderPosZ); - if(color == null) + if (color == null) { color = MathHelper.hsvToRGB(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F); + } int r = (color >> 16 & 0xFF); int g = (color >> 8 & 0xFF); int b = (color & 0xFF); @@ -141,7 +142,7 @@ public final class BlockHighlightRenderHandler { buffer.vertex(mat, f, f, z).color(r, g, b, alpha).endVertex(); buffer.vertex(mat, x, f, z).color(r, g, b, alpha).endVertex(); - if(inner) { + if (inner) { x += f; z += f; float f1 = f + f / 4F; @@ -183,7 +184,7 @@ public final class BlockHighlightRenderHandler { Runnable centerFunc = () -> buffer.vertex(mat, 0, f, 0).color(r, g, b, alpha).endVertex(); List vertexFuncs = new ArrayList<>(); - for(int i = 0; i < totalAngles + 1; i += step) { + for (int i = 0; i < totalAngles + 1; i += step) { double rad = (totalAngles - i) * Math.PI / 180.0; float xp = (float) (Math.cos(rad) * radius); float zp = (float) (Math.sin(rad) * radius); @@ -197,7 +198,7 @@ public final class BlockHighlightRenderHandler { centerFunc = () -> buffer.vertex(mat, 0, f1, 0).color(r, g, b, alpha2).endVertex(); vertexFuncs.clear(); - for(int i = 0; i < totalAngles + 1; i += step) { + for (int i = 0; i < totalAngles + 1; i += step) { double rad = (totalAngles - i) * Math.PI / 180.0; float xp = (float) (Math.cos(rad) * radius); float zp = (float) (Math.sin(rad) * radius); diff --git a/src/main/java/vazkii/botania/client/core/handler/BossBarHandler.java b/src/main/java/vazkii/botania/client/core/handler/BossBarHandler.java index 38e9d13e0..b07aaddb4 100644 --- a/src/main/java/vazkii/botania/client/core/handler/BossBarHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/BossBarHandler.java @@ -1,24 +1,25 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Oct 29, 2014, 6:46:10 PM (GMT)] */ package vazkii.botania.client.core.handler; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.client.Minecraft; import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.boss.IBotaniaBoss; import vazkii.botania.api.internal.ShaderCallback; import vazkii.botania.client.core.helper.RenderHelper; @@ -45,8 +46,8 @@ public final class BossBarHandler { @SubscribeEvent public static void onBarRender(RenderGameOverlayEvent.BossInfo evt) { UUID infoUuid = evt.getBossInfo().getUniqueId(); - for(IBotaniaBoss currentBoss : bosses) { - if(currentBoss.getBossInfoUuid().equals(infoUuid)) { + for (IBotaniaBoss currentBoss : bosses) { + if (currentBoss.getBossInfoUuid().equals(infoUuid)) { evt.setCanceled(true); Minecraft mc = Minecraft.getInstance(); @@ -79,7 +80,7 @@ public final class BossBarHandler { int program = currentBoss.getBossBarShaderProgram(bg); boolean useShader = program > 0; - if(useShader) { + if (useShader) { ShaderCallback callback = currentBoss.getBossBarShaderCallback(bg, program); barUniformCallback.set(u, v, callback); ShaderHelper.useShader(program, barUniformCallback); @@ -87,8 +88,9 @@ public final class BossBarHandler { RenderHelper.drawTexturedModalRect(x, y, u, v, w, h); - if(useShader) + if (useShader) { ShaderHelper.releaseShader(); + } } private static class BarCallback implements ShaderCallback { @@ -100,12 +102,12 @@ public final class BossBarHandler { int startXUniform = GlStateManager.getUniformLocation(shader, "startX"); int startYUniform = GlStateManager.getUniformLocation(shader, "startY"); - GlStateManager.uniform1(startXUniform, x); GlStateManager.uniform1(startYUniform, y); - if(callback != null) + if (callback != null) { callback.call(shader); + } } void set(int x, int y, ShaderCallback callback) { diff --git a/src/main/java/vazkii/botania/client/core/handler/BoundTileRenderer.java b/src/main/java/vazkii/botania/client/core/handler/BoundTileRenderer.java index 3eb1e0fe6..e6d280271 100644 --- a/src/main/java/vazkii/botania/client/core/handler/BoundTileRenderer.java +++ b/src/main/java/vazkii/botania/client/core/handler/BoundTileRenderer.java @@ -1,18 +1,17 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 24, 2014, 7:02:37 PM (GMT)] */ package vazkii.botania.client.core.handler; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; @@ -39,6 +38,7 @@ import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.wrapper.CombinedInvWrapper; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.item.IWireframeCoordinateListProvider; import vazkii.botania.api.wand.ICoordBoundItem; @@ -47,7 +47,6 @@ import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.lib.LibMisc; -import java.util.Collections; import java.util.IdentityHashMap; import java.util.List; import java.util.Map; @@ -63,12 +62,14 @@ public final class BoundTileRenderer { ret.put(RenderHelper.LINE_8_NO_DEPTH, new BufferBuilder(RenderHelper.LINE_8_NO_DEPTH.getExpectedBufferSize())); return ret; }), Tessellator.getInstance().getBuffer()); + private BoundTileRenderer() {} @SubscribeEvent public static void onWorldRenderLast(RenderWorldLastEvent event) { - if (!ConfigHandler.CLIENT.boundBlockWireframe.get()) + if (!ConfigHandler.CLIENT.boundBlockWireframe.get()) { return; + } MatrixStack ms = event.getMatrixStack(); ms.push(); @@ -76,16 +77,18 @@ public final class BoundTileRenderer { PlayerEntity player = Minecraft.getInstance().player; int color = 0xFF000000 | MathHelper.hsvToRGB(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F); - if(!player.getHeldItemMainhand().isEmpty() && player.getHeldItemMainhand().getItem() instanceof ICoordBoundItem) { + if (!player.getHeldItemMainhand().isEmpty() && player.getHeldItemMainhand().getItem() instanceof ICoordBoundItem) { BlockPos coords = ((ICoordBoundItem) player.getHeldItemMainhand().getItem()).getBinding(player.getHeldItemMainhand()); - if(coords != null) + if (coords != null) { renderBlockOutlineAt(ms, LINE_BUFFERS, coords, color); + } } - if(!player.getHeldItemOffhand().isEmpty() && player.getHeldItemOffhand().getItem() instanceof ICoordBoundItem) { + if (!player.getHeldItemOffhand().isEmpty() && player.getHeldItemOffhand().getItem() instanceof ICoordBoundItem) { BlockPos coords = ((ICoordBoundItem) player.getHeldItemOffhand().getItem()).getBinding(player.getHeldItemOffhand()); - if(coords != null) + if (coords != null) { renderBlockOutlineAt(ms, LINE_BUFFERS, coords, color); + } } LazyOptional mainInvCap = player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP); @@ -99,12 +102,14 @@ public final class BoundTileRenderer { if (!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof IWireframeCoordinateListProvider) { IWireframeCoordinateListProvider provider = (IWireframeCoordinateListProvider) stackInSlot.getItem(); List coordsList = provider.getWireframesToDraw(player, stackInSlot); - for (BlockPos coords : coordsList) + for (BlockPos coords : coordsList) { renderBlockOutlineAt(ms, LINE_BUFFERS, coords, color); + } BlockPos coords = provider.getSourceWireframe(player, stackInSlot); - if (coords != null && coords.getY() > -1) + if (coords != null && coords.getY() > -1) { renderBlockOutlineAt(ms, LINE_BUFFERS, coords, color, true); + } } } }); @@ -131,9 +136,9 @@ public final class BoundTileRenderer { Block block = state.getBlock(); List list; - if(block instanceof IWireframeAABBProvider) + if (block instanceof IWireframeAABBProvider) { list = ((IWireframeAABBProvider) block).getWireframeAABB(world, pos); - else{ + } else { VoxelShape shape = state.getShape(world, pos); list = shape.toBoundingBoxList().stream().map(b -> b.offset(pos)).collect(Collectors.toList()); } diff --git a/src/main/java/vazkii/botania/client/core/handler/ClientTickHandler.java b/src/main/java/vazkii/botania/client/core/handler/ClientTickHandler.java index c84ae2cf1..b8305fa14 100644 --- a/src/main/java/vazkii/botania/client/core/handler/ClientTickHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/ClientTickHandler.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 3, 2014, 9:59:17 PM (GMT)] */ package vazkii.botania.client.core.handler; import com.google.common.collect.ImmutableList; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screen.Screen; import net.minecraft.entity.player.PlayerEntity; @@ -20,6 +19,7 @@ import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; + import vazkii.botania.api.mana.IManaCollector; import vazkii.botania.client.render.tile.RenderTileRedString; import vazkii.botania.common.block.subtile.functional.SubTileVinculotus; @@ -53,7 +53,7 @@ public final class ClientTickHandler { @SubscribeEvent public static void renderTick(TickEvent.RenderTickEvent event) { Minecraft mc = Minecraft.getInstance(); - if(event.phase == TickEvent.Phase.START) { + if (event.phase == TickEvent.Phase.START) { partialTicks = event.renderTickTime; if (mc.isGamePaused()) { @@ -72,25 +72,26 @@ public final class ClientTickHandler { @SubscribeEvent public static void clientTickEnd(TickEvent.ClientTickEvent event) { - if(event.phase == TickEvent.Phase.END) { + if (event.phase == TickEvent.Phase.END) { RenderTileRedString.tick(); ItemsRemainingRenderHandler.tick(); - if(Minecraft.getInstance().world == null) { + if (Minecraft.getInstance().world == null) { ManaNetworkHandler.instance.clear(); SubTileVinculotus.existingFlowers.clear(); } - if(!Minecraft.getInstance().isGamePaused()) { + if (!Minecraft.getInstance().isGamePaused()) { ticksInGame++; partialTicks = 0; PlayerEntity player = Minecraft.getInstance().player; - if(player != null) { - if(PlayerHelper.hasHeldItemClass(player, ModItems.twigWand)) { - for(TileEntity tile : ImmutableList.copyOf(ManaNetworkHandler.instance.getAllCollectorsInWorld(Minecraft.getInstance().world))) { - if(tile instanceof IManaCollector) + if (player != null) { + if (PlayerHelper.hasHeldItemClass(player, ModItems.twigWand)) { + for (TileEntity tile : ImmutableList.copyOf(ManaNetworkHandler.instance.getAllCollectorsInWorld(Minecraft.getInstance().world))) { + if (tile instanceof IManaCollector) { ((IManaCollector) tile).onClientDisplayTick(); + } } } } @@ -98,18 +99,22 @@ public final class ClientTickHandler { int ticksToOpen = 10; Screen gui = Minecraft.getInstance().currentScreen; - if(gui instanceof GuiBook && ((GuiBook) gui).book.getBookItem().getItem() == ModItems.lexicon) { - if(ticksWithLexicaOpen < 0) + if (gui instanceof GuiBook && ((GuiBook) gui).book.getBookItem().getItem() == ModItems.lexicon) { + if (ticksWithLexicaOpen < 0) { ticksWithLexicaOpen = 0; - if(ticksWithLexicaOpen < ticksToOpen) + } + if (ticksWithLexicaOpen < ticksToOpen) { ticksWithLexicaOpen++; - if(pageFlipTicks > 0) + } + if (pageFlipTicks > 0) { pageFlipTicks--; + } } else { pageFlipTicks = 0; - if(ticksWithLexicaOpen > 0) { - if(ticksWithLexicaOpen > ticksToOpen) + if (ticksWithLexicaOpen > 0) { + if (ticksWithLexicaOpen > ticksToOpen) { ticksWithLexicaOpen = ticksToOpen; + } ticksWithLexicaOpen--; } } @@ -119,8 +124,9 @@ public final class ClientTickHandler { } public static void notifyPageChange() { - if(pageFlipTicks == 0) + if (pageFlipTicks == 0) { pageFlipTicks = 5; + } } } diff --git a/src/main/java/vazkii/botania/client/core/handler/ColorHandler.java b/src/main/java/vazkii/botania/client/core/handler/ColorHandler.java index 6ecb0027e..d55640e99 100644 --- a/src/main/java/vazkii/botania/client/core/handler/ColorHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/ColorHandler.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.client.core.handler; import net.minecraft.block.BlockState; @@ -15,6 +23,7 @@ import net.minecraft.util.Util; import net.minecraft.util.math.MathHelper; import net.minecraft.world.FoliageColors; import net.minecraft.world.biome.BiomeColors; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.brew.Brew; import vazkii.botania.api.brew.IBrewItem; @@ -49,17 +58,18 @@ public final class ColorHandler { // Pool blocks.register( (state, world, pos, tintIndex) -> { - if(tintIndex != 0) + if (tintIndex != 0) { return -1; + } int color = DyeColor.WHITE.colorValue; - if(world != null && pos != null) { + if (world != null && pos != null) { TileEntity te = world.getTileEntity(pos); - if(te instanceof TilePool) { + if (te instanceof TilePool) { color = ((TilePool) te).color.colorValue; } } - if (((BlockPool) state.getBlock()).variant == BlockPool.Variant.FABULOUS){ + if (((BlockPool) state.getBlock()).variant == BlockPool.Variant.FABULOUS) { float time = (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.005F; int fabulousColor = MathHelper.hsvToRGB(time - (int) time, 0.6F, 1F); return vazkii.botania.common.core.helper.MathHelper.multiplyColor(fabulousColor, color); @@ -67,7 +77,7 @@ public final class ColorHandler { return color; }, ModBlocks.manaPool, ModBlocks.creativePool, ModBlocks.dilutedPool, ModBlocks.fabulousPool - ); + ); // Spreader blocks.register( @@ -76,7 +86,7 @@ public final class ColorHandler { return MathHelper.hsvToRGB(time * 5 % 360 / 360F, 0.4F, 0.9F); }, ModBlocks.gaiaSpreader - ); + ); // Petal Block blocks.register((state, world, pos, tintIndex) -> tintIndex == 0 ? ((BlockPetalBlock) state.getBlock()).color.colorValue : -1, @@ -84,20 +94,21 @@ public final class ColorHandler { ModBlocks.petalBlockYellow, ModBlocks.petalBlockLime, ModBlocks.petalBlockPink, ModBlocks.petalBlockGray, ModBlocks.petalBlockSilver, ModBlocks.petalBlockCyan, ModBlocks.petalBlockPurple, ModBlocks.petalBlockBlue, ModBlocks.petalBlockBrown, ModBlocks.petalBlockGreen, ModBlocks.petalBlockRed, ModBlocks.petalBlockBlack - ); + ); // Platforms blocks.register( (state, world, pos, tintIndex) -> { if (world != null && pos != null) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TilePlatform) { + if (tile instanceof TilePlatform) { TilePlatform camo = (TilePlatform) tile; BlockState camoState = camo.camoState; - if(camoState != null) + if (camoState != null) { return camoState.getBlock() instanceof BlockPlatform ? 0xFFFFFF - : Minecraft.getInstance().getBlockColors().getColor(camoState, world, pos, tintIndex); + : Minecraft.getInstance().getBlockColors().getColor(camoState, world, pos, tintIndex); + } } } return 0xFFFFFF; @@ -106,17 +117,16 @@ public final class ColorHandler { ItemColors items = Minecraft.getInstance().getItemColors(); items.register((s, t) -> t == 0 ? MathHelper.hsvToRGB(Botania.proxy.getWorldElapsedTicks() * 2 % 360 / 360F, 0.25F, 1F) : -1, - ModItems.lifeEssence, ModItems.gaiaIngot); + ModItems.lifeEssence, ModItems.gaiaIngot); - items.register((s, t) -> - t == 1 ? DyeColor.byId(ItemTwigWand.getColor1(s)).colorValue + items.register((s, t) -> t == 1 ? DyeColor.byId(ItemTwigWand.getColor1(s)).colorValue : t == 2 ? DyeColor.byId(ItemTwigWand.getColor2(s)).colorValue - : -1, - ModItems.twigWand); + : -1, + ModItems.twigWand); IItemColor petalHandler = (s, t) -> t == 0 ? ((ItemPetal) s.getItem()).color.colorValue : -1; IItemColor dyeHandler = (s, t) -> t == 0 ? ((Item16Colors) s.getItem()).color.colorValue : -1; - for(DyeColor color : DyeColor.values()) { + for (DyeColor color : DyeColor.values()) { items.register(petalHandler, ModItems.getPetal(color)); items.register(dyeHandler, ModItems.getDye(color)); } @@ -132,15 +142,17 @@ public final class ColorHandler { items.register((s, t) -> t == 1 ? MathHelper.hsvToRGB(0.528F, (float) ((ItemManaTablet) ModItems.manaTablet).getMana(s) / (float) ItemManaTablet.MAX_MANA, 1F) : -1, ModItems.manaTablet); - items.register((s, t) -> t == 0 ? MathHelper.hsvToRGB(0.55F, ((float) s.getMaxDamage() - (float) s.getDamage()) / (float)s.getMaxDamage() * 0.5F, 1F) : -1, ModItems.spellCloth); + items.register((s, t) -> t == 0 ? MathHelper.hsvToRGB(0.55F, ((float) s.getMaxDamage() - (float) s.getDamage()) / (float) s.getMaxDamage() * 0.5F, 1F) : -1, ModItems.spellCloth); items.register((s, t) -> { - if(t != 1) + if (t != 1) { return -1; + } Brew brew = ((IBrewItem) s.getItem()).getBrew(s); - if(brew == BotaniaAPI.fallbackBrew) + if (brew == BotaniaAPI.fallbackBrew) { return s.getItem() instanceof ItemBloodPendant ? 0xC6000E : 0x989898; + } int color = brew.getColor(s); double speed = s.getItem() == ModItems.brewFlask || s.getItem() == ModItems.brewVial ? 0.1 : 0.2; @@ -155,10 +167,11 @@ public final class ColorHandler { items.register((s, t) -> { ItemStack lens = ItemManaGun.getLens(s); - if(!lens.isEmpty() && t == 0) + if (!lens.isEmpty() && t == 0) { return Minecraft.getInstance().getItemColors().getColor(lens, t); + } - if(t == 2) { + if (t == 2) { BurstProperties props = ((ItemManaGun) s.getItem()).getBurstProps(Minecraft.getInstance().player, s, false, Hand.MAIN_HAND); float mul = (float) (Math.sin((double) ClientTickHandler.ticksInGame / 5) * 0.15F); @@ -173,7 +186,9 @@ public final class ColorHandler { int cb = MathHelper.clamp(b, 0, 255); return cr << 16 | cg << 8 | cb; - } else return -1; + } else { + return -1; + } }, ModItems.manaGun); items.register((s, t) -> t == 1 ? MathHelper.hsvToRGB(0.75F, 1F, 1.5F - (float) Math.min(1F, Math.sin(Util.milliTime() / 100D) * 0.5 + 1.2F)) : -1, ModItems.enderDagger); diff --git a/src/main/java/vazkii/botania/client/core/handler/ContributorFancinessHandler.java b/src/main/java/vazkii/botania/client/core/handler/ContributorFancinessHandler.java index ecbb2d149..ede7eb1f6 100644 --- a/src/main/java/vazkii/botania/client/core/handler/ContributorFancinessHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/ContributorFancinessHandler.java @@ -1,32 +1,26 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 9, 2015, 5:35:26 PM (GMT)] */ package vazkii.botania.client.core.handler; import com.google.common.collect.ImmutableMap; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; -import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.client.Minecraft; import net.minecraft.client.entity.player.AbstractClientPlayerEntity; import net.minecraft.client.renderer.Atlases; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.entity.IEntityRenderer; import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.client.renderer.entity.model.PlayerModel; import net.minecraft.client.renderer.model.ItemCameraTransforms; -import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerModelPart; import net.minecraft.item.DyeColor; @@ -34,16 +28,16 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.util.DefaultUncaughtExceptionHandler; + import vazkii.botania.api.item.AccessoryRenderHelper; -import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.client.core.helper.RenderHelper; -import vazkii.botania.client.core.helper.ShaderHelper; import vazkii.botania.common.Botania; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.ModTags; import javax.annotation.Nonnull; + import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; @@ -73,26 +67,29 @@ public final class ContributorFancinessHandler extends LayerRenderer= 16) + if (i < 0 || i >= 16) { throw new NumberFormatException(); + } flowerMap.put(key, new ItemStack(ModBlocks.getFlower(DyeColor.byId(i)))); } catch (NumberFormatException e) { String rawName = value.toLowerCase(Locale.ROOT); diff --git a/src/main/java/vazkii/botania/client/core/handler/CorporeaInputHandler.java b/src/main/java/vazkii/botania/client/core/handler/CorporeaInputHandler.java index 6a5fd944e..da4baa4d8 100644 --- a/src/main/java/vazkii/botania/client/core/handler/CorporeaInputHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/CorporeaInputHandler.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [July 04, 2018, 19:16:14 (GMT)] */ package vazkii.botania.client.core.handler; @@ -24,6 +22,7 @@ import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; + import vazkii.botania.client.core.proxy.ClientProxy; import vazkii.botania.common.Botania; import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex; @@ -47,25 +46,28 @@ public class CorporeaInputHandler { @SubscribeEvent public static void buttonPressed(GuiScreenEvent.KeyboardKeyPressedEvent.Pre event) { Minecraft mc = Minecraft.getInstance(); - - if(mc.world == null || !supportedGuiFilter.test(mc.currentScreen) || event.getKeyCode() == 0 - || ClientProxy.CORPOREA_REQUEST.getKey().getKeyCode() != event.getKeyCode() - || TileCorporeaIndex.InputHandler.getNearbyIndexes(mc.player).isEmpty()) + + if (mc.world == null || !supportedGuiFilter.test(mc.currentScreen) || event.getKeyCode() == 0 + || ClientProxy.CORPOREA_REQUEST.getKey().getKeyCode() != event.getKeyCode() + || TileCorporeaIndex.InputHandler.getNearbyIndexes(mc.player).isEmpty()) { return; + } ItemStack stack = getStackUnderMouse(); - if(stack != null && !stack.isEmpty()) { + if (stack != null && !stack.isEmpty()) { int count = 1; int max = stack.getMaxStackSize(); - if(Screen.hasShiftDown()) { + if (Screen.hasShiftDown()) { count = max; - if(Screen.hasControlDown()) + if (Screen.hasControlDown()) { count /= 4; - } else if(Screen.hasControlDown()) + } + } else if (Screen.hasControlDown()) { count = max / 2; + } - if(count > 0) { + if (count > 0) { ItemStack requested = stack.copy(); requested.setCount(count); PacketHandler.sendToServer(new PacketIndexKeybindRequest(requested)); @@ -76,12 +78,12 @@ public class CorporeaInputHandler { private static ItemStack getStackUnderMouse() { Screen screen = Minecraft.getInstance().currentScreen; - if(screen instanceof ContainerScreen) { + if (screen instanceof ContainerScreen) { Slot slotUnderMouse = ((ContainerScreen) screen).getSlotUnderMouse(); - if(slotUnderMouse != null) { + if (slotUnderMouse != null) { ItemStack stack = slotUnderMouse.getStack().copy(); stack.setTag(null); // Wipe NBT of inventory items before request, as player items will often have data - return stack; // that's better to ignore. This is still an improvement over matching names only. + return stack; // that's better to ignore. This is still an improvement over matching names only. } } @@ -97,7 +99,7 @@ public class CorporeaInputHandler { Botania.LOGGER.error("Failed to get hovered recipe gui button", e); } } - + return jeiPanelSupplier.get(); } } diff --git a/src/main/java/vazkii/botania/client/core/handler/DebugHandler.java b/src/main/java/vazkii/botania/client/core/handler/DebugHandler.java index 0aeef0f8a..627882410 100644 --- a/src/main/java/vazkii/botania/client/core/handler/DebugHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/DebugHandler.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Oct 21, 2014, 4:58:55 PM (GMT)] */ package vazkii.botania.client.core.handler; @@ -25,10 +23,12 @@ import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.server.ServerLifecycleHooks; import net.minecraftforge.forgespi.language.IModInfo; + import org.lwjgl.opengl.GL; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GLCapabilities; + import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.core.handler.ManaNetworkHandler; import vazkii.botania.common.lib.LibMisc; @@ -43,7 +43,7 @@ public final class DebugHandler { @SubscribeEvent public static void onDrawDebugText(RenderGameOverlayEvent.Text event) { World world = Minecraft.getInstance().world; - if(ConfigHandler.CLIENT.debugInfo.get() && Minecraft.getInstance().gameSettings.showDebugInfo) { + if (ConfigHandler.CLIENT.debugInfo.get() && Minecraft.getInstance().gameSettings.showDebugInfo) { event.getLeft().add(""); String version = ModList.get().getModContainerById(LibMisc.MOD_ID) .map(ModContainer::getModInfo) @@ -62,7 +62,7 @@ public final class DebugHandler { } } - if(Screen.hasControlDown() && Screen.hasShiftDown()) { + if (Screen.hasControlDown() && Screen.hasShiftDown()) { event.getLeft().add(PREFIX + "Config Context"); event.getLeft().add(" shaders.enabled: " + ConfigHandler.CLIENT.useShaders.get()); @@ -74,11 +74,12 @@ public final class DebugHandler { event.getLeft().add(" GL_ARB_multitexture: " + caps.GL_ARB_multitexture); event.getLeft().add(" GL_ARB_texture_non_power_of_two: " + caps.GL_ARB_texture_non_power_of_two); event.getLeft().add(" OpenGL13: " + caps.OpenGL13); - } else if(Minecraft.IS_RUNNING_ON_MAC) + } else if (Minecraft.IS_RUNNING_ON_MAC) { event.getLeft().add(PREFIX + "SHIFT+CMD for context"); - else event.getLeft().add(PREFIX + "SHIFT+CTRL for context"); + } else { + event.getLeft().add(PREFIX + "SHIFT+CTRL for context"); + } } } - } diff --git a/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java b/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java index a58b372fa..c97fd1b15 100644 --- a/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 25, 2014, 6:11:10 PM (GMT)] */ package vazkii.botania.client.core.handler; import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; @@ -37,7 +36,9 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.wrapper.EmptyHandler; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.mana.ICreativeManaProvider; import vazkii.botania.api.mana.IManaItem; @@ -82,19 +83,19 @@ public final class HUDHandler { ItemStack main = mc.player.getHeldItemMainhand(); ItemStack offhand = mc.player.getHeldItemOffhand(); - if(event.getType() == ElementType.ALL) { + if (event.getType() == ElementType.ALL) { profiler.startSection("botania-hud"); if (Minecraft.getInstance().playerController.shouldDrawHUD()) { ItemStack tiara = EquipmentHandler.findOrEmpty(ModItems.flightTiara, mc.player); - if(!tiara.isEmpty()) { + if (!tiara.isEmpty()) { profiler.startSection("flugelTiara"); ItemFlightTiara.renderHUD(mc.player, tiara); profiler.endSection(); } ItemStack dodgeRing = EquipmentHandler.findOrEmpty(ModItems.dodgeRing, mc.player); - if(!dodgeRing.isEmpty()) { + if (!dodgeRing.isEmpty()) { profiler.startSection("dodgeRing"); ItemDodgeRing.renderHUD(mc.player, dodgeRing, event.getPartialTicks()); profiler.endSection(); @@ -103,51 +104,53 @@ public final class HUDHandler { RayTraceResult pos = mc.objectMouseOver; - if(pos != null) { + if (pos != null) { BlockPos bpos = pos.getType() == RayTraceResult.Type.BLOCK ? ((BlockRayTraceResult) pos).getPos() : null; BlockState state = bpos != null ? mc.world.getBlockState(bpos) : null; Block block = state == null ? null : state.getBlock(); TileEntity tile = bpos != null ? mc.world.getTileEntity(bpos) : null; - if(PlayerHelper.hasAnyHeldItem(mc.player)) { - if(PlayerHelper.hasHeldItem(mc.player, ModItems.twigWand)) { - if(block instanceof IWandHUD) { + if (PlayerHelper.hasAnyHeldItem(mc.player)) { + if (PlayerHelper.hasHeldItem(mc.player, ModItems.twigWand)) { + if (block instanceof IWandHUD) { profiler.startSection("wandItem"); ((IWandHUD) block).renderHUD(mc, mc.world, bpos); profiler.endSection(); } } - if(tile instanceof TilePool && !mc.player.getHeldItemMainhand().isEmpty()) + if (tile instanceof TilePool && !mc.player.getHeldItemMainhand().isEmpty()) { renderPoolRecipeHUD((TilePool) tile, mc.player.getHeldItemMainhand()); + } } - if(!PlayerHelper.hasHeldItem(mc.player, ModItems.lexicon)) { - if(tile instanceof TileAltar) + if (!PlayerHelper.hasHeldItem(mc.player, ModItems.lexicon)) { + if (tile instanceof TileAltar) { ((TileAltar) tile).renderHUD(mc); - else if(tile instanceof TileRuneAltar) + } else if (tile instanceof TileRuneAltar) { ((TileRuneAltar) tile).renderHUD(mc); - else if(tile instanceof TileCorporeaCrystalCube) + } else if (tile instanceof TileCorporeaCrystalCube) { renderCrystalCubeHUD((TileCorporeaCrystalCube) tile); + } } } TileCorporeaIndex.getInputHandler(); - if(!InputHandler.getNearbyIndexes(mc.player).isEmpty() && mc.currentScreen instanceof ChatScreen) { + if (!InputHandler.getNearbyIndexes(mc.player).isEmpty() && mc.currentScreen instanceof ChatScreen) { profiler.startSection("nearIndex"); renderNearIndexDisplay(); profiler.endSection(); } - if(!main.isEmpty() && main.getItem() instanceof ItemCraftingHalo) { + if (!main.isEmpty() && main.getItem() instanceof ItemCraftingHalo) { profiler.startSection("craftingHalo_main"); ItemCraftingHalo.renderHUD(mc.player, main); profiler.endSection(); - } else if(!offhand.isEmpty() && offhand.getItem() instanceof ItemCraftingHalo) { + } else if (!offhand.isEmpty() && offhand.getItem() instanceof ItemCraftingHalo) { profiler.startSection("craftingHalo_off"); ItemCraftingHalo.renderHUD(mc.player, offhand); profiler.endSection(); } - if(!main.isEmpty() && main.getItem() instanceof ItemSextant) { + if (!main.isEmpty() && main.getItem() instanceof ItemSextant) { profiler.startSection("sextant"); ItemSextant.renderHUD(mc.player, main); profiler.endSection(); @@ -159,7 +162,7 @@ public final class HUDHandler { profiler.endSection(); }*/ - if(Botania.proxy.isClientPlayerWearingMonocle()) { + if (Botania.proxy.isClientPlayerWearingMonocle()) { profiler.startSection("monocle"); ItemMonocle.renderHUD(mc.player); profiler.endSection(); @@ -168,7 +171,7 @@ public final class HUDHandler { profiler.startSection("manaBar"); PlayerEntity player = mc.player; - if(!player.isSpectator()) { + if (!player.isSpectator()) { int totalMana = 0; int totalMaxMana = 0; boolean anyRequest = false; @@ -179,45 +182,50 @@ public final class HUDHandler { int invSize = mainInv.getSlots(); int size = invSize; - if(accInv != null) + if (accInv != null) { size += accInv.getSlots(); + } - for(int i = 0; i < size; i++) { + for (int i = 0; i < size; i++) { boolean useAccessories = i >= invSize; IItemHandler inv = useAccessories ? accInv : mainInv; ItemStack stack = inv.getStackInSlot(i - (useAccessories ? invSize : 0)); - if(!stack.isEmpty()) { + if (!stack.isEmpty()) { Item item = stack.getItem(); - if(item instanceof IManaUsingItem) + if (item instanceof IManaUsingItem) { anyRequest = anyRequest || ((IManaUsingItem) item).usesMana(stack); + } } } List items = ManaItemHandler.getManaItems(player); for (ItemStack stack : items) { Item item = stack.getItem(); - if(!((IManaItem) item).isNoExport(stack)) { + if (!((IManaItem) item).isNoExport(stack)) { totalMana += ((IManaItem) item).getMana(stack); totalMaxMana += ((IManaItem) item).getMaxMana(stack); } - if(item instanceof ICreativeManaProvider && ((ICreativeManaProvider) item).isCreative(stack)) + if (item instanceof ICreativeManaProvider && ((ICreativeManaProvider) item).isCreative(stack)) { creative = true; + } } List acc = ManaItemHandler.getManaAccesories(player); for (ItemStack stack : acc) { Item item = stack.getItem(); - if(!((IManaItem) item).isNoExport(stack)) { + if (!((IManaItem) item).isNoExport(stack)) { totalMana += ((IManaItem) item).getMana(stack); totalMaxMana += ((IManaItem) item).getMaxMana(stack); } - if(item instanceof ICreativeManaProvider && ((ICreativeManaProvider) item).isCreative(stack)) + if (item instanceof ICreativeManaProvider && ((ICreativeManaProvider) item).isCreative(stack)) { creative = true; + } } - if(anyRequest) + if (anyRequest) { renderManaInvBar(creative, totalMana, totalMaxMana); + } } profiler.endStartSection("itemsRemaining"); @@ -235,16 +243,20 @@ public final class HUDHandler { int x = mc.getWindow().getScaledWidth() / 2 - width / 2; int y = mc.getWindow().getScaledHeight() - ConfigHandler.CLIENT.manaBarHeight.get(); - if(!hasCreative) { - if(totalMaxMana == 0) + if (!hasCreative) { + if (totalMaxMana == 0) { width = 0; - else width *= (double) totalMana / (double) totalMaxMana; + } else { + width *= (double) totalMana / (double) totalMaxMana; + } } - if(width == 0) { - if(totalMana > 0) + if (width == 0) { + if (totalMana > 0) { width = 1; - else return; + } else { + return; + } } int color = MathHelper.hsvToRGB(0.55F, (float) Math.min(1F, Math.sin(Util.milliTime() / 200D) * 0.5 + 1F), 1F); @@ -267,7 +279,7 @@ public final class HUDHandler { profiler.startSection("poolRecipe"); RecipeManaInfusion recipe = TilePool.getMatchingRecipe(stack, tile.getWorld().getBlockState(tile.getPos().down())); - if(recipe != null) { + if (recipe != null) { int x = mc.getWindow().getScaledWidth() / 2 - 11; int y = mc.getWindow().getScaledHeight() / 2 + 10; @@ -297,7 +309,7 @@ public final class HUDHandler { profiler.startSection("crystalCube"); ItemStack target = tile.getRequestTarget(); - if(!target.isEmpty()) { + if (!target.isEmpty()) { String s1 = target.getDisplayName().getString(); String s2 = tile.getItemCount() + "x"; int strlen = Math.max(mc.fontRenderer.getStringWidth(s1), mc.fontRenderer.getStringWidth(s2)); @@ -309,8 +321,9 @@ public final class HUDHandler { mc.fontRenderer.drawStringWithShadow(s1, w / 2 + 30, h / 2 - 10, 0x6666FF); mc.fontRenderer.drawStringWithShadow(tile.getItemCount() + "x", w / 2 + 30, h / 2, 0xFFFFFF); - if(tile.locked) + if (tile.locked) { mc.fontRenderer.drawStringWithShadow(I18n.format("botaniamisc.locked"), w / 2 + 30, h / 2 + 10, 0xFFAA00); + } RenderSystem.enableRescaleNormal(); mc.getItemRenderer().renderItemAndEffectIntoGUI(target, w / 2 + 10, h / 2 - 10); } @@ -352,7 +365,7 @@ public final class HUDHandler { renderManaBar(x, y, color, mana < 0 ? 0.5F : 1F, mana, maxMana); - if(mana < 0) { + if (mana < 0) { String text = I18n.format("botaniamisc.statusUnknown"); x = mc.getWindow().getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(text) / 2; y -= 1; @@ -374,7 +387,7 @@ public final class HUDHandler { mc.getItemRenderer().renderItemAndEffectIntoGUI(bindDisplay, x, y); RenderSystem.disableDepthTest(); - if(properlyBound) { + if (properlyBound) { mc.fontRenderer.drawStringWithShadow("\u2714", x + 10, y + 9, 0x004C00); mc.fontRenderer.drawStringWithShadow("\u2714", x + 10, y + 8, 0x0BD20D); } else { @@ -393,8 +406,9 @@ public final class HUDHandler { int manaPercentage = Math.max(0, (int) ((double) mana / (double) maxMana * 100)); - if(manaPercentage == 0 && mana > 0) + if (manaPercentage == 0 && mana > 0) { manaPercentage = 1; + } RenderHelper.drawTexturedModalRect(x + 1, y + 1, 0, 5, 100, 3); diff --git a/src/main/java/vazkii/botania/client/core/handler/ItemsRemainingRenderHandler.java b/src/main/java/vazkii/botania/client/core/handler/ItemsRemainingRenderHandler.java index 900355d0a..95117c8ca 100644 --- a/src/main/java/vazkii/botania/client/core/handler/ItemsRemainingRenderHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/ItemsRemainingRenderHandler.java @@ -1,24 +1,22 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 23, 2015, 9:22:10 PM (GMT)] */ package vazkii.botania.client.core.handler; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.RenderHelper; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import org.lwjgl.opengl.GL11; import java.util.regex.Pattern; @@ -34,7 +32,7 @@ public final class ItemsRemainingRenderHandler { @OnlyIn(Dist.CLIENT) public static void render(float partTicks) { - if(ticks > 0 && !stack.isEmpty()) { + if (ticks > 0 && !stack.isEmpty()) { int pos = maxTicks - ticks; Minecraft mc = Minecraft.getInstance(); int x = mc.getWindow().getScaledWidth() / 2 + 10 + Math.max(0, pos - leaveTicks); @@ -53,28 +51,33 @@ public final class ItemsRemainingRenderHandler { RenderSystem.translatef(xp, y, 0F); RenderSystem.scalef(alpha, 1F, 1F); mc.getItemRenderer().renderItemAndEffectIntoGUI(stack, 0, 0); - RenderSystem.scalef(1F / alpha,1F, 1F); + RenderSystem.scalef(1F / alpha, 1F, 1F); RenderSystem.translatef(-xp, -y, 0F); RenderSystem.color4f(1F, 1F, 1F, 1F); RenderSystem.enableBlend(); String text = ""; - if(customString == null) { - if(!stack.isEmpty()) { + if (customString == null) { + if (!stack.isEmpty()) { text = TextFormatting.GREEN + stack.getDisplayName().getString(); - if(count >= 0) { + if (count >= 0) { int max = stack.getMaxStackSize(); int stacks = count / max; int rem = count % max; - if(stacks == 0) + if (stacks == 0) { text = "" + count; - else text = count + " (" + TextFormatting.AQUA + stacks + TextFormatting.RESET + "*" + TextFormatting.GRAY + max + TextFormatting.RESET + "+" + TextFormatting.YELLOW + rem + TextFormatting.RESET + ")"; - } else if(count == -1) + } else { + text = count + " (" + TextFormatting.AQUA + stacks + TextFormatting.RESET + "*" + TextFormatting.GRAY + max + TextFormatting.RESET + "+" + TextFormatting.YELLOW + rem + TextFormatting.RESET + ")"; + } + } else if (count == -1) { text = "\u221E"; + } } - } else text = customString; + } else { + text = customString; + } int color = 0x00FFFFFF | (int) (alpha * 0xFF) << 24; mc.fontRenderer.drawStringWithShadow(text, x + 20, y + 6, color); @@ -86,8 +89,9 @@ public final class ItemsRemainingRenderHandler { @OnlyIn(Dist.CLIENT) public static void tick() { - if(ticks > 0) + if (ticks > 0) { --ticks; + } } public static void set(ItemStack stack, String str) { @@ -107,10 +111,11 @@ public final class ItemsRemainingRenderHandler { public static void set(PlayerEntity player, ItemStack displayStack, Pattern pattern) { int count = 0; - for(int i = 0; i < player.inventory.getSizeInventory(); i++) { + for (int i = 0; i < player.inventory.getSizeInventory(); i++) { ItemStack stack = player.inventory.getStackInSlot(i); - if(!stack.isEmpty() && pattern.matcher(stack.getTranslationKey()).find()) + if (!stack.isEmpty() && pattern.matcher(stack.getTranslationKey()).find()) { count += stack.getCount(); + } } set(displayStack, count); diff --git a/src/main/java/vazkii/botania/client/core/handler/KonamiHandler.java b/src/main/java/vazkii/botania/client/core/handler/KonamiHandler.java index ef179875a..e7bd7a8fd 100644 --- a/src/main/java/vazkii/botania/client/core/handler/KonamiHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/KonamiHandler.java @@ -1,6 +1,15 @@ +/* + * This class is 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 + */ package vazkii.botania.client.core.handler; import com.mojang.blaze3d.platform.GlStateManager; + import net.minecraft.client.Minecraft; import net.minecraft.client.audio.SimpleSound; import net.minecraft.client.resources.I18n; @@ -9,7 +18,9 @@ import net.minecraftforge.client.event.InputEvent; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import org.lwjgl.glfw.GLFW; + import vazkii.botania.common.core.handler.ModSounds; import vazkii.botania.common.item.ItemLexicon; import vazkii.botania.common.lib.LibMisc; @@ -63,7 +74,7 @@ public class KonamiHandler { @SubscribeEvent public static void renderBook(BookDrawScreenEvent evt) { - if(konamiTime > 0) { + if (konamiTime > 0) { String meme = I18n.format("botania.subtitle.way"); GlStateManager.disableDepthTest(); GlStateManager.pushMatrix(); diff --git a/src/main/java/vazkii/botania/client/core/handler/LayerTerraHelmet.java b/src/main/java/vazkii/botania/client/core/handler/LayerTerraHelmet.java index 89da20b04..2d617a769 100644 --- a/src/main/java/vazkii/botania/client/core/handler/LayerTerraHelmet.java +++ b/src/main/java/vazkii/botania/client/core/handler/LayerTerraHelmet.java @@ -1,7 +1,15 @@ +/* + * This class is 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 + */ package vazkii.botania.client.core.handler; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; + import net.minecraft.client.entity.player.AbstractClientPlayerEntity; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.entity.IEntityRenderer; @@ -9,17 +17,19 @@ import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.client.renderer.entity.model.PlayerModel; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ItemStack; + import vazkii.botania.common.item.equipment.armor.terrasteel.ItemTerrasteelHelm; public class LayerTerraHelmet extends LayerRenderer> { - public LayerTerraHelmet(IEntityRenderer> renderer) { - super(renderer); - } + public LayerTerraHelmet(IEntityRenderer> renderer) { + super(renderer); + } - @Override - public void render(MatrixStack ms, IRenderTypeBuffer buffers, int light, AbstractClientPlayerEntity player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) { - ItemStack helm = player.getItemStackFromSlot(EquipmentSlotType.HEAD); - if(!helm.isEmpty() && helm.getItem() instanceof ItemTerrasteelHelm) - ItemTerrasteelHelm.renderOnPlayer(ms, buffers, light, helm, player, partialTicks); - } + @Override + public void render(MatrixStack ms, IRenderTypeBuffer buffers, int light, AbstractClientPlayerEntity player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) { + ItemStack helm = player.getItemStackFromSlot(EquipmentSlotType.HEAD); + if (!helm.isEmpty() && helm.getItem() instanceof ItemTerrasteelHelm) { + ItemTerrasteelHelm.renderOnPlayer(ms, buffers, light, helm, player, partialTicks); + } + } } diff --git a/src/main/java/vazkii/botania/client/core/handler/LightningHandler.java b/src/main/java/vazkii/botania/client/core/handler/LightningHandler.java index 6c5167410..5bab902a4 100644 --- a/src/main/java/vazkii/botania/client/core/handler/LightningHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/LightningHandler.java @@ -1,17 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 3, 2014, 9:05:38 PM (GMT)] */ package vazkii.botania.client.core.handler; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.TextureManager; @@ -23,7 +21,9 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.fx.FXLightning; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.lib.LibMisc; @@ -71,7 +71,7 @@ public class LightningHandler { tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEXTURE_LIGHT_COLOR); for (FXLightning bolt : queuedLightningBolts) { bolt.renderBolt(0, false); - if(counter % BATCH_THRESHOLD == BATCH_THRESHOLD - 1) { + if (counter % BATCH_THRESHOLD == BATCH_THRESHOLD - 1) { tessellator.draw(); tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEXTURE_LIGHT_COLOR); } @@ -85,7 +85,7 @@ public class LightningHandler { tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEXTURE_LIGHT_COLOR); for (FXLightning bolt : queuedLightningBolts) { bolt.renderBolt(1, true); - if(counter % BATCH_THRESHOLD == BATCH_THRESHOLD - 1) { + if (counter % BATCH_THRESHOLD == BATCH_THRESHOLD - 1) { tessellator.draw(); tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEXTURE_LIGHT_COLOR); } @@ -105,4 +105,4 @@ public class LightningHandler { profiler.endSection(); } -} \ No newline at end of file +} 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 d4fa61864..8a71268df 100644 --- a/src/main/java/vazkii/botania/client/core/handler/MiscellaneousIcons.java +++ b/src/main/java/vazkii/botania/client/core/handler/MiscellaneousIcons.java @@ -1,6 +1,6 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @@ -8,37 +8,29 @@ */ package vazkii.botania.client.core.handler; -import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.model.Material; import net.minecraft.client.renderer.model.ModelBakery; import net.minecraft.client.renderer.model.ModelResourceLocation; -import net.minecraft.client.renderer.model.ModelRotation; import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.fluid.Fluids; -import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.ModelBakeEvent; import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.eventbus.api.SubscribeEvent; -import vazkii.botania.client.model.FloatingFlowerModel; + import vazkii.botania.client.model.GunModel; import vazkii.botania.client.model.LexiconModel; import vazkii.botania.client.model.PlatformModel; import vazkii.botania.client.render.tile.RenderTileCorporeaCrystalCube; import vazkii.botania.client.render.tile.RenderTilePump; import vazkii.botania.common.Botania; -import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.bauble.ItemFlightTiara; import vazkii.botania.common.item.relic.ItemKingKey; -import vazkii.botania.common.lib.LibMisc; import vazkii.botania.common.lib.LibObfuscation; import java.lang.invoke.MethodHandle; -import java.util.Map; import java.util.Set; import static vazkii.botania.common.lib.ResourceLocationHelper.prefix; @@ -47,24 +39,23 @@ public class MiscellaneousIcons { private static final MethodHandle MATERIALS = LibObfuscation.getGetter(ModelBakery.class, "field_177602_b"); public static final MiscellaneousIcons INSTANCE = new MiscellaneousIcons(); - public TextureAtlasSprite - alfPortalTex, - lightRelayWorldIcon, - lightRelayWorldIconRed, - lightRelayWorldIconGreen, - lightRelayWorldIconPurple, - alchemyCatalystOverlay, - conjurationCatalystOverlay, - enchanterOverlay, - manaVoidOverlay, - manaWater, - terraPlateOverlay, - corporeaWorldIcon, - corporeaWorldIconMaster, - corporeaIconStar, - sparkWorldIcon, - manaDetectorIcon, - runeAltarTriggerIcon; + public TextureAtlasSprite alfPortalTex, + lightRelayWorldIcon, + lightRelayWorldIconRed, + lightRelayWorldIconGreen, + lightRelayWorldIconPurple, + alchemyCatalystOverlay, + conjurationCatalystOverlay, + enchanterOverlay, + manaVoidOverlay, + manaWater, + terraPlateOverlay, + corporeaWorldIcon, + corporeaWorldIconMaster, + corporeaIconStar, + sparkWorldIcon, + manaDetectorIcon, + runeAltarTriggerIcon; public final TextureAtlasSprite[] sparkUpgradeIcons = new TextureAtlasSprite[4]; // public final Map manaLevelTriggerIcons = new EnumMap<>(TriggerManaLevel.State.class); @@ -74,22 +65,21 @@ public class MiscellaneousIcons { public TextureAtlasSprite tailIcon = null; public IBakedModel goldfishModel, - phiFlowerModel, - nerfBatModel, - bloodPendantChain, - bloodPendantGem, - snowflakePendantGem, - itemFinderGem, - pyroclastGem, - crimsonGem, - cirrusGem, - nimbusGem, - terrasteelHelmWillModel, - elvenSpreaderInside, - gaiaSpreaderInside, - manaSpreaderInside, - redstoneSpreaderInside - ; + phiFlowerModel, + nerfBatModel, + bloodPendantChain, + bloodPendantGem, + snowflakePendantGem, + itemFinderGem, + pyroclastGem, + crimsonGem, + cirrusGem, + nimbusGem, + terrasteelHelmWillModel, + elvenSpreaderInside, + gaiaSpreaderInside, + manaSpreaderInside, + redstoneSpreaderInside; public final IBakedModel[] kingKeyWeaponModels = new IBakedModel[ItemKingKey.WEAPON_TYPES]; @@ -183,11 +173,12 @@ public class MiscellaneousIcons { tiaraWingIcons[i] = evt.getModelRegistry().get(prefix("icon/tiara_wing_" + (i + 1))); } } - + @SubscribeEvent public void onTextureStitchPre(TextureStitchEvent.Pre evt) { - if(!evt.getMap().getId().equals(AtlasTexture.LOCATION_BLOCKS_TEXTURE)) + if (!evt.getMap().getId().equals(AtlasTexture.LOCATION_BLOCKS_TEXTURE)) { return; + } evt.addSprite(prefix("blocks/alfheim_portal_swirl")); evt.addSprite(prefix("blocks/alfheim_portal_swirl")); @@ -206,7 +197,7 @@ public class MiscellaneousIcons { evt.addSprite(prefix("items/spark_corporea_star")); evt.addSprite(prefix("items/spark")); - for(int i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) { evt.addSprite(prefix("items/spark_upgrade_rune_" + i)); } @@ -215,7 +206,7 @@ public class MiscellaneousIcons { /* evt.addSprite(prefix("items/triggers/mana_detector")); evt.addSprite(prefix("items/triggers/rune_altar_can_craft")); - + for (TriggerManaLevel.State s : TriggerManaLevel.State.values()) { register(evt.getMap(), "items/triggers/mana" + WordUtils.capitalizeFully(s.name())); } @@ -224,8 +215,9 @@ public class MiscellaneousIcons { @SubscribeEvent public void onTextureStitchPost(TextureStitchEvent.Post evt) { - if(!evt.getMap().getId().equals(AtlasTexture.LOCATION_BLOCKS_TEXTURE)) + if (!evt.getMap().getId().equals(AtlasTexture.LOCATION_BLOCKS_TEXTURE)) { return; + } alfPortalTex = get(evt.getMap(), "blocks/alfheim_portal_swirl"); lightRelayWorldIcon = get(evt.getMap(), "blocks/luminizer"); @@ -243,7 +235,7 @@ public class MiscellaneousIcons { corporeaIconStar = get(evt.getMap(), "items/spark_corporea_star"); sparkWorldIcon = get(evt.getMap(), "items/spark"); - for(int i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) { sparkUpgradeIcons[i] = get(evt.getMap(), "items/spark_upgrade_rune_" + i); } @@ -252,7 +244,7 @@ public class MiscellaneousIcons { /* manaDetectorIcon = get(evt.getMap(), "items/triggers/mana_detector"); runeAltarTriggerIcon = get(evt.getMap(), "items/triggers/rune_altar_can_craft"); - + for (TriggerManaLevel.State s : TriggerManaLevel.State.values()) { manaLevelTriggerIcons.put(s, get(evt.getMap(), "items/triggers/mana" + WordUtils.capitalizeFully(s.name()))); } diff --git a/src/main/java/vazkii/botania/client/core/handler/ModelHandler.java b/src/main/java/vazkii/botania/client/core/handler/ModelHandler.java index 5cf706f38..539dd9c96 100644 --- a/src/main/java/vazkii/botania/client/core/handler/ModelHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/ModelHandler.java @@ -1,6 +1,6 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @@ -9,24 +9,23 @@ package vazkii.botania.client.core.handler; import com.mojang.datafixers.util.Pair; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.entity.ItemRenderer; import net.minecraft.client.renderer.entity.SpriteRenderer; import net.minecraft.client.renderer.model.ModelResourceLocation; -import net.minecraft.util.ResourceLocation; import net.minecraft.util.registry.Registry; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.client.model.ModelLoaderRegistry; -import net.minecraftforge.client.model.animation.TileEntityRendererAnimation; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.client.registry.RenderingRegistry; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.api.BotaniaAPIClient; import vazkii.botania.api.item.IFloatingFlower; -import vazkii.botania.api.subtile.TileEntitySpecialFlower; import vazkii.botania.client.model.FloatingFlowerModel; import vazkii.botania.client.render.entity.RenderBabylonWeapon; import vazkii.botania.client.render.entity.RenderCorporeaSpark; @@ -65,7 +64,6 @@ import vazkii.botania.common.block.tile.mana.TilePool; import vazkii.botania.common.block.tile.mana.TilePrism; import vazkii.botania.common.block.tile.mana.TilePump; import vazkii.botania.common.block.tile.mana.TileSpreader; -import vazkii.botania.common.block.tile.string.TileRedString; import vazkii.botania.common.block.tile.string.TileRedStringComparator; import vazkii.botania.common.block.tile.string.TileRedStringContainer; import vazkii.botania.common.block.tile.string.TileRedStringDispenser; @@ -96,8 +94,8 @@ import static vazkii.botania.common.lib.ResourceLocationHelper.prefix; @Mod.EventBusSubscriber(value = Dist.CLIENT, modid = LibMisc.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) public final class ModelHandler { - static boolean registeredModels = false; - + static boolean registeredModels = false; + @SubscribeEvent public static void registerModels(ModelRegistryEvent evt) { registeredModels = true; diff --git a/src/main/java/vazkii/botania/client/core/handler/PersistentVariableHelper.java b/src/main/java/vazkii/botania/client/core/handler/PersistentVariableHelper.java index d02c27eb3..63ca4ace3 100644 --- a/src/main/java/vazkii/botania/client/core/handler/PersistentVariableHelper.java +++ b/src/main/java/vazkii/botania/client/core/handler/PersistentVariableHelper.java @@ -1,24 +1,20 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 24, 2015, 5:54:45 PM (GMT)] */ package vazkii.botania.client.core.handler; import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompressedStreamTools; -import vazkii.botania.common.lib.LibMisc; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; -import java.util.Set; public final class PersistentVariableHelper { @@ -50,8 +46,9 @@ public final class PersistentVariableHelper { } private static File getCacheFile() throws IOException { - if(!cacheFile.exists()) + if (!cacheFile.exists()) { cacheFile.createNewFile(); + } return cacheFile; } @@ -61,12 +58,13 @@ public final class PersistentVariableHelper { } private static CompoundNBT getCacheCompound(File cache) throws IOException { - if(cache == null) + if (cache == null) { throw new RuntimeException("No cache file!"); + } try { return CompressedStreamTools.readCompressed(new FileInputStream(cache)); - } catch(IOException e) { + } catch (IOException e) { CompoundNBT cmp = new CompoundNBT(); CompressedStreamTools.writeCompressed(cmp, new FileOutputStream(cache)); return getCacheCompound(cache); @@ -76,7 +74,7 @@ public final class PersistentVariableHelper { private static void injectNBTToFile(CompoundNBT cmp, File f) { try { CompressedStreamTools.writeCompressed(cmp, new FileOutputStream(f)); - } catch(IOException e) { + } catch (IOException e) { e.printStackTrace(); } } diff --git a/src/main/java/vazkii/botania/client/core/handler/RenderLexicon.java b/src/main/java/vazkii/botania/client/core/handler/RenderLexicon.java index babcc077c..35453f2d4 100644 --- a/src/main/java/vazkii/botania/client/core/handler/RenderLexicon.java +++ b/src/main/java/vazkii/botania/client/core/handler/RenderLexicon.java @@ -1,8 +1,17 @@ +/* + * This class is 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 + */ package vazkii.botania.client.core.handler; import com.google.common.base.Joiner; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.Minecraft; import net.minecraft.client.entity.player.AbstractClientPlayerEntity; import net.minecraft.client.gui.FontRenderer; @@ -26,6 +35,7 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.RenderHandEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.Botania; import vazkii.botania.common.core.handler.ConfigHandler; @@ -62,11 +72,12 @@ public class RenderLexicon { @SubscribeEvent public static void renderItem(RenderHandEvent evt) { Minecraft mc = Minecraft.getInstance(); - if(!ConfigHandler.CLIENT.lexicon3dModel.get() + if (!ConfigHandler.CLIENT.lexicon3dModel.get() || mc.gameSettings.thirdPersonView != 0 || mc.player.getHeldItem(evt.getHand()).isEmpty() - || mc.player.getHeldItem(evt.getHand()).getItem() != ModItems.lexicon) + || mc.player.getHeldItem(evt.getHand()).getItem() != ModItems.lexicon) { return; + } evt.setCanceled(true); try { renderFirstPersonItem(mc.player, evt.getPartialTicks(), evt.getInterpolatedPitch(), evt.getHand(), evt.getSwingProgress(), evt.getItemStack(), evt.getEquipProgress(), evt.getMatrixStack(), evt.getBuffers(), evt.getLight()); @@ -83,11 +94,11 @@ public class RenderLexicon { { boolean flag3 = handside == HandSide.RIGHT; { - float f5 = -0.4F * MathHelper.sin(MathHelper.sqrt(swingProgress) * (float)Math.PI); - float f6 = 0.2F * MathHelper.sin(MathHelper.sqrt(swingProgress) * ((float)Math.PI * 2F)); - float f10 = -0.2F * MathHelper.sin(swingProgress * (float)Math.PI); + float f5 = -0.4F * MathHelper.sin(MathHelper.sqrt(swingProgress) * (float) Math.PI); + float f6 = 0.2F * MathHelper.sin(MathHelper.sqrt(swingProgress) * ((float) Math.PI * 2F)); + float f10 = -0.2F * MathHelper.sin(swingProgress * (float) Math.PI); int l = flag3 ? 1 : -1; - ms.translate((double)((float)l * f5), (double)f6, (double)f10); + ms.translate((double) ((float) l * f5), (double) f6, (double) f10); try { APPLY_EQUIP_OFFSET.invokeExact(Minecraft.getInstance().getFirstPersonRenderer(), ms, handside, equipProgress); APPLY_SWING_OFFSET.invokeExact(Minecraft.getInstance().getFirstPersonRenderer(), ms, handside, swingProgress); @@ -108,11 +119,13 @@ public class RenderLexicon { ms.push(); float ticks = ClientTickHandler.ticksWithLexicaOpen; - if(ticks > 0 && ticks < 10) { - if(Minecraft.getInstance().currentScreen instanceof GuiBook - && ((GuiBook) Minecraft.getInstance().currentScreen).book.getBookItem().getItem() == ModItems.lexicon) + if (ticks > 0 && ticks < 10) { + if (Minecraft.getInstance().currentScreen instanceof GuiBook + && ((GuiBook) Minecraft.getInstance().currentScreen).book.getBookItem().getItem() == ModItems.lexicon) { ticks += partialTicks; - else ticks -= partialTicks; + } else { + ticks -= partialTicks; + } } if (side == HandSide.RIGHT) { @@ -126,8 +139,9 @@ public class RenderLexicon { float opening = MathHelper.clamp(ticks / 12F, 0, 1); float pageFlipTicks = ClientTickHandler.pageFlipTicks; - if(pageFlipTicks > 0) + if (pageFlipTicks > 0) { pageFlipTicks -= ClientTickHandler.partialTicks; + } float pageFlip = pageFlipTicks / 5F; @@ -139,7 +153,7 @@ public class RenderLexicon { IVertexBuilder buffer = mat.getVertexConsumer(buffers, RenderType::getEntitySolid); model.render(ms, buffer, light, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1); - if(ticks < 3) { + if (ticks < 3) { FontRenderer font = Minecraft.getInstance().fontRenderer; ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(180F)); ms.translate(-0.30F, -0.24F, -0.07F); @@ -153,8 +167,9 @@ public class RenderLexicon { String edition = TextFormatting.ITALIC + "" + TextFormatting.BOLD + ItemLexicon.getEdition(); font.draw(edition, 0, 0, 0xA07100, false, ms.peek().getModel(), buffers, false, 0, light); - if(quote == -1) + if (quote == -1) { quote = mc.world.rand.nextInt(QUOTES.length); + } String quoteStr = QUOTES[quote]; @@ -191,17 +206,17 @@ public class RenderLexicon { List> lines = new ArrayList<>(); String controlCodes; - for(String s : textEntries) { + for (String s : textEntries) { List words = new ArrayList<>(); String lineStr = ""; String[] tokens = s.split(" "); - for(String token : tokens) { + for (String token : tokens) { String prev = lineStr; String spaced = token + " "; lineStr += spaced; controlCodes = toControlCodes(getControlCodes(prev)); - if(font.getStringWidth(lineStr) > width) { + if (font.getStringWidth(lineStr) > width) { lines.add(words); lineStr = controlCodes + spaced; words = new ArrayList<>(); @@ -210,20 +225,21 @@ public class RenderLexicon { words.add(controlCodes + token); } - if(!lineStr.isEmpty()) + if (!lineStr.isEmpty()) { lines.add(words); + } lines.add(new ArrayList<>()); } int i = 0; - for(List words : lines) { + for (List words : lines) { int xi = x; int spacing = 4; int wcount = words.size(); int compensationSpaces = 0; boolean justify = ConfigHandler.CLIENT.lexiconJustifiedText.get() && wcount > 0 && lines.size() > i && !lines.get(i + 1).isEmpty(); - if(justify) { + if (justify) { String s = Joiner.on("").join(words); int swidth = font.getStringWidth(s); int space = width - swidth; @@ -232,9 +248,9 @@ public class RenderLexicon { compensationSpaces = wcount == 1 ? 0 : space % (wcount - 1); } - for(String s : words) { + for (String s : words) { int extra = 0; - if(compensationSpaces > 0) { + if (compensationSpaces > 0) { compensationSpaces--; extra++; } diff --git a/src/main/java/vazkii/botania/client/core/handler/SplashHandler.java b/src/main/java/vazkii/botania/client/core/handler/SplashHandler.java index ec5742866..0cc26a776 100644 --- a/src/main/java/vazkii/botania/client/core/handler/SplashHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/SplashHandler.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [2020-01-14, 01:26 (UTC+2)] */ package vazkii.botania.client.core.handler; @@ -22,10 +20,12 @@ import net.minecraftforge.client.event.ParticleFactoryRegisterEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; + import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.List; @Mod.EventBusSubscriber(value = Dist.CLIENT, modid = LibMisc.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) @@ -47,8 +47,9 @@ public class SplashHandler { @Override protected void apply(@Nonnull Unit unused, @Nonnull IResourceManager resourceManager, @Nonnull IProfiler profiler) { - if (!ConfigHandler.CLIENT.splashesEnabled.get()) + if (!ConfigHandler.CLIENT.splashesEnabled.get()) { return; + } Splashes splashes = Minecraft.getInstance().getSplashes(); List splashList = ObfuscationReflectionHelper.getPrivateValue(Splashes.class, splashes, "field_215280_c"); //possibleSplashes diff --git a/src/main/java/vazkii/botania/client/core/handler/TooltipAdditionDisplayHandler.java b/src/main/java/vazkii/botania/client/core/handler/TooltipAdditionDisplayHandler.java index 526942e89..e1ae5050a 100644 --- a/src/main/java/vazkii/botania/client/core/handler/TooltipAdditionDisplayHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/TooltipAdditionDisplayHandler.java @@ -1,17 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 23, 2015, 4:24:56 PM (GMT)] */ package vazkii.botania.client.core.handler; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.client.gui.AbstractGui; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.resources.I18n; @@ -21,7 +19,9 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.RenderTooltipEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.mana.IManaTooltipDisplay; import vazkii.botania.common.item.equipment.tool.terrasteel.ItemTerraPick; import vazkii.botania.common.lib.LibMisc; @@ -31,8 +31,9 @@ public final class TooltipAdditionDisplayHandler { @SubscribeEvent public static void onToolTipRender(RenderTooltipEvent.PostText evt) { - if(evt.getStack().isEmpty()) + if (evt.getStack().isEmpty()) { return; + } ItemStack stack = evt.getStack(); int width = evt.getWidth(); @@ -41,10 +42,11 @@ public final class TooltipAdditionDisplayHandler { int tooltipY = evt.getY() - 4; FontRenderer font = evt.getFontRenderer(); - if(stack.getItem() instanceof ItemTerraPick) + if (stack.getItem() instanceof ItemTerraPick) { drawTerraPick(stack, tooltipX, tooltipY, width, height, font); - else if(stack.getItem() instanceof IManaTooltipDisplay) + } else if (stack.getItem() instanceof IManaTooltipDisplay) { drawManaBar(stack, (IManaTooltipDisplay) stack.getItem(), tooltipX, tooltipY, width, height); + } } private static void drawTerraPick(ItemStack stack, int mouseX, int mouseY, int width, int height, FontRenderer font) { @@ -59,8 +61,9 @@ public final class TooltipAdditionDisplayHandler { RenderSystem.disableDepthTest(); AbstractGui.fill(mouseX - 1, mouseY - height - 1, mouseX + width + 1, mouseY, 0xFF000000); - for(int i = 0; i < rainbowWidth; i++) + for (int i = 0; i < rainbowWidth; i++) { AbstractGui.fill(mouseX + i, mouseY - height, mouseX + i + 1, mouseY, MathHelper.hsvToRGB(hueOff + huePer * i, 1F, 1F)); + } AbstractGui.fill(mouseX + rainbowWidth, mouseY - height, mouseX + width, mouseY, 0xFF555555); String rank = I18n.format("botania.rank" + level).replaceAll("&", "\u00a7"); @@ -68,7 +71,7 @@ public final class TooltipAdditionDisplayHandler { GL11.glPushAttrib(GL11.GL_LIGHTING_BIT); RenderSystem.disableLighting(); font.drawStringWithShadow(rank, mouseX, mouseY - 12, 0xFFFFFF); - if(!ss) { + if (!ss) { rank = I18n.format("botania.rank" + (level + 1)).replaceAll("&", "\u00a7"); font.drawStringWithShadow(rank, mouseX + width - font.getStringWidth(rank), mouseY - 12, 0xFFFFFF); } diff --git a/src/main/java/vazkii/botania/client/core/handler/TooltipHandler.java b/src/main/java/vazkii/botania/client/core/handler/TooltipHandler.java index e5467fb05..82898a79b 100644 --- a/src/main/java/vazkii/botania/client/core/handler/TooltipHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/TooltipHandler.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 26, 2014, 2:33:04 AM (GMT)] */ package vazkii.botania.client.core.handler; @@ -16,6 +14,7 @@ import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.item.ItemKeepIvy; import vazkii.botania.common.lib.LibMisc; @@ -25,8 +24,9 @@ public final class TooltipHandler { @SubscribeEvent(priority = EventPriority.HIGHEST) public static void onTooltipEvent(ItemTooltipEvent event) { - if(event.getItemStack().hasTag() && ItemNBTHelper.getBoolean(event.getItemStack(), ItemKeepIvy.TAG_KEEP, false)) + if (event.getItemStack().hasTag() && ItemNBTHelper.getBoolean(event.getItemStack(), ItemKeepIvy.TAG_KEEP, false)) { event.getToolTip().add(new TranslationTextComponent("botaniamisc.hasKeepIvy")); + } } } diff --git a/src/main/java/vazkii/botania/client/core/helper/IconHelper.java b/src/main/java/vazkii/botania/client/core/helper/IconHelper.java index 7a298c300..9731223b6 100644 --- a/src/main/java/vazkii/botania/client/core/helper/IconHelper.java +++ b/src/main/java/vazkii/botania/client/core/helper/IconHelper.java @@ -1,23 +1,18 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 14, 2014, 5:28:21 PM (GMT)] */ package vazkii.botania.client.core.helper; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; -import net.minecraft.client.renderer.BufferBuilder; + import net.minecraft.client.renderer.Matrix4f; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import org.lwjgl.opengl.GL11; public final class IconHelper { /** @@ -31,4 +26,4 @@ public final class IconHelper { buffer.vertex(mat, x + width, y, 0).color(1, 1, 1, alpha).texture(icon.getMaxU(), icon.getMinV()).light(fullbright).endVertex(); buffer.vertex(mat, x, y, 0).color(1, 1, 1, alpha).texture(icon.getMinU(), icon.getMinV()).light(fullbright).endVertex(); } -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/client/core/helper/RenderHelper.java b/src/main/java/vazkii/botania/client/core/helper/RenderHelper.java index 42fd33fe8..7e3e44f32 100644 --- a/src/main/java/vazkii/botania/client/core/helper/RenderHelper.java +++ b/src/main/java/vazkii/botania/client/core/helper/RenderHelper.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 19, 2014, 5:40:38 PM (GMT)] */ package vazkii.botania.client.core.helper; @@ -14,6 +12,7 @@ import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.AbstractGui; @@ -40,16 +39,18 @@ import net.minecraft.util.Direction; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.internal.ShaderCallback; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.render.tile.RenderTilePylon; import vazkii.botania.common.item.equipment.bauble.ItemFlightTiara; -import vazkii.botania.common.lib.LibMisc; import vazkii.botania.common.lib.LibObfuscation; import javax.annotation.Nullable; + import java.lang.invoke.MethodHandle; import java.util.Arrays; import java.util.List; @@ -183,8 +184,9 @@ public final class RenderHelper { IVertexBuilder buffer = buffers.getBuffer(STAR); float ticks = (ClientTickHandler.ticksInGame % 200) + ClientTickHandler.partialTicks; - if (ticks >= 100) + if (ticks >= 100) { ticks = 200 - ticks - 1; + } float f1 = ticks / 200F; float f2 = f1 > 0.F ? (f1 - 0.7F) / 0.2F : 0; @@ -269,7 +271,7 @@ public final class RenderHelper { buf.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR); buf.vertex(centerX, centerY, 0).color(0, 0.5F, 0.5F, a).endVertex(); - for(int i = degs; i > 0; i--) { + for (int i = degs; i > 0; i--) { double rad = (i - 90) / 180F * Math.PI; buf.vertex(centerX + Math.cos(rad) * r, centerY + Math.sin(rad) * r, 0).color(0F, 1F, 0.5F, a).endVertex(); } @@ -286,11 +288,12 @@ public final class RenderHelper { public static String getKeyDisplayString(String keyName) { String key = null; KeyBinding[] keys = Minecraft.getInstance().gameSettings.keyBindings; - for(KeyBinding otherKey : keys) - if(otherKey.getKeyDescription().equals(keyName)) { + for (KeyBinding otherKey : keys) { + if (otherKey.getKeyDescription().equals(keyName)) { key = otherKey.getLocalizedName(); break; } + } return key; } @@ -327,25 +330,25 @@ public final class RenderHelper { Random random = new Random(); long i = 42L; - for(Direction direction : Direction.values()) { + for (Direction direction : Direction.values()) { random.setSeed(42L); - renderBakedItemQuads(ms, buffer, color, model.getQuads((BlockState)null, direction, random), stack, light, overlay); + renderBakedItemQuads(ms, buffer, color, model.getQuads((BlockState) null, direction, random), stack, light, overlay); } random.setSeed(42L); - renderBakedItemQuads(ms, buffer, color, model.getQuads((BlockState)null, (Direction)null, random), stack, light, overlay); + renderBakedItemQuads(ms, buffer, color, model.getQuads((BlockState) null, (Direction) null, random), stack, light, overlay); } // [VanillaCopy] ItemRenderer, with custom color + alpha support private static void renderBakedItemQuads(MatrixStack ms, IVertexBuilder buffer, int color, List quads, ItemStack stack, int light, int overlay) { MatrixStack.Entry matrixstack$entry = ms.peek(); - for(BakedQuad bakedquad : quads) { + for (BakedQuad bakedquad : quads) { int i = color; - float f = (float)(i >> 16 & 255) / 255.0F; - float f1 = (float)(i >> 8 & 255) / 255.0F; - float f2 = (float)(i & 255) / 255.0F; + float f = (float) (i >> 16 & 255) / 255.0F; + float f1 = (float) (i >> 8 & 255) / 255.0F; + float f2 = (float) (i & 255) / 255.0F; float alpha = ((color >> 24) & 0xFF) / 255.0F; buffer.addVertexData(matrixstack$entry, bakedquad, f, f1, f2, alpha, light, overlay, true); } diff --git a/src/main/java/vazkii/botania/client/core/helper/ShaderHelper.java b/src/main/java/vazkii/botania/client/core/helper/ShaderHelper.java index 4aa6a1d3f..0e802d4bd 100644 --- a/src/main/java/vazkii/botania/client/core/helper/ShaderHelper.java +++ b/src/main/java/vazkii/botania/client/core/helper/ShaderHelper.java @@ -1,17 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 9, 2014, 11:20:26 PM (GMT)] */ package vazkii.botania.client.core.helper; import com.mojang.blaze3d.platform.GlStateManager; -import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.client.Minecraft; import net.minecraft.client.shader.IShaderManager; import net.minecraft.client.shader.ShaderLinkHelper; @@ -21,8 +19,9 @@ import net.minecraft.resources.IResourceManager; import net.minecraft.resources.IResourceManagerReloadListener; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.ModList; -import org.lwjgl.opengl.GL11; + import org.lwjgl.system.MemoryUtil; + import vazkii.botania.api.internal.ShaderCallback; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.lib.LibResources; @@ -60,10 +59,11 @@ public final class ShaderHelper { this.fragmentShaderPath = fragmentShaderPath; } } + // Scratch buffer to use for uniforms public static final FloatBuffer FLOAT_BUF = MemoryUtil.memAllocFloat(1); private static final Map PROGRAMS = new EnumMap<>(BotaniaShader.class); - + private static boolean hasIncompatibleMods = false; private static boolean checkedIncompatibility = false; @@ -71,7 +71,7 @@ public final class ShaderHelper { public static void initShaders() { // Can be null when running datagenerators due to the unfortunate time we call this if (Minecraft.getInstance() != null - && Minecraft.getInstance().getResourceManager() instanceof IReloadableResourceManager) { + && Minecraft.getInstance().getResourceManager() instanceof IReloadableResourceManager) { ((IReloadableResourceManager) Minecraft.getInstance().getResourceManager()).addReloadListener( (IResourceManagerReloadListener) manager -> { PROGRAMS.values().forEach(ShaderLinkHelper::deleteShader); @@ -82,8 +82,9 @@ public final class ShaderHelper { } private static void loadShaders(IResourceManager manager) { - if(!useShaders()) + if (!useShaders()) { return; + } for (BotaniaShader shader : BotaniaShader.values()) { createProgram(manager, shader); @@ -97,22 +98,25 @@ public final class ShaderHelper { public static void useShader(BotaniaShader shader, ShaderCallback callback) { ShaderProgram prog = PROGRAMS.get(shader); - if(prog == null) + if (prog == null) { return; + } useShader(prog.getProgram(), callback); } public static void useShader(int shader, ShaderCallback callback) { - if(!useShaders()) + if (!useShaders()) { return; + } ShaderLinkHelper.useProgram(shader); int time = GlStateManager.getUniformLocation(shader, "time"); GlStateManager.uniform1(time, ClientTickHandler.ticksInGame); - if(callback != null) + if (callback != null) { callback.call(shader); + } } public static void useShader(BotaniaShader shader) { @@ -126,13 +130,13 @@ public final class ShaderHelper { public static boolean useShaders() { return ConfigHandler.CLIENT.useShaders.get() && checkIncompatibleMods(); } - + private static boolean checkIncompatibleMods() { - if(!checkedIncompatibility) { + if (!checkedIncompatibility) { hasIncompatibleMods = ModList.get().isLoaded("optifine"); checkedIncompatibility = true; } - + return !hasIncompatibleMods; } diff --git a/src/main/java/vazkii/botania/client/core/helper/ShaderWrappedRenderLayer.java b/src/main/java/vazkii/botania/client/core/helper/ShaderWrappedRenderLayer.java index 32e4b1850..db472c736 100644 --- a/src/main/java/vazkii/botania/client/core/helper/ShaderWrappedRenderLayer.java +++ b/src/main/java/vazkii/botania/client/core/helper/ShaderWrappedRenderLayer.java @@ -1,10 +1,20 @@ +/* + * This class is 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 + */ package vazkii.botania.client.core.helper; import net.minecraft.client.renderer.RenderType; + import vazkii.botania.api.internal.ShaderCallback; import vazkii.botania.client.lib.LibResources; import javax.annotation.Nullable; + import java.util.Objects; import java.util.Optional; @@ -12,8 +22,7 @@ public class ShaderWrappedRenderLayer extends RenderType { private final RenderType delegate; private final ShaderHelper.BotaniaShader shader; - @Nullable - private final ShaderCallback cb; + @Nullable private final ShaderCallback cb; public ShaderWrappedRenderLayer(ShaderHelper.BotaniaShader shader, @Nullable ShaderCallback cb, RenderType delegate) { super(LibResources.PREFIX_MOD + delegate.toString() + "_with_" + shader.name(), delegate.getVertexFormat(), delegate.getDrawMode(), delegate.getExpectedBufferSize(), delegate.func_228665_s_(), true, diff --git a/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java b/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java index 0e079f30b..9a824b5fa 100644 --- a/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java +++ b/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 13, 2014, 7:46:05 PM (GMT)] */ package vazkii.botania.client.core.proxy; import com.google.common.collect.ImmutableList; + import net.minecraft.block.FlowerBlock; import net.minecraft.block.TallFlowerBlock; import net.minecraft.client.Minecraft; @@ -30,13 +29,14 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.registry.Registry; import net.minecraft.world.World; import net.minecraftforge.client.settings.KeyConflictContext; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.DeferredWorkQueue; import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; + import org.lwjgl.glfw.GLFW; + import vazkii.botania.api.boss.IBotaniaBoss; import vazkii.botania.client.core.handler.BaubleRenderHandler; import vazkii.botania.client.core.handler.BossBarHandler; @@ -49,15 +49,10 @@ import vazkii.botania.client.core.handler.PersistentVariableHelper; import vazkii.botania.client.core.helper.ShaderHelper; import vazkii.botania.client.fx.FXLightning; import vazkii.botania.common.Botania; -import vazkii.botania.common.block.BlockModDoubleFlower; -import vazkii.botania.common.block.BlockModFlower; -import vazkii.botania.common.block.BlockSpecialFlower; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.ModFluffBlocks; import vazkii.botania.common.block.decor.BlockFloatingFlower; import vazkii.botania.common.block.decor.BlockModMushroom; -import vazkii.botania.common.block.decor.BlockShinyFlower; -import vazkii.botania.common.block.decor.panes.BlockModPane; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.core.proxy.IProxy; @@ -112,12 +107,14 @@ public class ClientProxy implements IProxy { Botania.LOGGER.fatal("Persistent Variables couldn't load!!"); } - if(ConfigHandler.CLIENT.enableSeasonalFeatures.get()) { + if (ConfigHandler.CLIENT.enableSeasonalFeatures.get()) { LocalDateTime now = LocalDateTime.now(); - if (now.getMonth() == Month.DECEMBER && now.getDayOfMonth() >= 16 || now.getMonth() == Month.JANUARY && now.getDayOfMonth() <= 2) + if (now.getMonth() == Month.DECEMBER && now.getDayOfMonth() >= 16 || now.getMonth() == Month.JANUARY && now.getDayOfMonth() <= 2) { jingleTheBells = true; - if(now.getMonth() == Month.OCTOBER) + } + if (now.getMonth() == Month.OCTOBER) { dootDoot = true; + } } DeferredWorkQueue.runLater(() -> { @@ -159,13 +156,14 @@ public class ClientProxy implements IProxy { Registry.BLOCK.stream().filter(b -> b.getRegistryName().getNamespace().equals(LibMisc.MOD_ID)) .forEach(b -> { if (b instanceof BlockFloatingFlower || b instanceof FlowerBlock - || b instanceof TallFlowerBlock || b instanceof BlockModMushroom) + || b instanceof TallFlowerBlock || b instanceof BlockModMushroom) { RenderTypeLookup.setRenderLayer(b, RenderType.getCutout()); + } }); } private void loadComplete(FMLLoadCompleteEvent event) { - DeferredWorkQueue.runLater(() -> { + DeferredWorkQueue.runLater(() -> { initAuxiliaryRender(); ColorHandler.init(); }); @@ -176,14 +174,16 @@ public class ClientProxy implements IProxy { PlayerRenderer render; render = skinMap.get("default"); render.addLayer(new ContributorFancinessHandler(render)); - if(Botania.curiosLoaded) + if (Botania.curiosLoaded) { render.addLayer(new BaubleRenderHandler(render)); + } render.addLayer(new LayerTerraHelmet(render)); render = skinMap.get("slim"); render.addLayer(new ContributorFancinessHandler(render)); - if(Botania.curiosLoaded) + if (Botania.curiosLoaded) { render.addLayer(new BaubleRenderHandler(render)); + } render.addLayer(new LayerTerraHelmet(render)); } @@ -242,8 +242,8 @@ public class ClientProxy implements IProxy { public void clearSextantMultiblock() { if (MultiblockVisualizationHandler.hasMultiblock && MultiblockVisualizationHandler.getMultiblock() != null - && MultiblockVisualizationHandler.getMultiblock().getID().equals(ItemSextant.MULTIBLOCK_ID)) + && MultiblockVisualizationHandler.getMultiblock().getID().equals(ItemSextant.MULTIBLOCK_ID)) { MultiblockVisualizationHandler.setMultiblock(null, null, null, true); + } } } - diff --git a/src/main/java/vazkii/botania/client/fx/FXLightning.java b/src/main/java/vazkii/botania/client/fx/FXLightning.java index 3daf81e8b..608e2a59d 100644 --- a/src/main/java/vazkii/botania/client/fx/FXLightning.java +++ b/src/main/java/vazkii/botania/client/fx/FXLightning.java @@ -1,6 +1,15 @@ +/* + * This class is 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 + */ package vazkii.botania.client.fx; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.IParticleRenderType; @@ -14,10 +23,12 @@ import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.RayTraceContext; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; + import vazkii.botania.client.core.handler.LightningHandler; import vazkii.botania.common.core.helper.Vector3; import javax.annotation.Nonnull; + import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -81,18 +92,21 @@ public class FXLightning extends Particle { float boltAge = age < 0 ? 0 : (float) age / (float) maxAge; float mainAlpha; - if(pass == 0) + if (pass == 0) { mainAlpha = (1 - boltAge) * 0.4F; - else mainAlpha = 1 - boltAge * 0.5F; + } else { + mainAlpha = 1 - boltAge * 0.5F; + } int expandTime = (int) (length * speed); int renderstart = (int) ((expandTime / 2 - maxAge + age) / (float) (expandTime / 2) * segmentCount); int renderend = (int) ((age + expandTime) / (float) expandTime * segmentCount); - for(FXLightningSegment rendersegment : segments) { - if(rendersegment.segmentNo < renderstart || rendersegment.segmentNo > renderend) + for (FXLightningSegment rendersegment : segments) { + if (rendersegment.segmentNo < renderstart || rendersegment.segmentNo > renderend) { continue; + } Vector3 playerVec = getRelativeViewVector(rendersegment.startPoint.point).multiply(-1); @@ -106,32 +120,32 @@ public class FXLightning extends Particle { int color = inner ? colorInner : colorOuter; int r = (color & 0xFF0000) >> 16; - int g = (color & 0xFF00) >> 8; - int b = color & 0xFF; - int a = (int) (mainAlpha * rendersegment.light * 0xFF); + int g = (color & 0xFF00) >> 8; + int b = color & 0xFF; + int a = (int) (mainAlpha * rendersegment.light * 0xFF); - wr.vertex(endvec.x - diff2.x, endvec.y - diff2.y, endvec.z - diff2.z).texture(0.5F, 0).light(0xF000F0).color(r, g, b, a).endVertex(); - wr.vertex(startvec.x - diff1.x, startvec.y - diff1.y, startvec.z - diff1.z).texture(0.5F, 0).light(0xF000F0).color(r, g, b, a).endVertex(); - wr.vertex(startvec.x + diff1.x, startvec.y + diff1.y, startvec.z + diff1.z).texture(0.5F, 1).light(0xF000F0).color(r, g, b, a).endVertex(); - wr.vertex(endvec.x + diff2.x, endvec.y + diff2.y, endvec.z + diff2.z).texture(0.5F, 1).light(0xF000F0).color(r, g, b, a).endVertex(); - - if(rendersegment.next == null) { - Vector3 roundend = rendersegment.endPoint.point.add(rendersegment.diff.normalize().multiply(width)); - - wr.vertex(roundend.x - diff2.x, roundend.y - diff2.y, roundend.z - diff2.z).texture(0, 0).light(0xF000F0).color(r, g, b, a).endVertex(); wr.vertex(endvec.x - diff2.x, endvec.y - diff2.y, endvec.z - diff2.z).texture(0.5F, 0).light(0xF000F0).color(r, g, b, a).endVertex(); - wr.vertex(endvec.x + diff2.x, endvec.y + diff2.y, endvec.z + diff2.z).texture(0.5F, 1).light(0xF000F0).color(r, g, b, a).endVertex(); - wr.vertex(roundend.x + diff2.x, roundend.y + diff2.y, roundend.z + diff2.z).texture(0, 1).light(0xF000F0).color(r, g, b, a).endVertex(); - } - - if(rendersegment.prev == null) { - Vector3 roundend = rendersegment.startPoint.point.subtract(rendersegment.diff.normalize().multiply(width)); - wr.vertex(startvec.x - diff1.x, startvec.y - diff1.y, startvec.z - diff1.z).texture(0.5F, 0).light(0xF000F0).color(r, g, b, a).endVertex(); - wr.vertex(roundend.x - diff1.x, roundend.y - diff1.y, roundend.z - diff1.z).texture(0, 0).light(0xF000F0).color(r, g, b, a).endVertex(); - wr.vertex(roundend.x + diff1.x, roundend.y + diff1.y, roundend.z + diff1.z).texture(0, 1).light(0xF000F0).color(r, g, b, a).endVertex(); wr.vertex(startvec.x + diff1.x, startvec.y + diff1.y, startvec.z + diff1.z).texture(0.5F, 1).light(0xF000F0).color(r, g, b, a).endVertex(); - } + wr.vertex(endvec.x + diff2.x, endvec.y + diff2.y, endvec.z + diff2.z).texture(0.5F, 1).light(0xF000F0).color(r, g, b, a).endVertex(); + + if (rendersegment.next == null) { + Vector3 roundend = rendersegment.endPoint.point.add(rendersegment.diff.normalize().multiply(width)); + + wr.vertex(roundend.x - diff2.x, roundend.y - diff2.y, roundend.z - diff2.z).texture(0, 0).light(0xF000F0).color(r, g, b, a).endVertex(); + wr.vertex(endvec.x - diff2.x, endvec.y - diff2.y, endvec.z - diff2.z).texture(0.5F, 0).light(0xF000F0).color(r, g, b, a).endVertex(); + wr.vertex(endvec.x + diff2.x, endvec.y + diff2.y, endvec.z + diff2.z).texture(0.5F, 1).light(0xF000F0).color(r, g, b, a).endVertex(); + wr.vertex(roundend.x + diff2.x, roundend.y + diff2.y, roundend.z + diff2.z).texture(0, 1).light(0xF000F0).color(r, g, b, a).endVertex(); + } + + if (rendersegment.prev == null) { + Vector3 roundend = rendersegment.startPoint.point.subtract(rendersegment.diff.normalize().multiply(width)); + + wr.vertex(startvec.x - diff1.x, startvec.y - diff1.y, startvec.z - diff1.z).texture(0.5F, 0).light(0xF000F0).color(r, g, b, a).endVertex(); + wr.vertex(roundend.x - diff1.x, roundend.y - diff1.y, roundend.z - diff1.z).texture(0, 0).light(0xF000F0).color(r, g, b, a).endVertex(); + wr.vertex(roundend.x + diff1.x, roundend.y + diff1.y, roundend.z + diff1.z).texture(0, 1).light(0xF000F0).color(r, g, b, a).endVertex(); + wr.vertex(startvec.x + diff1.x, startvec.y + diff1.y, startvec.z + diff1.z).texture(0.5F, 1).light(0xF000F0).color(r, g, b, a).endVertex(); + } } } @@ -141,7 +155,7 @@ public class FXLightning extends Particle { FXLightningSegment prev; - for(FXLightningSegment segment : oldSegments) { + for (FXLightningSegment segment : oldSegments) { prev = segment.prev; Vector3 subsegment = segment.diff.multiply(1F / splits); @@ -152,7 +166,7 @@ public class FXLightning extends Particle { newpoints[0] = segment.startPoint; newpoints[splits] = segment.endPoint; - for(int i = 1; i < splits; i++) { + for (int i = 1; i < splits; i++) { Vector3 randoff = segment.diff.perpendicular().normalize().rotate(rand.nextFloat() * 360, segment.diff); randoff = randoff.multiply((rand.nextFloat() - 0.5F) * amount * 2); @@ -161,13 +175,14 @@ public class FXLightning extends Particle { newpoints[i] = new FXLightningBoltPoint(basepoint, randoff); } - for(int i = 0; i < splits; i++) { + for (int i = 0; i < splits; i++) { FXLightningSegment next = new FXLightningSegment(newpoints[i], newpoints[i + 1], segment.light, segment.segmentNo * splits + i, segment.splitNo); next.prev = prev; - if (prev != null) + if (prev != null) { prev.next = next; + } - if(i != 0 && rand.nextFloat() < splitChance) { + if (i != 0 && rand.nextFloat() < splitChance) { Vector3 splitrot = next.diff.xCrossProduct().rotate(rand.nextFloat() * 360, next.diff); Vector3 diff = next.diff.rotate((rand.nextFloat() * 0.66F + 0.33F) * splitAngle, splitrot).multiply(splitLength); @@ -184,8 +199,9 @@ public class FXLightning extends Particle { segments.add(next); } - if(segment.next != null) + if (segment.next != null) { segment.next.prev = prev; + } } segmentCount *= splits; @@ -197,15 +213,18 @@ public class FXLightning extends Particle { RayTraceContext ctx = new RayTraceContext(start.toVec3D(), end.toVec3D(), RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, viewer); RayTraceResult mop = world.rayTraceBlocks(ctx); - if(mop.getType() == RayTraceResult.Type.BLOCK) { + if (mop.getType() == RayTraceResult.Type.BLOCK) { BlockPos pos = ((BlockRayTraceResult) mop).getPos(); Block block = world.getBlockState(pos).getBlock(); - if(world.isAirBlock(pos)) + if (world.isAirBlock(pos)) { return prevresistance; + } return prevresistance + block.getExplosionResistance() + 0.3F; - } else return prevresistance; + } else { + return prevresistance; + } } private void calculateCollisionAndDiffs() { @@ -213,25 +232,28 @@ public class FXLightning extends Particle { segments.sort((o1, o2) -> { int comp = Integer.compare(o1.splitNo, o2.splitNo); - if (comp == 0) + if (comp == 0) { return Integer.compare(o1.segmentNo, o2.segmentNo); - else return comp; + } else { + return comp; + } }); int lastSplitCalc = 0; int lastActiveSegment = 0;// unterminated float splitResistance = 0; - for(FXLightningSegment segment : segments) { - if(segment.splitNo > lastSplitCalc) { + for (FXLightningSegment segment : segments) { + if (segment.splitNo > lastSplitCalc) { lastactivesegment.put(lastSplitCalc, lastActiveSegment); lastSplitCalc = segment.splitNo; lastActiveSegment = lastactivesegment.get(splitParents.get(segment.splitNo)); splitResistance = lastActiveSegment < segment.segmentNo ? 50 : 0; } - if(splitResistance >= 40 * segment.light) + if (splitResistance >= 40 * segment.light) { continue; + } splitResistance = rayTraceResistance(segment.startPoint.point, segment.endPoint.point, splitResistance); lastActiveSegment = segment.segmentNo; @@ -240,15 +262,16 @@ public class FXLightning extends Particle { lastSplitCalc = 0; lastActiveSegment = lastactivesegment.get(0); - for(Iterator iterator = segments.iterator(); iterator.hasNext();) { + for (Iterator iterator = segments.iterator(); iterator.hasNext();) { FXLightningSegment segment = iterator.next(); - if(lastSplitCalc != segment.splitNo) { + if (lastSplitCalc != segment.splitNo) { lastSplitCalc = segment.splitNo; lastActiveSegment = lastactivesegment.get(segment.splitNo); } - if(segment.segmentNo > lastActiveSegment) + if (segment.segmentNo > lastActiveSegment) { iterator.remove(); + } segment.calcEndDiffs(); } } diff --git a/src/main/java/vazkii/botania/client/fx/FXLightningBoltPoint.java b/src/main/java/vazkii/botania/client/fx/FXLightningBoltPoint.java index 7eefcc62c..1bcaaa44c 100644 --- a/src/main/java/vazkii/botania/client/fx/FXLightningBoltPoint.java +++ b/src/main/java/vazkii/botania/client/fx/FXLightningBoltPoint.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.client.fx; import vazkii.botania.common.core.helper.Vector3; diff --git a/src/main/java/vazkii/botania/client/fx/FXLightningSegment.java b/src/main/java/vazkii/botania/client/fx/FXLightningSegment.java index 0a3146335..a11be7da0 100644 --- a/src/main/java/vazkii/botania/client/fx/FXLightningSegment.java +++ b/src/main/java/vazkii/botania/client/fx/FXLightningSegment.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.client.fx; import vazkii.botania.common.core.helper.Vector3; @@ -41,7 +49,7 @@ public class FXLightningSegment { } public void calcEndDiffs() { - if(prev != null) { + if (prev != null) { Vector3 prevdiffnorm = prev.diff.normalize(); Vector3 thisdiffnorm = diff.normalize(); @@ -52,7 +60,7 @@ public class FXLightningSegment { sinPrev = 1; } - if(next != null) { + if (next != null) { Vector3 nextdiffnorm = next.diff.normalize(); Vector3 thisdiffnorm = diff.normalize(); diff --git a/src/main/java/vazkii/botania/client/fx/FXSparkle.java b/src/main/java/vazkii/botania/client/fx/FXSparkle.java index 23c473a40..c63a02e8b 100644 --- a/src/main/java/vazkii/botania/client/fx/FXSparkle.java +++ b/src/main/java/vazkii/botania/client/fx/FXSparkle.java @@ -1,25 +1,19 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [? (GMT)] */ package vazkii.botania.client.fx; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.IVertexBuilder; -import net.minecraft.block.Block; + import net.minecraft.client.Minecraft; import net.minecraft.client.particle.IAnimatedSprite; import net.minecraft.client.particle.IParticleRenderType; -import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.SpriteTexturedParticle; -import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.AtlasTexture; @@ -27,14 +21,13 @@ import net.minecraft.client.renderer.texture.Texture; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.util.Direction; -import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.helper.ShaderHelper; -import vazkii.botania.client.lib.LibResources; -import vazkii.botania.common.core.handler.ConfigHandler; import javax.annotation.Nonnull; @@ -46,8 +39,8 @@ public class FXSparkle extends SpriteTexturedParticle { private final IAnimatedSprite sprite; public FXSparkle(World world, double x, double y, double z, float size, - float red, float green, float blue, int m, - boolean fake, boolean noClip, boolean corrupt, IAnimatedSprite sprite) { + float red, float green, float blue, int m, + boolean fake, boolean noClip, boolean corrupt, IAnimatedSprite sprite) { super(world, x, y, z, 0.0D, 0.0D, 0.0D); particleRed = red; particleGreen = green; @@ -70,7 +63,7 @@ public class FXSparkle extends SpriteTexturedParticle { @Override public float getScale(float partialTicks) { - return particleScale * (maxAge-age+1) / (float)maxAge; + return particleScale * (maxAge - age + 1) / (float) maxAge; } @Override @@ -80,13 +73,15 @@ public class FXSparkle extends SpriteTexturedParticle { prevPosY = posY; prevPosZ = posZ; - if (age++ >= maxAge) + if (age++ >= maxAge) { setExpired(); + } motionY -= 0.04D * particleGravity; - if (canCollide && !fake) + if (canCollide && !fake) { wiggleAround(posX, (getBoundingBox().minY + getBoundingBox().maxY) / 2.0D, posZ); + } this.move(motionX, motionY, motionZ); @@ -101,8 +96,9 @@ public class FXSparkle extends SpriteTexturedParticle { } } - if(fake && age > 1) + if (fake && age > 1) { setExpired(); + } } @Nonnull @@ -116,15 +112,14 @@ public class FXSparkle extends SpriteTexturedParticle { } // [VanillaCopy] Entity.pushOutOfBlocks with tweaks - private void wiggleAround(double x, double y, double z) - { + private void wiggleAround(double x, double y, double z) { BlockPos blockpos = new BlockPos(x, y, z); - Vec3d vec3d = new Vec3d(x - (double)blockpos.getX(), y - (double)blockpos.getY(), z - (double)blockpos.getZ()); + Vec3d vec3d = new Vec3d(x - (double) blockpos.getX(), y - (double) blockpos.getY(), z - (double) blockpos.getZ()); BlockPos.Mutable blockpos$mutable = new BlockPos.Mutable(); Direction direction = Direction.UP; double d0 = Double.MAX_VALUE; - for(Direction direction1 : new Direction[]{Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST, Direction.UP}) { + for (Direction direction1 : new Direction[] { Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST, Direction.UP }) { blockpos$mutable.setPos(blockpos).move(direction1); if (!this.world.getBlockState(blockpos$mutable).isFullCube(this.world, blockpos$mutable)) { double d1 = vec3d.getCoordinate(direction1.getAxis()); @@ -138,22 +133,22 @@ public class FXSparkle extends SpriteTexturedParticle { // Botania - made multiplier and add both smaller float f = this.rand.nextFloat() * 0.05F + 0.025F; - float f1 = (float)direction.getAxisDirection().getOffset(); + float f1 = (float) direction.getAxisDirection().getOffset(); // Botania - Randomness in other axes as well float secondary = (rand.nextFloat() - rand.nextFloat()) * 0.1F; float secondary2 = (rand.nextFloat() - rand.nextFloat()) * 0.1F; if (direction.getAxis() == Direction.Axis.X) { - motionX = (double)(f1 * f); + motionX = (double) (f1 * f); motionY = secondary; motionZ = secondary2; } else if (direction.getAxis() == Direction.Axis.Y) { motionX = secondary; - motionY = (double)(f1 * f); + motionY = (double) (f1 * f); motionZ = secondary2; } else if (direction.getAxis() == Direction.Axis.Z) { motionX = secondary; motionY = secondary2; - motionZ = (double)(f1 * f); + motionZ = (double) (f1 * f); } } diff --git a/src/main/java/vazkii/botania/client/fx/FXWisp.java b/src/main/java/vazkii/botania/client/fx/FXWisp.java index af6b80e67..45d399503 100644 --- a/src/main/java/vazkii/botania/client/fx/FXWisp.java +++ b/src/main/java/vazkii/botania/client/fx/FXWisp.java @@ -1,38 +1,28 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [? (GMT)] */ package vazkii.botania.client.fx; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.Minecraft; import net.minecraft.client.particle.IParticleRenderType; -import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.SpriteTexturedParticle; -import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.AtlasTexture; -import net.minecraft.client.renderer.texture.Texture; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; -import net.minecraftforge.fml.common.ObfuscationReflectionHelper; + import org.lwjgl.opengl.GL11; -import vazkii.botania.client.lib.LibResources; -import vazkii.botania.common.core.handler.ConfigHandler; import javax.annotation.Nonnull; -import java.lang.reflect.Field; public class FXWisp extends SpriteTexturedParticle { private final boolean depthTest; @@ -40,7 +30,7 @@ public class FXWisp extends SpriteTexturedParticle { private final int moteHalfLife; public FXWisp(World world, double d, double d1, double d2, double xSpeed, double ySpeed, double zSpeed, - float size, float red, float green, float blue, boolean depthTest, float maxAgeMul, boolean noClip) { + float size, float red, float green, float blue, boolean depthTest, float maxAgeMul, boolean noClip) { super(world, d, d1, d2, 0, 0, 0); // super applies wiggle to motion so set it here instead motionX = xSpeed; @@ -53,7 +43,7 @@ public class FXWisp extends SpriteTexturedParticle { particleGravity = 0; particleScale = (this.rand.nextFloat() * 0.5F + 0.5F) * 2.0F * size; moteParticleScale = particleScale; - maxAge = (int)(28D / (Math.random() * 0.3D + 0.7D) * maxAgeMul); + maxAge = (int) (28D / (Math.random() * 0.3D + 0.7D) * maxAgeMul); this.depthTest = depthTest; moteHalfLife = maxAge / 2; @@ -67,9 +57,10 @@ public class FXWisp extends SpriteTexturedParticle { @Override public float getScale(float p_217561_1_) { - float agescale = (float)age / (float) moteHalfLife; - if (agescale > 1F) + float agescale = (float) age / (float) moteHalfLife; + if (agescale > 1F) { agescale = 2 - agescale; + } particleScale = moteParticleScale * agescale * 0.5F; return particleScale; @@ -93,12 +84,11 @@ public class FXWisp extends SpriteTexturedParticle { this.prevPosY = this.posY; this.prevPosZ = this.posZ; - if (this.age++ >= this.maxAge) - { + if (this.age++ >= this.maxAge) { this.setExpired(); } - this.motionY -= 0.04D * (double)this.particleGravity; + this.motionY -= 0.04D * (double) this.particleGravity; this.move(this.motionX, this.motionY, this.motionZ); this.motionX *= 0.9800000190734863D; this.motionY *= 0.9800000190734863D; diff --git a/src/main/java/vazkii/botania/client/fx/ModParticles.java b/src/main/java/vazkii/botania/client/fx/ModParticles.java index b381b131d..0a648bedb 100644 --- a/src/main/java/vazkii/botania/client/fx/ModParticles.java +++ b/src/main/java/vazkii/botania/client/fx/ModParticles.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.client.fx; import net.minecraft.client.Minecraft; @@ -8,30 +16,29 @@ import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.common.lib.LibMisc; import static vazkii.botania.common.block.ModBlocks.register; @Mod.EventBusSubscriber(modid = LibMisc.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) public class ModParticles { - @ObjectHolder(LibMisc.MOD_ID + ":wisp") - public static ParticleType WISP; + @ObjectHolder(LibMisc.MOD_ID + ":wisp") public static ParticleType WISP; - @ObjectHolder(LibMisc.MOD_ID + ":sparkle") - public static ParticleType SPARKLE; + @ObjectHolder(LibMisc.MOD_ID + ":sparkle") public static ParticleType SPARKLE; - @SubscribeEvent - public static void registerParticles(RegistryEvent.Register> evt) { - register(evt.getRegistry(), new WispParticleType(), "wisp"); - register(evt.getRegistry(), new SparkleParticleType(), "sparkle"); - } + @SubscribeEvent + public static void registerParticles(RegistryEvent.Register> evt) { + register(evt.getRegistry(), new WispParticleType(), "wisp"); + register(evt.getRegistry(), new SparkleParticleType(), "sparkle"); + } - @Mod.EventBusSubscriber(value = Dist.CLIENT, modid = LibMisc.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) - public static class FactoryHandler { - @SubscribeEvent - public static void registerFactories(ParticleFactoryRegisterEvent evt) { - Minecraft.getInstance().particles.registerFactory(ModParticles.WISP, WispParticleType.Factory::new); - Minecraft.getInstance().particles.registerFactory(ModParticles.SPARKLE, SparkleParticleType.Factory::new); - } - } + @Mod.EventBusSubscriber(value = Dist.CLIENT, modid = LibMisc.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) + public static class FactoryHandler { + @SubscribeEvent + public static void registerFactories(ParticleFactoryRegisterEvent evt) { + Minecraft.getInstance().particles.registerFactory(ModParticles.WISP, WispParticleType.Factory::new); + Minecraft.getInstance().particles.registerFactory(ModParticles.SPARKLE, SparkleParticleType.Factory::new); + } + } } diff --git a/src/main/java/vazkii/botania/client/fx/SparkleParticleData.java b/src/main/java/vazkii/botania/client/fx/SparkleParticleData.java index 1fddd20af..6969041d2 100644 --- a/src/main/java/vazkii/botania/client/fx/SparkleParticleData.java +++ b/src/main/java/vazkii/botania/client/fx/SparkleParticleData.java @@ -1,102 +1,111 @@ +/* + * This class is 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 + */ package vazkii.botania.client.fx; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.exceptions.CommandSyntaxException; + import net.minecraft.network.PacketBuffer; import net.minecraft.particles.IParticleData; import net.minecraft.particles.ParticleType; import javax.annotation.Nonnull; + import java.util.Locale; public class SparkleParticleData implements IParticleData { - public final float size; - public final float r, g, b; - public final int m; - public final boolean noClip; - public final boolean fake; - public final boolean corrupt; + public final float size; + public final float r, g, b; + public final int m; + public final boolean noClip; + public final boolean fake; + public final boolean corrupt; - public static SparkleParticleData noClip(float size, float r, float g, float b, int m) { - return new SparkleParticleData(size, r, g, b, m, true, false, false); - } + public static SparkleParticleData noClip(float size, float r, float g, float b, int m) { + return new SparkleParticleData(size, r, g, b, m, true, false, false); + } - public static SparkleParticleData fake(float size, float r, float g, float b, int m) { - return new SparkleParticleData(size, r, g, b, m, false, true, false); - } + public static SparkleParticleData fake(float size, float r, float g, float b, int m) { + return new SparkleParticleData(size, r, g, b, m, false, true, false); + } - public static SparkleParticleData corrupt(float size, float r, float g, float b, int m) { - return new SparkleParticleData(size, r, g, b, m, false, false, true); - } + public static SparkleParticleData corrupt(float size, float r, float g, float b, int m) { + return new SparkleParticleData(size, r, g, b, m, false, false, true); + } - public static SparkleParticleData sparkle(float size, float r, float g, float b, int m) { - return new SparkleParticleData(size, r, g, b, m, false, false, false); - } + public static SparkleParticleData sparkle(float size, float r, float g, float b, int m) { + return new SparkleParticleData(size, r, g, b, m, false, false, false); + } - private SparkleParticleData(float size, float r, float g, float b, int m, boolean noClip, boolean fake, boolean corrupt) { - this.size = size; - this.r = r; - this.g = g; - this.b = b; - this.m = m; - this.noClip = noClip; - this.fake = fake; - this.corrupt = corrupt; - } + private SparkleParticleData(float size, float r, float g, float b, int m, boolean noClip, boolean fake, boolean corrupt) { + this.size = size; + this.r = r; + this.g = g; + this.b = b; + this.m = m; + this.noClip = noClip; + this.fake = fake; + this.corrupt = corrupt; + } + @Nonnull + @Override + public ParticleType getType() { + return ModParticles.SPARKLE; + } - @Nonnull - @Override - public ParticleType getType() { - return ModParticles.SPARKLE; - } + @Override + public void write(PacketBuffer buf) { + buf.writeFloat(size); + buf.writeFloat(r); + buf.writeFloat(g); + buf.writeFloat(b); + buf.writeInt(m); + buf.writeBoolean(noClip); + buf.writeBoolean(fake); + buf.writeBoolean(corrupt); + } - @Override - public void write(PacketBuffer buf) { - buf.writeFloat(size); - buf.writeFloat(r); - buf.writeFloat(g); - buf.writeFloat(b); - buf.writeInt(m); - buf.writeBoolean(noClip); - buf.writeBoolean(fake); - buf.writeBoolean(corrupt); - } + @Nonnull + @Override + public String getParameters() { + return String.format(Locale.ROOT, "%s %.2f %.2f %.2f %.2f %d %s %s %s", + this.getType().getRegistryName(), this.size, this.r, this.g, this.b, this.m, this.noClip, this.fake, this.corrupt); + } - @Nonnull - @Override - public String getParameters() { - return String.format(Locale.ROOT, "%s %.2f %.2f %.2f %.2f %d %s %s %s", - this.getType().getRegistryName(), this.size, this.r, this.g, this.b, this.m, this.noClip, this.fake, this.corrupt); - } + public static final IDeserializer DESERIALIZER = new IDeserializer() { + @Nonnull + @Override + public SparkleParticleData deserialize(@Nonnull ParticleType type, @Nonnull StringReader reader) throws CommandSyntaxException { + reader.expect(' '); + float size = reader.readFloat(); + reader.expect(' '); + float r = reader.readFloat(); + reader.expect(' '); + float g = reader.readFloat(); + reader.expect(' '); + float b = reader.readFloat(); + reader.expect(' '); + int m = reader.readInt(); + reader.expect(' '); + boolean noClip = reader.readBoolean(); + reader.expect(' '); + boolean fake = reader.readBoolean(); + reader.expect(' '); + boolean corrupt = reader.readBoolean(); - public static final IDeserializer DESERIALIZER = new IDeserializer() { - @Nonnull - @Override - public SparkleParticleData deserialize(@Nonnull ParticleType type, @Nonnull StringReader reader) throws CommandSyntaxException { - reader.expect(' '); - float size = reader.readFloat(); - reader.expect(' '); - float r = reader.readFloat(); - reader.expect(' '); - float g = reader.readFloat(); - reader.expect(' '); - float b = reader.readFloat(); - reader.expect(' '); - int m = reader.readInt(); - reader.expect(' '); - boolean noClip = reader.readBoolean(); - reader.expect(' '); - boolean fake = reader.readBoolean(); - reader.expect(' '); - boolean corrupt = reader.readBoolean(); + return new SparkleParticleData(size, r, g, b, m, noClip, fake, corrupt); + } - return new SparkleParticleData(size, r, g, b, m, noClip, fake, corrupt); - } - - @Override - public SparkleParticleData read(@Nonnull ParticleType type, PacketBuffer buf) { - return new SparkleParticleData(buf.readFloat(), buf.readFloat(), buf.readFloat(), buf.readFloat(), buf.readInt(), buf.readBoolean(), buf.readBoolean(), buf.readBoolean()); - } - }; + @Override + public SparkleParticleData read(@Nonnull ParticleType type, PacketBuffer buf) { + return new SparkleParticleData(buf.readFloat(), buf.readFloat(), buf.readFloat(), buf.readFloat(), buf.readInt(), buf.readBoolean(), buf.readBoolean(), buf.readBoolean()); + } + }; } diff --git a/src/main/java/vazkii/botania/client/fx/SparkleParticleType.java b/src/main/java/vazkii/botania/client/fx/SparkleParticleType.java index c64d76125..c7de1081f 100644 --- a/src/main/java/vazkii/botania/client/fx/SparkleParticleType.java +++ b/src/main/java/vazkii/botania/client/fx/SparkleParticleType.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.client.fx; import net.minecraft.client.particle.IAnimatedSprite; @@ -7,20 +15,20 @@ import net.minecraft.particles.ParticleType; import net.minecraft.world.World; public class SparkleParticleType extends ParticleType { - public SparkleParticleType() { - super(false, SparkleParticleData.DESERIALIZER); - } + public SparkleParticleType() { + super(false, SparkleParticleData.DESERIALIZER); + } - public static class Factory implements IParticleFactory { - private final IAnimatedSprite sprite; + public static class Factory implements IParticleFactory { + private final IAnimatedSprite sprite; - public Factory(IAnimatedSprite sprite) { - this.sprite = sprite; - } + public Factory(IAnimatedSprite sprite) { + this.sprite = sprite; + } - @Override - public Particle makeParticle(SparkleParticleData data, World world, double x, double y, double z, double mx, double my, double mz) { - return new FXSparkle(world, x, y, z, data.size, data.r, data.g, data.b, data.m, data.fake, data.noClip, data.corrupt, sprite); - } - } + @Override + public Particle makeParticle(SparkleParticleData data, World world, double x, double y, double z, double mx, double my, double mz) { + return new FXSparkle(world, x, y, z, data.size, data.r, data.g, data.b, data.m, data.fake, data.noClip, data.corrupt, sprite); + } + } } diff --git a/src/main/java/vazkii/botania/client/fx/WispParticleData.java b/src/main/java/vazkii/botania/client/fx/WispParticleData.java index 79caeb206..aff08c858 100644 --- a/src/main/java/vazkii/botania/client/fx/WispParticleData.java +++ b/src/main/java/vazkii/botania/client/fx/WispParticleData.java @@ -1,109 +1,119 @@ +/* + * This class is 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 + */ package vazkii.botania.client.fx; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.exceptions.CommandSyntaxException; + import net.minecraft.network.PacketBuffer; import net.minecraft.particles.IParticleData; import net.minecraft.particles.ParticleType; import javax.annotation.Nonnull; + import java.util.Locale; public class WispParticleData implements IParticleData { - public final float size; - public final float r, g, b; - public final float maxAgeMul; - public final boolean depthTest; - public final boolean noClip; + public final float size; + public final float r, g, b; + public final float maxAgeMul; + public final boolean depthTest; + public final boolean noClip; - public static WispParticleData wisp(float size, float r, float g, float b) { - return wisp(size, r, g, b, 1); - } + public static WispParticleData wisp(float size, float r, float g, float b) { + return wisp(size, r, g, b, 1); + } - public static WispParticleData wisp(float size, float r, float g, float b, float maxAgeMul) { - return wisp(size, r, g, b, maxAgeMul, true); - } + public static WispParticleData wisp(float size, float r, float g, float b, float maxAgeMul) { + return wisp(size, r, g, b, maxAgeMul, true); + } - public static WispParticleData wisp(float size, float r, float g, float b, boolean depth) { - return wisp(size, r, g, b, 1, depth); - } + public static WispParticleData wisp(float size, float r, float g, float b, boolean depth) { + return wisp(size, r, g, b, 1, depth); + } - public static WispParticleData wisp(float size, float r, float g, float b, float maxAgeMul, boolean depthTest) { - return new WispParticleData(size, r, g, b, maxAgeMul, depthTest, false); - } + public static WispParticleData wisp(float size, float r, float g, float b, float maxAgeMul, boolean depthTest) { + return new WispParticleData(size, r, g, b, maxAgeMul, depthTest, false); + } - private WispParticleData(float size, float r, float g, float b, float maxAgeMul, boolean depthTest, boolean noClip) { - this.size = size; - this.r = r; - this.g = g; - this.b = b; - this.maxAgeMul = maxAgeMul; - this.depthTest = depthTest; - this.noClip = noClip; - } + private WispParticleData(float size, float r, float g, float b, float maxAgeMul, boolean depthTest, boolean noClip) { + this.size = size; + this.r = r; + this.g = g; + this.b = b; + this.maxAgeMul = maxAgeMul; + this.depthTest = depthTest; + this.noClip = noClip; + } - public WispParticleData withNoClip(boolean v) { - if (noClip == v) { - return this; - } else { - return new WispParticleData(size, r, g, b, maxAgeMul, depthTest, v); - } - } + public WispParticleData withNoClip(boolean v) { + if (noClip == v) { + return this; + } else { + return new WispParticleData(size, r, g, b, maxAgeMul, depthTest, v); + } + } - @Nonnull - @Override - public ParticleType getType() { - return ModParticles.WISP; - } + @Nonnull + @Override + public ParticleType getType() { + return ModParticles.WISP; + } - @Override - public void write(PacketBuffer buf) { - buf.writeFloat(size); - buf.writeFloat(r); - buf.writeFloat(g); - buf.writeFloat(b); - buf.writeFloat(maxAgeMul); - buf.writeBoolean(depthTest); - buf.writeBoolean(noClip); - } + @Override + public void write(PacketBuffer buf) { + buf.writeFloat(size); + buf.writeFloat(r); + buf.writeFloat(g); + buf.writeFloat(b); + buf.writeFloat(maxAgeMul); + buf.writeBoolean(depthTest); + buf.writeBoolean(noClip); + } - @Nonnull - @Override - public String getParameters() { - return String.format(Locale.ROOT, "%s %.2f %.2f %.2f %.2f %.2f %s", - this.getType().getRegistryName(), this.size, this.r, this.g, this.b, this.maxAgeMul, this.depthTest); - } + @Nonnull + @Override + public String getParameters() { + return String.format(Locale.ROOT, "%s %.2f %.2f %.2f %.2f %.2f %s", + this.getType().getRegistryName(), this.size, this.r, this.g, this.b, this.maxAgeMul, this.depthTest); + } - public static final IDeserializer DESERIALIZER = new IDeserializer() { - @Nonnull - @Override - public WispParticleData deserialize(@Nonnull ParticleType type, @Nonnull StringReader reader) throws CommandSyntaxException { - reader.expect(' '); - float size = reader.readFloat(); - reader.expect(' '); - float r = reader.readFloat(); - reader.expect(' '); - float g = reader.readFloat(); - reader.expect(' '); - float b = reader.readFloat(); - reader.expect(' '); - float mam = reader.readFloat(); - boolean depth = true; - if (reader.canRead()) { - reader.expect(' '); - depth = reader.readBoolean(); - } - boolean noClip = false; - if (reader.canRead()) { - reader.expect(' '); - depth = reader.readBoolean(); - } - return new WispParticleData(size, r, g, b, mam, depth, noClip); - } + public static final IDeserializer DESERIALIZER = new IDeserializer() { + @Nonnull + @Override + public WispParticleData deserialize(@Nonnull ParticleType type, @Nonnull StringReader reader) throws CommandSyntaxException { + reader.expect(' '); + float size = reader.readFloat(); + reader.expect(' '); + float r = reader.readFloat(); + reader.expect(' '); + float g = reader.readFloat(); + reader.expect(' '); + float b = reader.readFloat(); + reader.expect(' '); + float mam = reader.readFloat(); + boolean depth = true; + if (reader.canRead()) { + reader.expect(' '); + depth = reader.readBoolean(); + } + boolean noClip = false; + if (reader.canRead()) { + reader.expect(' '); + depth = reader.readBoolean(); + } + return new WispParticleData(size, r, g, b, mam, depth, noClip); + } - @Override - public WispParticleData read(@Nonnull ParticleType type, PacketBuffer buf) { - return new WispParticleData(buf.readFloat(), buf.readFloat(), buf.readFloat(), buf.readFloat(), buf.readFloat(), buf.readBoolean(), buf.readBoolean()); - } - }; + @Override + public WispParticleData read(@Nonnull ParticleType type, PacketBuffer buf) { + return new WispParticleData(buf.readFloat(), buf.readFloat(), buf.readFloat(), buf.readFloat(), buf.readFloat(), buf.readBoolean(), buf.readBoolean()); + } + }; } diff --git a/src/main/java/vazkii/botania/client/fx/WispParticleType.java b/src/main/java/vazkii/botania/client/fx/WispParticleType.java index 1b0bd52cb..6510fc1ec 100644 --- a/src/main/java/vazkii/botania/client/fx/WispParticleType.java +++ b/src/main/java/vazkii/botania/client/fx/WispParticleType.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.client.fx; import net.minecraft.client.particle.IAnimatedSprite; @@ -7,22 +15,22 @@ import net.minecraft.particles.ParticleType; import net.minecraft.world.World; public class WispParticleType extends ParticleType { - public WispParticleType() { - super(false, WispParticleData.DESERIALIZER); - } + public WispParticleType() { + super(false, WispParticleData.DESERIALIZER); + } - public static class Factory implements IParticleFactory { - private final IAnimatedSprite sprite; + public static class Factory implements IParticleFactory { + private final IAnimatedSprite sprite; - public Factory(IAnimatedSprite sprite) { - this.sprite = sprite; - } + public Factory(IAnimatedSprite sprite) { + this.sprite = sprite; + } - @Override - public Particle makeParticle(WispParticleData data, World world, double x, double y, double z, double mx, double my, double mz) { - FXWisp ret = new FXWisp(world, x, y, z, mx, my, mz, data.size, data.r, data.g, data.b, data.depthTest, data.maxAgeMul, data.noClip); - ret.selectSpriteRandomly(sprite); - return ret; - } - } + @Override + public Particle makeParticle(WispParticleData data, World world, double x, double y, double z, double mx, double my, double mz) { + FXWisp ret = new FXWisp(world, x, y, z, mx, my, mz, data.size, data.r, data.g, data.b, data.depthTest, data.maxAgeMul, data.noClip); + ret.selectSpriteRandomly(sprite); + return ret; + } + } } diff --git a/src/main/java/vazkii/botania/client/gui/SlotLocked.java b/src/main/java/vazkii/botania/client/gui/SlotLocked.java index adaba9ccc..94271dc8e 100644 --- a/src/main/java/vazkii/botania/client/gui/SlotLocked.java +++ b/src/main/java/vazkii/botania/client/gui/SlotLocked.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 6, 2015, 1:11:25 AM (GMT)] */ package vazkii.botania.client.gui; diff --git a/src/main/java/vazkii/botania/client/gui/bag/ContainerFlowerBag.java b/src/main/java/vazkii/botania/client/gui/bag/ContainerFlowerBag.java index f22dded37..af2c51fd5 100644 --- a/src/main/java/vazkii/botania/client/gui/bag/ContainerFlowerBag.java +++ b/src/main/java/vazkii/botania/client/gui/bag/ContainerFlowerBag.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 16, 2015, 6:42:40 PM (GMT)] */ package vazkii.botania.client.gui.bag; @@ -23,15 +21,14 @@ import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.SlotItemHandler; import net.minecraftforge.registries.ObjectHolder; -import vazkii.botania.client.gui.SlotLocked; + import vazkii.botania.common.block.BlockModFlower; import vazkii.botania.common.lib.LibItemNames; import javax.annotation.Nonnull; public class ContainerFlowerBag extends Container { - @ObjectHolder("botania:" + LibItemNames.FLOWER_BAG) - public static ContainerType TYPE; + @ObjectHolder("botania:" + LibItemNames.FLOWER_BAG) public static ContainerType TYPE; public static ContainerFlowerBag fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { Hand hand = buf.readBoolean() ? Hand.MAIN_HAND : Hand.OFF_HAND; @@ -48,17 +45,20 @@ public class ContainerFlowerBag extends Container { this.bag = bag; IItemHandlerModifiable flowerBagInv = (IItemHandlerModifiable) bag.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElse(null); - for(i = 0; i < 2; ++i) - for(j = 0; j < 8; ++j) { + for (i = 0; i < 2; ++i) { + for (j = 0; j < 8; ++j) { int k = j + i * 8; addSlot(new SlotItemHandler(flowerBagInv, k, 17 + j * 18, 26 + i * 18)); } + } - for(i = 0; i < 3; ++i) - for(j = 0; j < 9; ++j) + for (i = 0; i < 3; ++i) { + for (j = 0; j < 9; ++j) { addSlot(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } - for(i = 0; i < 9; ++i) { + for (i = 0; i < 9; ++i) { addSlot(new Slot(playerInv, i, 8 + i * 18, 142)); } @@ -77,29 +77,34 @@ public class ContainerFlowerBag extends Container { ItemStack itemstack = ItemStack.EMPTY; Slot slot = inventorySlots.get(slotIndex); - if(slot != null && slot.getHasStack()) { + if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); - if(slotIndex < 16) { - if(!mergeItemStack(itemstack1, 16, 52, true)) + if (slotIndex < 16) { + if (!mergeItemStack(itemstack1, 16, 52, true)) { return ItemStack.EMPTY; + } } else { Block b = Block.getBlockFromItem(itemstack.getItem()); int i = b instanceof BlockModFlower ? ((BlockModFlower) b).color.getId() : -1; - if(i >= 0 && i < 16) { + if (i >= 0 && i < 16) { Slot slot1 = inventorySlots.get(i); - if(slot1.isItemValid(itemstack) && !mergeItemStack(itemstack1, i, i + 1, true)) + if (slot1.isItemValid(itemstack) && !mergeItemStack(itemstack1, i, i + 1, true)) { return ItemStack.EMPTY; + } } } - if(itemstack1.isEmpty()) + if (itemstack1.isEmpty()) { slot.putStack(ItemStack.EMPTY); - else slot.onSlotChanged(); + } else { + slot.onSlotChanged(); + } - if(itemstack1.getCount() == itemstack.getCount()) + if (itemstack1.getCount() == itemstack.getCount()) { return ItemStack.EMPTY; + } slot.onTake(player, itemstack1); } diff --git a/src/main/java/vazkii/botania/client/gui/bag/GuiFlowerBag.java b/src/main/java/vazkii/botania/client/gui/bag/GuiFlowerBag.java index 968422672..058449f03 100644 --- a/src/main/java/vazkii/botania/client/gui/bag/GuiFlowerBag.java +++ b/src/main/java/vazkii/botania/client/gui/bag/GuiFlowerBag.java @@ -1,20 +1,17 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 16, 2015, 6:42:43 PM (GMT)] */ package vazkii.botania.client.gui.bag; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screen.inventory.ContainerScreen; -import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.Slot; @@ -23,6 +20,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; import net.minecraftforge.items.SlotItemHandler; + import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.item.ModItems; @@ -58,8 +56,8 @@ public class GuiFlowerBag extends ContainerScreen { int l = (height - ySize) / 2; blit(k, l, 0, 0, xSize, ySize); - for(Slot slot : container.inventorySlots) - if(slot instanceof SlotItemHandler && !slot.getHasStack()) { + for (Slot slot : container.inventorySlots) { + if (slot instanceof SlotItemHandler && !slot.getHasStack()) { DyeColor color = DyeColor.byId(slot.getSlotIndex()); ItemStack stack = new ItemStack(ModBlocks.getFlower(color)); int x = guiLeft + slot.xPos; @@ -67,6 +65,7 @@ public class GuiFlowerBag extends ContainerScreen { mc.getItemRenderer().renderItemIntoGUI(stack, x, y); mc.fontRenderer.drawStringWithShadow("0", x + 11, y + 9, 0xFF6666); } + } } } diff --git a/src/main/java/vazkii/botania/client/gui/box/ContainerBaubleBox.java b/src/main/java/vazkii/botania/client/gui/box/ContainerBaubleBox.java index b01d7278f..dce89e783 100644 --- a/src/main/java/vazkii/botania/client/gui/box/ContainerBaubleBox.java +++ b/src/main/java/vazkii/botania/client/gui/box/ContainerBaubleBox.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [25/11/2015, 19:59:06 (GMT)] */ package vazkii.botania.client.gui.box; @@ -22,14 +20,14 @@ import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.SlotItemHandler; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.common.core.handler.EquipmentHandler; import vazkii.botania.common.lib.LibItemNames; import javax.annotation.Nonnull; public class ContainerBaubleBox extends Container { - @ObjectHolder("botania:" + LibItemNames.BAUBLE_BOX) - public static ContainerType TYPE; + @ObjectHolder("botania:" + LibItemNames.BAUBLE_BOX) public static ContainerType TYPE; public static ContainerBaubleBox fromNetwork(int windowId, PlayerInventory inv, PacketBuffer buf) { Hand hand = buf.readBoolean() ? Hand.MAIN_HAND : Hand.OFF_HAND; @@ -47,17 +45,20 @@ public class ContainerBaubleBox extends Container { this.box = box; IItemHandlerModifiable baubleBoxInv = (IItemHandlerModifiable) box.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElse(null); - for(i = 0; i < 4; ++i) - for(j = 0; j < 6; ++j) { + for (i = 0; i < 4; ++i) { + for (j = 0; j < 6; ++j) { int k = j + i * 6; addSlot(new SlotItemHandler(baubleBoxInv, k, 62 + j * 18, 8 + i * 18)); } + } - for(i = 0; i < 3; ++i) - for(j = 0; j < 9; ++j) + for (i = 0; i < 3; ++i) { + for (j = 0; j < 9; ++j) { addSlot(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } - for(i = 0; i < 9; ++i) { + for (i = 0; i < 9; ++i) { addSlot(new Slot(playerInv, i, 8 + i * 18, 142)); } @@ -76,28 +77,33 @@ public class ContainerBaubleBox extends Container { ItemStack itemstack = ItemStack.EMPTY; Slot slot = inventorySlots.get(slotIndex); - if(slot != null && slot.getHasStack()) { + if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); int boxStart = 0; int boxEnd = boxStart + 24; int invEnd = boxEnd + 36; - - if(slotIndex < boxEnd) { - if(!mergeItemStack(itemstack1, boxEnd, invEnd, true)) + + if (slotIndex < boxEnd) { + if (!mergeItemStack(itemstack1, boxEnd, invEnd, true)) { return ItemStack.EMPTY; + } } else { - if(!itemstack1.isEmpty() && EquipmentHandler.instance.isAccessory(itemstack1) && !mergeItemStack(itemstack1, boxStart, boxEnd, false)) + if (!itemstack1.isEmpty() && EquipmentHandler.instance.isAccessory(itemstack1) && !mergeItemStack(itemstack1, boxStart, boxEnd, false)) { return ItemStack.EMPTY; + } } - if(itemstack1.isEmpty()) + if (itemstack1.isEmpty()) { slot.putStack(ItemStack.EMPTY); - else slot.onSlotChanged(); + } else { + slot.onSlotChanged(); + } - if(itemstack1.getCount() == itemstack.getCount()) + if (itemstack1.getCount() == itemstack.getCount()) { return ItemStack.EMPTY; + } slot.onTake(player, itemstack1); } diff --git a/src/main/java/vazkii/botania/client/gui/box/GuiBaubleBox.java b/src/main/java/vazkii/botania/client/gui/box/GuiBaubleBox.java index 22c14a317..2ac2bb4dc 100644 --- a/src/main/java/vazkii/botania/client/gui/box/GuiBaubleBox.java +++ b/src/main/java/vazkii/botania/client/gui/box/GuiBaubleBox.java @@ -1,24 +1,22 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [25/11/2015, 19:59:11 (GMT)] */ package vazkii.botania.client.gui.box; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screen.inventory.ContainerScreen; import net.minecraft.client.gui.screen.inventory.InventoryScreen; import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.Slot; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; + import vazkii.botania.client.lib.LibResources; public class GuiBaubleBox extends ContainerScreen { diff --git a/src/main/java/vazkii/botania/client/gui/crafting/ContainerCraftingHalo.java b/src/main/java/vazkii/botania/client/gui/crafting/ContainerCraftingHalo.java index 1826d66f7..d23b62db3 100644 --- a/src/main/java/vazkii/botania/client/gui/crafting/ContainerCraftingHalo.java +++ b/src/main/java/vazkii/botania/client/gui/crafting/ContainerCraftingHalo.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Dec 15, 2014, 6:02:52 PM (GMT)] */ package vazkii.botania.client.gui.crafting; @@ -17,7 +15,8 @@ import net.minecraft.util.IWorldPosCallable; import javax.annotation.Nonnull; -/* We don't need to register a new ContainerType and can just piggyback off vanilla's, +/* + * We don't need to register a new ContainerType and can just piggyback off vanilla's, * because all we want to change is canInteractWith, which is only checked serverside. * So on the server we have this container while the client will think it's just interacting * with a normal WorkbenchContainer. diff --git a/src/main/java/vazkii/botania/client/integration/jei/JEIBotaniaPlugin.java b/src/main/java/vazkii/botania/client/integration/jei/JEIBotaniaPlugin.java index 74f9e9553..41e495d91 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/JEIBotaniaPlugin.java +++ b/src/main/java/vazkii/botania/client/integration/jei/JEIBotaniaPlugin.java @@ -1,8 +1,8 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 */ @@ -20,6 +20,7 @@ import mezz.jei.api.registration.ISubtypeRegistration; import mezz.jei.api.registration.IVanillaCategoryExtensionRegistration; import mezz.jei.api.runtime.IJeiRuntime; import mezz.jei.api.runtime.IRecipesGui; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screen.inventory.ContainerScreen; import net.minecraft.item.Item; @@ -27,6 +28,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.tags.BlockTags; import net.minecraft.util.ResourceLocation; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.mana.IManaItem; import vazkii.botania.api.recipe.RecipeElvenTrade; @@ -61,6 +63,7 @@ import vazkii.botania.common.item.equipment.tool.terrasteel.ItemTerraPick; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.List; import java.util.stream.Collectors; @@ -82,7 +85,7 @@ public class JEIBotaniaPlugin implements IModPlugin { registry.registerSubtypeInterpreter(ModItems.terraPick, stack -> String.valueOf(ItemTerraPick.getLevel(stack)) + ItemTerraPick.isTipped(stack)); registry.registerSubtypeInterpreter(ModItems.manaTablet, stack -> String.valueOf(((IManaItem) ModItems.manaTablet).getMana(stack)) + ItemManaTablet.isStackCreative(stack)); - for(Item item : new Item[]{ModItems.manaRing, ModItems.manaRingGreater}) { + for (Item item : new Item[] { ModItems.manaRing, ModItems.manaRingGreater }) { registry.registerSubtypeInterpreter(item, stack -> String.valueOf(((IManaItem) item).getMana(stack))); } } @@ -172,7 +175,6 @@ public class JEIBotaniaPlugin implements IModPlugin { registry.addRecipeCatalyst(new ItemStack(ModSubtiles.pureDaisy), PureDaisyRecipeCategory.UID); registry.addRecipeCatalyst(new ItemStack(ModSubtiles.pureDaisyFloating), PureDaisyRecipeCategory.UID); - registry.addRecipeCatalyst(new ItemStack(ModBlocks.runeAltar), RunicAltarRecipeCategory.UID); registry.addRecipeCatalyst(new ItemStack(ModItems.autocraftingHalo), VanillaRecipeCategoryUid.CRAFTING); registry.addRecipeCatalyst(new ItemStack(ModItems.craftingHalo), VanillaRecipeCategoryUid.CRAFTING); @@ -181,25 +183,28 @@ public class JEIBotaniaPlugin implements IModPlugin { @Override public void onRuntimeAvailable(IJeiRuntime jeiRuntime) { IRecipeManager recipeRegistry = jeiRuntime.getRecipeManager(); - for(RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes.values()) { + for (RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes.values()) { List inputs = recipe.getInputs(); List outputs = recipe.getOutputs(); - if(inputs.size() == 1 && outputs.size() == 1 && recipe.containsItem(outputs.get(0)) && outputs.get(0).getItem() != ModItems.lexicon) { + if (inputs.size() == 1 && outputs.size() == 1 && recipe.containsItem(outputs.get(0)) && outputs.get(0).getItem() != ModItems.lexicon) { recipeRegistry.hideRecipe(recipe, ElvenTradeRecipeCategory.UID); } } - + CorporeaInputHandler.jeiPanelSupplier = () -> { Object o = jeiRuntime.getIngredientListOverlay().getIngredientUnderMouse(); - if(o == null && Minecraft.getInstance().currentScreen == jeiRuntime.getRecipesGui()) + if (o == null && Minecraft.getInstance().currentScreen == jeiRuntime.getRecipesGui()) { o = jeiRuntime.getRecipesGui().getIngredientUnderMouse(); + } - if(o == null) + if (o == null) { o = jeiRuntime.getBookmarkOverlay().getIngredientUnderMouse(); + } - if(o instanceof ItemStack) + if (o instanceof ItemStack) { return (ItemStack) o; + } return ItemStack.EMPTY; }; diff --git a/src/main/java/vazkii/botania/client/integration/jei/brewery/BreweryRecipeCategory.java b/src/main/java/vazkii/botania/client/integration/jei/brewery/BreweryRecipeCategory.java index 118782c2b..4002ff2d3 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/brewery/BreweryRecipeCategory.java +++ b/src/main/java/vazkii/botania/client/integration/jei/brewery/BreweryRecipeCategory.java @@ -1,14 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 */ package vazkii.botania.client.integration.jei.brewery; import com.google.common.collect.ImmutableList; + import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.drawable.IDrawable; @@ -17,16 +18,19 @@ import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IFocus; import mezz.jei.api.recipe.category.IRecipeCategory; + import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.ResourceLocation; + import vazkii.botania.api.recipe.RecipeBrew; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -83,16 +87,16 @@ public class BreweryRecipeCategory implements IRecipeCategory { final List inputs = Arrays.asList(new ItemStack(ModItems.vial), new ItemStack(ModItems.flask), new ItemStack(ModItems.incenseStick), new ItemStack(ModItems.bloodPendant)); - for(ItemStack stack : inputs) { + for (ItemStack stack : inputs) { ItemStack brewed = recipe.getOutput(stack); - if(!brewed.isEmpty()) { + if (!brewed.isEmpty()) { containers.add(stack); outputBuilder.add(brewed); } } inputBuilder.add(containers.build()); - for(Ingredient i : recipe.getInputs()) { + for (Ingredient i : recipe.getInputs()) { inputBuilder.add(Arrays.asList(i.getMatchingStacks())); } @@ -111,7 +115,7 @@ public class BreweryRecipeCategory implements IRecipeCategory { recipeLayout.getItemStacks().set(0, getItemMatchingFocus(focus, IFocus.Mode.OUTPUT, outputs.get(0), inputs.get(0))); int index = 1, posX = 60; - for(int i = 1; i < inputs.size(); i++) { + for (int i = 1; i < inputs.size(); i++) { List o = inputs.get(i); recipeLayout.getItemStacks().init(index, true, posX, 6); recipeLayout.getItemStacks().set(index, o); @@ -127,11 +131,13 @@ public class BreweryRecipeCategory implements IRecipeCategory { * If an item in this recipe is focused, returns the corresponding item instead of all the containers/results. */ private List getItemMatchingFocus(IFocus focus, IFocus.Mode mode, List focused, List other) { - if(focus != null && focus.getMode() == mode) { + if (focus != null && focus.getMode() == mode) { ItemStack focusStack = (ItemStack) focus.getValue(); - for(int i = 0; i < focused.size(); i++) - if(focusStack.isItemEqual(focused.get(i))) + for (int i = 0; i < focused.size(); i++) { + if (focusStack.isItemEqual(focused.get(i))) { return Collections.singletonList(other.get(i)); + } + } } return other; } diff --git a/src/main/java/vazkii/botania/client/integration/jei/crafting/AncientWillRecipeWrapper.java b/src/main/java/vazkii/botania/client/integration/jei/crafting/AncientWillRecipeWrapper.java index 7c2389c10..ff81a2455 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/crafting/AncientWillRecipeWrapper.java +++ b/src/main/java/vazkii/botania/client/integration/jei/crafting/AncientWillRecipeWrapper.java @@ -1,15 +1,26 @@ +/* + * This class is 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 + */ package vazkii.botania.client.integration.jei.crafting; import com.google.common.collect.ImmutableList; + import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IFocus; import mezz.jei.api.recipe.category.extensions.vanilla.crafting.ICustomCraftingCategoryExtension; + import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; + import vazkii.botania.api.item.IAncientWillContainer; import vazkii.botania.common.Botania; import vazkii.botania.common.crafting.recipe.AncientWillRecipe; @@ -18,9 +29,10 @@ import vazkii.botania.common.item.ModItems; import javax.annotation.Nonnull; import javax.annotation.Nullable; + import java.util.List; -public class AncientWillRecipeWrapper implements ICustomCraftingCategoryExtension { +public class AncientWillRecipeWrapper implements ICustomCraftingCategoryExtension { private final ResourceLocation name; public AncientWillRecipeWrapper(AncientWillRecipe recipe) { @@ -29,11 +41,11 @@ public class AncientWillRecipeWrapper implements ICustomCraftingCategoryExtensio @Override public void setIngredients(@Nonnull IIngredients ingredients) { - ImmutableList.Builder> builder = ImmutableList.builder(); + ImmutableList.Builder> builder = ImmutableList.builder(); ImmutableList.Builder helmets = ImmutableList.builder(); ImmutableList.Builder wills = ImmutableList.builder(); helmets.add(new ItemStack(ModItems.terrasteelHelm)); - if(Botania.thaumcraftLoaded) { + if (Botania.thaumcraftLoaded) { helmets.add(new ItemStack(ModItems.terrasteelHelmRevealing)); } wills.add(new ItemStack(ModItems.ancientWillAhrim)); @@ -62,15 +74,15 @@ public class AncientWillRecipeWrapper implements ICustomCraftingCategoryExtensio IGuiItemStackGroup group = recipeLayout.getItemStacks(); group.set(ingredients); - if(focus != null) { + if (focus != null) { ItemStack focused = (ItemStack) focus.getValue(); - if(focus.getMode() == IFocus.Mode.INPUT && focused.getItem() instanceof ItemAncientWill) { + if (focus.getMode() == IFocus.Mode.INPUT && focused.getItem() instanceof ItemAncientWill) { ItemStack copy = focused.copy(); copy.setCount(1); group.set(2, copy); group.set(0, getHelmetsWithWill(((ItemAncientWill) focused.getItem()).type, ingredients)); - } else if(focused.getItem() instanceof IAncientWillContainer) { //helmet + } else if (focused.getItem() instanceof IAncientWillContainer) { //helmet group.set(1, new ItemStack(focused.getItem())); group.set(0, getWillsOnHelmet(focused.getItem())); } @@ -79,7 +91,7 @@ public class AncientWillRecipeWrapper implements ICustomCraftingCategoryExtensio private List getHelmetsWithWill(IAncientWillContainer.AncientWillType type, IIngredients ingredients) { ImmutableList.Builder builder = ImmutableList.builder(); - for(ItemStack itemStack : ingredients.getOutputs(VanillaTypes.ITEM).get(0)) { + for (ItemStack itemStack : ingredients.getOutputs(VanillaTypes.ITEM).get(0)) { ItemStack toAdd = itemStack.copy(); ((IAncientWillContainer) toAdd.getItem()).addAncientWill(toAdd, type); builder.add(toAdd); @@ -88,9 +100,9 @@ public class AncientWillRecipeWrapper implements ICustomCraftingCategoryExtensio } private List getWillsOnHelmet(Item item) { - if(item instanceof IAncientWillContainer) { + if (item instanceof IAncientWillContainer) { ImmutableList.Builder builder = ImmutableList.builder(); - for(IAncientWillContainer.AncientWillType type : IAncientWillContainer.AncientWillType.values()) { + for (IAncientWillContainer.AncientWillType type : IAncientWillContainer.AncientWillType.values()) { ItemStack stack = new ItemStack(item); ((IAncientWillContainer) item).addAncientWill(stack, type); builder.add(stack); diff --git a/src/main/java/vazkii/botania/client/integration/jei/crafting/CompositeLensRecipeWrapper.java b/src/main/java/vazkii/botania/client/integration/jei/crafting/CompositeLensRecipeWrapper.java index 9b1655740..544fa7115 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/crafting/CompositeLensRecipeWrapper.java +++ b/src/main/java/vazkii/botania/client/integration/jei/crafting/CompositeLensRecipeWrapper.java @@ -1,20 +1,32 @@ +/* + * This class is 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 + */ package vazkii.botania.client.integration.jei.crafting; import com.google.common.collect.ImmutableList; + import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.category.extensions.vanilla.crafting.ICustomCraftingCategoryExtension; + import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.tags.ItemTags; import net.minecraft.util.ResourceLocation; + import vazkii.botania.common.crafting.recipe.CompositeLensRecipe; import vazkii.botania.common.item.lens.ItemLens; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -43,10 +55,10 @@ public class CompositeLensRecipeWrapper implements ICustomCraftingCategoryExtens public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IIngredients ingredients) { recipeLayout.getItemStacks().set(ingredients); recipeLayout.setShapeless(); - if(recipeLayout.getFocus() != null) { + if (recipeLayout.getFocus() != null) { ItemStack stack = (ItemStack) recipeLayout.getFocus().getValue(); int idx = lenses.indexOf(stack.getItem()); - if(idx != -1) { + if (idx != -1) { setLenses(recipeLayout, idx, idx); return; } @@ -59,17 +71,19 @@ public class CompositeLensRecipeWrapper implements ICustomCraftingCategoryExtens List secondInput = new ArrayList<>(); List outputs = new ArrayList<>(); - if(end >= lenses.size()) + if (end >= lenses.size()) { end = lenses.size() - 1; + } - for(int i = start; i <= end; i++) { + for (int i = start; i <= end; i++) { ItemStack firstLens = new ItemStack(lenses.get(i)); - for(Item secondLens : lenses) { - if(secondLens == firstLens.getItem()) + for (Item secondLens : lenses) { + if (secondLens == firstLens.getItem()) { continue; + } ItemStack secondLensStack = new ItemStack(secondLens); - if(((ItemLens) firstLens.getItem()).canCombineLenses(firstLens, secondLensStack)) { + if (((ItemLens) firstLens.getItem()).canCombineLenses(firstLens, secondLensStack)) { firstInput.add(firstLens); secondInput.add(secondLensStack); outputs.add(((ItemLens) firstLens.getItem()).setCompositeLens(firstLens.copy(), secondLensStack)); diff --git a/src/main/java/vazkii/botania/client/integration/jei/crafting/TerraPickTippingRecipeWrapper.java b/src/main/java/vazkii/botania/client/integration/jei/crafting/TerraPickTippingRecipeWrapper.java index a6f67c756..36c6ddbf2 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/crafting/TerraPickTippingRecipeWrapper.java +++ b/src/main/java/vazkii/botania/client/integration/jei/crafting/TerraPickTippingRecipeWrapper.java @@ -1,32 +1,44 @@ +/* + * This class is 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 + */ package vazkii.botania.client.integration.jei.crafting; import com.google.common.collect.ImmutableList; + import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.category.extensions.vanilla.crafting.ICraftingCategoryExtension; + import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; + import vazkii.botania.common.crafting.recipe.TerraPickTippingRecipe; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.terrasteel.ItemTerraPick; import javax.annotation.Nonnull; import javax.annotation.Nullable; + import java.util.List; public class TerraPickTippingRecipeWrapper implements ICraftingCategoryExtension { private final List> inputs; private final ItemStack output; private final ResourceLocation name; - + public TerraPickTippingRecipeWrapper(TerraPickTippingRecipe recipe) { inputs = ImmutableList.of(ImmutableList.of(new ItemStack(ModItems.terraPick)), ImmutableList.of(new ItemStack(ModItems.elementiumPick))); output = new ItemStack(ModItems.terraPick); ItemTerraPick.setTipped(output); - + this.name = recipe.getId(); } - + @Override public void setIngredients(@Nonnull IIngredients ingredients) { ingredients.setInputLists(VanillaTypes.ITEM, inputs); diff --git a/src/main/java/vazkii/botania/client/integration/jei/elventrade/ElvenTradeRecipeCategory.java b/src/main/java/vazkii/botania/client/integration/jei/elventrade/ElvenTradeRecipeCategory.java index 572b01b70..3f63d148d 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/elventrade/ElvenTradeRecipeCategory.java +++ b/src/main/java/vazkii/botania/client/integration/jei/elventrade/ElvenTradeRecipeCategory.java @@ -1,22 +1,23 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 */ package vazkii.botania.client.integration.jei.elventrade; import com.google.common.collect.ImmutableList; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; + import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.drawable.IDrawable; import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.category.IRecipeCategory; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.Tessellator; @@ -27,13 +28,16 @@ import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.recipe.RecipeElvenTrade; import vazkii.botania.client.core.handler.MiscellaneousIcons; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.Arrays; import java.util.List; @@ -85,8 +89,8 @@ public class ElvenTradeRecipeCategory implements IRecipeCategory> builder = ImmutableList.builder(); - for(Ingredient i : recipe.getInputs()) { - builder.add(Arrays.asList(i.getMatchingStacks())); + for (Ingredient i : recipe.getInputs()) { + builder.add(Arrays.asList(i.getMatchingStacks())); } iIngredients.setInputLists(VanillaTypes.ITEM, builder.build()); iIngredients.setOutputs(VanillaTypes.ITEM, ImmutableList.copyOf(recipe.getOutputs())); @@ -119,14 +123,14 @@ public class ElvenTradeRecipeCategory implements IRecipeCategory o : ingredients.getInputs(VanillaTypes.ITEM)) { + for (List o : ingredients.getInputs(VanillaTypes.ITEM)) { recipeLayout.getItemStacks().init(index, true, posX, 0); recipeLayout.getItemStacks().set(index, o); index++; posX += 18; } - for(int i = 0; i < ingredients.getOutputs(VanillaTypes.ITEM).size(); i++) { + for (int i = 0; i < ingredients.getOutputs(VanillaTypes.ITEM).size(); i++) { List stacks = ingredients.getOutputs(VanillaTypes.ITEM).get(i); recipeLayout.getItemStacks().init(index + i, false, 93 + i % 2 * 20, 41 + i / 2 * 20); recipeLayout.getItemStacks().set(index + i, stacks); diff --git a/src/main/java/vazkii/botania/client/integration/jei/manapool/ManaPoolRecipeCategory.java b/src/main/java/vazkii/botania/client/integration/jei/manapool/ManaPoolRecipeCategory.java index aadb7fbca..ed18f94e4 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/manapool/ManaPoolRecipeCategory.java +++ b/src/main/java/vazkii/botania/client/integration/jei/manapool/ManaPoolRecipeCategory.java @@ -1,27 +1,29 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 */ package vazkii.botania.client.integration.jei.manapool; import com.google.common.collect.ImmutableList; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; + import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.drawable.IDrawable; import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.category.IRecipeCategory; + import net.minecraft.block.Block; import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.util.ResourceLocation; + import vazkii.botania.api.recipe.RecipeManaInfusion; import vazkii.botania.client.core.handler.HUDHandler; import vazkii.botania.common.block.ModBlocks; @@ -30,6 +32,7 @@ import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.Arrays; import java.util.List; @@ -87,7 +90,7 @@ public class ManaPoolRecipeCategory implements IRecipeCategory 1) { + if (ingredients.getInputs(VanillaTypes.ITEM).size() > 1) { // Has catalyst recipeLayout.getItemStacks().init(index, true, 20, 12); recipeLayout.getItemStacks().set(index, ingredients.getInputs(VanillaTypes.ITEM).get(1)); diff --git a/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidIgnemRecipeCategory.java b/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidIgnemRecipeCategory.java index 0a450535a..ed5d05e6d 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidIgnemRecipeCategory.java +++ b/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidIgnemRecipeCategory.java @@ -1,23 +1,26 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 */ package vazkii.botania.client.integration.jei.orechid; import mezz.jei.api.helpers.IGuiHelper; + import net.minecraft.block.Blocks; import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.common.block.ModSubtiles; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.Map; public class OrechidIgnemRecipeCategory extends OrechidRecipeCategoryBase { @@ -25,7 +28,7 @@ public class OrechidIgnemRecipeCategory extends OrechidRecipeCategoryBase. It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 */ diff --git a/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeCategory.java b/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeCategory.java index 57ce70a12..296be0f6c 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeCategory.java +++ b/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeCategory.java @@ -1,30 +1,33 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 */ package vazkii.botania.client.integration.jei.orechid; import mezz.jei.api.helpers.IGuiHelper; + import net.minecraft.block.Blocks; import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.common.block.ModSubtiles; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.Map; public class OrechidRecipeCategory extends OrechidRecipeCategoryBase { public static final ResourceLocation UID = new ResourceLocation(LibMisc.MOD_ID, "orechid"); - + public OrechidRecipeCategory(IGuiHelper guiHelper) { - super(guiHelper, new ItemStack(ModSubtiles.orechid), new ItemStack(Blocks.STONE, 64), + super(guiHelper, new ItemStack(ModSubtiles.orechid), new ItemStack(Blocks.STONE, 64), I18n.format("botania.nei.orechid")); } diff --git a/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeCategoryBase.java b/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeCategoryBase.java index aed0837a5..4453a47c9 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeCategoryBase.java +++ b/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeCategoryBase.java @@ -1,15 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 */ package vazkii.botania.client.integration.jei.orechid; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; + import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.drawable.IDrawable; @@ -18,14 +18,16 @@ import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.category.IRecipeCategory; -import net.minecraft.block.Blocks; + import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.tags.BlockTags; import net.minecraft.util.ResourceLocation; + import vazkii.botania.client.integration.jei.JEIBotaniaPlugin; import javax.annotation.Nonnull; + import java.util.Collections; import java.util.List; import java.util.Map; diff --git a/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeWrapper.java b/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeWrapper.java index feb3658b3..17f126892 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeWrapper.java +++ b/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeWrapper.java @@ -1,8 +1,8 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 */ @@ -11,6 +11,7 @@ package vazkii.botania.client.integration.jei.orechid; import net.minecraft.util.ResourceLocation; import javax.annotation.Nonnull; + import java.util.Map; // This only exists to hold the map entry diff --git a/src/main/java/vazkii/botania/client/integration/jei/petalapothecary/PetalApothecaryRecipeCategory.java b/src/main/java/vazkii/botania/client/integration/jei/petalapothecary/PetalApothecaryRecipeCategory.java index b0a2bb238..c63215e17 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/petalapothecary/PetalApothecaryRecipeCategory.java +++ b/src/main/java/vazkii/botania/client/integration/jei/petalapothecary/PetalApothecaryRecipeCategory.java @@ -1,15 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 */ package vazkii.botania.client.integration.jei.petalapothecary; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; + import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.drawable.IDrawable; @@ -17,15 +17,18 @@ import mezz.jei.api.gui.drawable.IDrawableStatic; import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.category.IRecipeCategory; + import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.ResourceLocation; + import vazkii.botania.api.recipe.RecipePetals; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.awt.*; import java.util.ArrayList; import java.util.Arrays; @@ -80,7 +83,7 @@ public class PetalApothecaryRecipeCategory implements IRecipeCategory> list = new ArrayList<>(); - for(Ingredient ingr : recipe.getInputs()) { + for (Ingredient ingr : recipe.getInputs()) { list.add(Arrays.asList(ingr.getMatchingStacks())); } iIngredients.setInputLists(VanillaTypes.ITEM, list); @@ -105,7 +108,7 @@ public class PetalApothecaryRecipeCategory implements IRecipeCategory o : ingredients.getInputs(VanillaTypes.ITEM)) { + for (List o : ingredients.getInputs(VanillaTypes.ITEM)) { recipeLayout.getItemStacks().init(index, true, point.x, point.y); recipeLayout.getItemStacks().set(index, o); index += 1; diff --git a/src/main/java/vazkii/botania/client/integration/jei/puredaisy/PureDaisyRecipeCategory.java b/src/main/java/vazkii/botania/client/integration/jei/puredaisy/PureDaisyRecipeCategory.java index bc982b006..66b27392c 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/puredaisy/PureDaisyRecipeCategory.java +++ b/src/main/java/vazkii/botania/client/integration/jei/puredaisy/PureDaisyRecipeCategory.java @@ -1,21 +1,22 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 */ package vazkii.botania.client.integration.jei.puredaisy; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; + import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.drawable.IDrawable; import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.category.IRecipeCategory; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.FlowingFluidBlock; @@ -25,11 +26,13 @@ import net.minecraft.item.Items; import net.minecraft.tags.Tag; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.FluidStack; + import vazkii.botania.api.recipe.RecipePureDaisy; import vazkii.botania.common.block.ModSubtiles; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.Collection; import java.util.Collections; import java.util.stream.Collectors; @@ -82,27 +85,29 @@ public class PureDaisyRecipeCategory implements IRecipeCategory @Override public void setIngredients(RecipePureDaisy recipe, IIngredients iIngredients) { - if(recipe.getInput() instanceof Tag) { + if (recipe.getInput() instanceof Tag) { Collection all = ((Tag) recipe.getInput()).getAllElements(); iIngredients.setInputLists(VanillaTypes.ITEM, Collections.singletonList(all.stream().map(ItemStack::new).filter(s -> !s.isEmpty()).collect(Collectors.toList()))); - } else if(recipe.getInput() instanceof Block || recipe.getInput() instanceof BlockState) { + } else if (recipe.getInput() instanceof Block || recipe.getInput() instanceof BlockState) { BlockState state = recipe.getInput() instanceof BlockState ? (BlockState) recipe.getInput() : ((Block) recipe.getInput()).getDefaultState(); Block b = state.getBlock(); if (b instanceof FlowingFluidBlock) { iIngredients.setInput(VanillaTypes.FLUID, new FluidStack(((FlowingFluidBlock) b).getFluid(), 1000)); } else { - if(b.asItem() != Items.AIR) - iIngredients.setInput(VanillaTypes.ITEM, new ItemStack(b)); + if (b.asItem() != Items.AIR) { + iIngredients.setInput(VanillaTypes.ITEM, new ItemStack(b)); + } } } Block outBlock = recipe.getOutputState().getBlock(); - if(outBlock instanceof FlowingFluidBlock) { + if (outBlock instanceof FlowingFluidBlock) { iIngredients.setOutput(VanillaTypes.FLUID, new FluidStack(((FlowingFluidBlock) outBlock).getFluid(), 1000)); } else { - if(outBlock.asItem() != Items.AIR) - iIngredients.setOutput(VanillaTypes.ITEM, new ItemStack(outBlock)); + if (outBlock.asItem() != Items.AIR) { + iIngredients.setOutput(VanillaTypes.ITEM, new ItemStack(outBlock)); + } } } @@ -120,7 +125,7 @@ public class PureDaisyRecipeCategory implements IRecipeCategory boolean inputFluid = !ingredients.getInputs(VanillaTypes.FLUID).isEmpty(); boolean outputFluid = !ingredients.getOutputs(VanillaTypes.FLUID).isEmpty(); - if(inputFluid) { + if (inputFluid) { recipeLayout.getFluidStacks().init(0, true, 40, 12, 16, 16, 1000, false, null); recipeLayout.getFluidStacks().set(0, ingredients.getInputs(VanillaTypes.FLUID).get(0)); } else { @@ -131,7 +136,7 @@ public class PureDaisyRecipeCategory implements IRecipeCategory recipeLayout.getItemStacks().init(1, true, 70, 12); recipeLayout.getItemStacks().set(1, new ItemStack(ModSubtiles.pureDaisy)); - if(outputFluid) { + if (outputFluid) { recipeLayout.getFluidStacks().init(2, false, 99, 12, 16, 16, 1000, false, null); recipeLayout.getFluidStacks().set(2, ingredients.getOutputs(VanillaTypes.FLUID).get(0)); } else { diff --git a/src/main/java/vazkii/botania/client/integration/jei/runicaltar/RunicAltarRecipeCategory.java b/src/main/java/vazkii/botania/client/integration/jei/runicaltar/RunicAltarRecipeCategory.java index b627842a8..38c2b0d3c 100644 --- a/src/main/java/vazkii/botania/client/integration/jei/runicaltar/RunicAltarRecipeCategory.java +++ b/src/main/java/vazkii/botania/client/integration/jei/runicaltar/RunicAltarRecipeCategory.java @@ -1,25 +1,27 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 */ package vazkii.botania.client.integration.jei.runicaltar; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; + import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.drawable.IDrawable; import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.category.IRecipeCategory; + import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.ResourceLocation; + import vazkii.botania.api.recipe.RecipeRuneAltar; import vazkii.botania.client.core.handler.HUDHandler; import vazkii.botania.common.block.ModBlocks; @@ -27,6 +29,7 @@ import vazkii.botania.common.block.tile.mana.TilePool; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.awt.*; import java.util.ArrayList; import java.util.Arrays; @@ -81,7 +84,7 @@ public class RunicAltarRecipeCategory implements IRecipeCategory> list = new ArrayList<>(); - for(Ingredient ingr : recipe.getInputs()) { + for (Ingredient ingr : recipe.getInputs()) { list.add(Arrays.asList(ingr.getMatchingStacks())); } iIngredients.setInputLists(VanillaTypes.ITEM, list); @@ -107,7 +110,7 @@ public class RunicAltarRecipeCategory implements IRecipeCategory o : ingredients.getInputs(VanillaTypes.ITEM)) { + for (List o : ingredients.getInputs(VanillaTypes.ITEM)) { recipeLayout.getItemStacks().init(index, true, point.x, point.y); recipeLayout.getItemStacks().set(index, o); index += 1; diff --git a/src/main/java/vazkii/botania/client/lib/LibResources.java b/src/main/java/vazkii/botania/client/lib/LibResources.java index bb1d6dea2..9ef62399e 100644 --- a/src/main/java/vazkii/botania/client/lib/LibResources.java +++ b/src/main/java/vazkii/botania/client/lib/LibResources.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 14, 2014, 5:29:31 PM (GMT)] */ package vazkii.botania.client.lib; diff --git a/src/main/java/vazkii/botania/client/model/FloatingFlowerModel.java b/src/main/java/vazkii/botania/client/model/FloatingFlowerModel.java index e8f5bee11..511957697 100644 --- a/src/main/java/vazkii/botania/client/model/FloatingFlowerModel.java +++ b/src/main/java/vazkii/botania/client/model/FloatingFlowerModel.java @@ -1,9 +1,18 @@ +/* + * This class is 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 + */ package vazkii.botania.client.model; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.datafixers.util.Pair; + import net.minecraft.block.BlockState; import net.minecraft.client.renderer.TransformationMatrix; import net.minecraft.client.renderer.Vector3f; @@ -17,7 +26,6 @@ import net.minecraft.client.renderer.model.ItemOverrideList; import net.minecraft.client.renderer.model.Material; import net.minecraft.client.renderer.model.ModelBakery; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.resources.IResourceManager; import net.minecraft.util.Direction; import net.minecraft.util.ResourceLocation; @@ -29,12 +37,14 @@ import net.minecraftforge.client.model.SimpleModelTransform; import net.minecraftforge.client.model.data.EmptyModelData; import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.geometry.IModelGeometry; + import vazkii.botania.api.BotaniaAPIClient; import vazkii.botania.api.item.IFloatingFlower; import vazkii.botania.api.state.BotaniaStateProps; import javax.annotation.Nonnull; import javax.annotation.Nullable; + import java.util.ArrayList; import java.util.Collection; import java.util.EnumMap; @@ -49,110 +59,110 @@ import java.util.function.Function; import static vazkii.botania.common.lib.ResourceLocationHelper.prefix; public class FloatingFlowerModel implements IModelGeometry { - private IUnbakedModel unbakedFlower; - private final Map unbakedIslands = new HashMap<>(); + private IUnbakedModel unbakedFlower; + private final Map unbakedIslands = new HashMap<>(); - private FloatingFlowerModel(IUnbakedModel flower) { - this.unbakedFlower = flower; - } + private FloatingFlowerModel(IUnbakedModel flower) { + this.unbakedFlower = flower; + } - @Nonnull - @Override - public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { - Set ret = new HashSet<>(); - for (Map.Entry e : BotaniaAPIClient.getRegisteredIslandTypeModels().entrySet()) { - IUnbakedModel unbakedIsland = modelGetter.apply(e.getValue()); - ret.addAll(unbakedIsland.getTextureDependencies(modelGetter, missingTextureErrors)); - unbakedIslands.put(e.getKey(), unbakedIsland); - } - ret.addAll(unbakedFlower.getTextureDependencies(modelGetter, missingTextureErrors)); - return ret; - } + @Nonnull + @Override + public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { + Set ret = new HashSet<>(); + for (Map.Entry e : BotaniaAPIClient.getRegisteredIslandTypeModels().entrySet()) { + IUnbakedModel unbakedIsland = modelGetter.apply(e.getValue()); + ret.addAll(unbakedIsland.getTextureDependencies(modelGetter, missingTextureErrors)); + unbakedIslands.put(e.getKey(), unbakedIsland); + } + ret.addAll(unbakedFlower.getTextureDependencies(modelGetter, missingTextureErrors)); + return ret; + } - @Nullable - @Override - public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, IModelTransform transform, ItemOverrideList overrides, ResourceLocation name) { - final TransformationMatrix moveFlower = new TransformationMatrix(new Vector3f(0F, 0.2F, 0F), null, new Vector3f(0.5F, 0.5F, 0.5F), null); - IModelTransform comp = new ModelTransformComposition(new SimpleModelTransform(moveFlower), transform); - IBakedModel bakedFlower = unbakedFlower.bake(bakery, spriteGetter, comp, name); + @Nullable + @Override + public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, IModelTransform transform, ItemOverrideList overrides, ResourceLocation name) { + final TransformationMatrix moveFlower = new TransformationMatrix(new Vector3f(0F, 0.2F, 0F), null, new Vector3f(0.5F, 0.5F, 0.5F), null); + IModelTransform comp = new ModelTransformComposition(new SimpleModelTransform(moveFlower), transform); + IBakedModel bakedFlower = unbakedFlower.bake(bakery, spriteGetter, comp, name); - Map bakedIslands = new HashMap<>(); - for (Map.Entry e : unbakedIslands.entrySet()) { - IBakedModel bakedIsland = e.getValue().bake(bakery, spriteGetter, transform, name); - bakedIslands.put(e.getKey(), bakedIsland); - } - return new Baked(bakedFlower, bakedIslands); - } + Map bakedIslands = new HashMap<>(); + for (Map.Entry e : unbakedIslands.entrySet()) { + IBakedModel bakedIsland = e.getValue().bake(bakery, spriteGetter, transform, name); + bakedIslands.put(e.getKey(), bakedIsland); + } + return new Baked(bakedFlower, bakedIslands); + } - public static class Baked extends BakedModelWrapper { - private final Map> genQuads = new HashMap<>(); - private final Map>> faceQuads = new HashMap<>(); + public static class Baked extends BakedModelWrapper { + private final Map> genQuads = new HashMap<>(); + private final Map>> faceQuads = new HashMap<>(); - Baked(IBakedModel flower, Map islands) { - super(flower); - Random rand = new Random(); - for (Map.Entry e : islands.entrySet()) { - rand.setSeed(42); - List gen = new ArrayList<>(flower.getQuads(null, null, rand, EmptyModelData.INSTANCE)); - rand.setSeed(42); - gen.addAll(e.getValue().getQuads(null, null, rand, EmptyModelData.INSTANCE)); - genQuads.put(e.getKey(), gen); + Baked(IBakedModel flower, Map islands) { + super(flower); + Random rand = new Random(); + for (Map.Entry e : islands.entrySet()) { + rand.setSeed(42); + List gen = new ArrayList<>(flower.getQuads(null, null, rand, EmptyModelData.INSTANCE)); + rand.setSeed(42); + gen.addAll(e.getValue().getQuads(null, null, rand, EmptyModelData.INSTANCE)); + genQuads.put(e.getKey(), gen); - Map> fq = new EnumMap<>(Direction.class); - for (Direction dir : Direction.values()) { - rand.setSeed(42); - List lst = new ArrayList<>(flower.getQuads(null, dir, rand, EmptyModelData.INSTANCE)); - rand.setSeed(42); - lst.addAll(e.getValue().getQuads(null, dir, rand, EmptyModelData.INSTANCE)); - fq.put(dir, lst); - } - faceQuads.put(e.getKey(), fq); - } - } + Map> fq = new EnumMap<>(Direction.class); + for (Direction dir : Direction.values()) { + rand.setSeed(42); + List lst = new ArrayList<>(flower.getQuads(null, dir, rand, EmptyModelData.INSTANCE)); + rand.setSeed(42); + lst.addAll(e.getValue().getQuads(null, dir, rand, EmptyModelData.INSTANCE)); + fq.put(dir, lst); + } + faceQuads.put(e.getKey(), fq); + } + } - @Nonnull - @Override - public List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand) { - // Default to GRASS island - return getQuads(state, side, rand, EmptyModelData.INSTANCE); - } + @Nonnull + @Override + public List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand) { + // Default to GRASS island + return getQuads(state, side, rand, EmptyModelData.INSTANCE); + } - @Nonnull - @Override - public List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) { - IFloatingFlower.IslandType type = IFloatingFlower.IslandType.GRASS; - if (extraData.hasProperty(BotaniaStateProps.FLOATING_DATA)) { - type = extraData.getData(BotaniaStateProps.FLOATING_DATA).getIslandType(); - } + @Nonnull + @Override + public List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) { + IFloatingFlower.IslandType type = IFloatingFlower.IslandType.GRASS; + if (extraData.hasProperty(BotaniaStateProps.FLOATING_DATA)) { + type = extraData.getData(BotaniaStateProps.FLOATING_DATA).getIslandType(); + } - if (side == null) { - return genQuads.get(type); - } else { - return faceQuads.get(type).get(side); - } - } + if (side == null) { + return genQuads.get(type); + } else { + return faceQuads.get(type).get(side); + } + } - @Nonnull - @Override - public IBakedModel handlePerspective(@Nonnull ItemCameraTransforms.TransformType cameraTransformType, MatrixStack ms) { - super.handlePerspective(cameraTransformType, ms); - return this; - } - } + @Nonnull + @Override + public IBakedModel handlePerspective(@Nonnull ItemCameraTransforms.TransformType cameraTransformType, MatrixStack ms) { + super.handlePerspective(cameraTransformType, ms); + return this; + } + } - public enum Loader implements IModelLoader { - INSTANCE; + public enum Loader implements IModelLoader { + INSTANCE; - public static final ResourceLocation ID = prefix("floating_flower"); + public static final ResourceLocation ID = prefix("floating_flower"); - @Override - public void onResourceManagerReload(@Nonnull IResourceManager resourceManager) {} + @Override + public void onResourceManagerReload(@Nonnull IResourceManager resourceManager) {} - @Nonnull - @Override - public FloatingFlowerModel read(JsonDeserializationContext ctx, JsonObject model) { - BlockModel flower = ctx.deserialize(model.getAsJsonObject("flower"), BlockModel.class); - return new FloatingFlowerModel(flower); - } - } + @Nonnull + @Override + public FloatingFlowerModel read(JsonDeserializationContext ctx, JsonObject model) { + BlockModel flower = ctx.deserialize(model.getAsJsonObject("flower"), BlockModel.class); + return new FloatingFlowerModel(flower); + } + } } diff --git a/src/main/java/vazkii/botania/client/model/GunModel.java b/src/main/java/vazkii/botania/client/model/GunModel.java index ded5dfd84..ae8d03dc4 100644 --- a/src/main/java/vazkii/botania/client/model/GunModel.java +++ b/src/main/java/vazkii/botania/client/model/GunModel.java @@ -1,7 +1,16 @@ +/* + * This class is 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 + */ package vazkii.botania.client.model; import com.google.common.base.Preconditions; import com.mojang.blaze3d.matrix.MatrixStack; + import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.TransformationMatrix; @@ -17,28 +26,25 @@ import net.minecraft.client.renderer.model.ItemOverrideList; import net.minecraft.client.renderer.model.ModelBakery; import net.minecraft.client.renderer.model.ModelResourceLocation; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.entity.LivingEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.resources.IResource; import net.minecraft.util.Direction; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.client.model.BakedModelWrapper; import net.minecraftforge.client.model.ModelLoader; -import net.minecraftforge.client.model.ModelLoaderRegistry; import net.minecraftforge.client.model.SimpleModelTransform; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; + import org.apache.commons.lang3.tuple.Pair; -import vazkii.botania.common.Botania; + import vazkii.botania.common.item.ItemManaGun; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import java.io.IOException; -import java.io.InputStreamReader; + import java.util.ArrayList; import java.util.EnumMap; import java.util.HashMap; @@ -73,9 +79,11 @@ public class GunModel implements IBakedModel { } ItemStack lens = ItemManaGun.getLens(stack); - if(!lens.isEmpty()) { + if (!lens.isEmpty()) { return GunModel.this.getModel(lens, clip); - } else return clip ? originalModelClip : originalModel; + } else { + return clip ? originalModelClip : originalModel; + } } }; @@ -85,13 +93,43 @@ public class GunModel implements IBakedModel { return itemHandler; } - @Nonnull @Override public List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand) { return originalModel.getQuads(state, side, rand); } - @Override public boolean isAmbientOcclusion() { return originalModel.isAmbientOcclusion(); } - @Override public boolean isGui3d() { return originalModel.isGui3d(); } - @Override public boolean isBuiltInRenderer() { return originalModel.isBuiltInRenderer(); } - @Nonnull @Override public TextureAtlasSprite getParticleTexture() { return originalModel.getParticleTexture(); } - @Nonnull @Override public ItemCameraTransforms getItemCameraTransforms() { return originalModel.getItemCameraTransforms(); } - @Override public boolean isSideLit() { return originalModel.isSideLit(); } + @Nonnull + @Override + public List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand) { + return originalModel.getQuads(state, side, rand); + } + + @Override + public boolean isAmbientOcclusion() { + return originalModel.isAmbientOcclusion(); + } + + @Override + public boolean isGui3d() { + return originalModel.isGui3d(); + } + + @Override + public boolean isBuiltInRenderer() { + return originalModel.isBuiltInRenderer(); + } + + @Nonnull + @Override + public TextureAtlasSprite getParticleTexture() { + return originalModel.getParticleTexture(); + } + + @Nonnull + @Override + public ItemCameraTransforms getItemCameraTransforms() { + return originalModel.getItemCameraTransforms(); + } + + @Override + public boolean isSideLit() { + return originalModel.isSideLit(); + } private final HashMap, CompositeBakedModel> cache = new HashMap<>(); @@ -122,13 +160,14 @@ public class GunModel implements IBakedModel { lensBaked = lensUnbaked.bake(bakery, ModelLoader.defaultTextureGetter(), transform, name); } - for(Direction e : Direction.values()) + for (Direction e : Direction.values()) { faceQuads.put(e, new ArrayList<>()); + } Random rand = new Random(0); genQuads.addAll(lensBaked.getQuads(null, null, rand)); - for(Direction e : Direction.values()) { + for (Direction e : Direction.values()) { rand.setSeed(0); faceQuads.get(e).addAll(lensBaked.getQuads(null, e, rand)); } @@ -136,7 +175,7 @@ public class GunModel implements IBakedModel { // Add gun quads rand.setSeed(0); genQuads.addAll(gun.getQuads(null, null, rand)); - for(Direction e : Direction.values()) { + for (Direction e : Direction.values()) { rand.setSeed(0); faceQuads.get(e).addAll(gun.getQuads(null, e, rand)); } diff --git a/src/main/java/vazkii/botania/client/model/IPylonModel.java b/src/main/java/vazkii/botania/client/model/IPylonModel.java index cfe93a0e6..f78a21e99 100644 --- a/src/main/java/vazkii/botania/client/model/IPylonModel.java +++ b/src/main/java/vazkii/botania/client/model/IPylonModel.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.client.model; import com.mojang.blaze3d.matrix.MatrixStack; diff --git a/src/main/java/vazkii/botania/client/model/LexiconModel.java b/src/main/java/vazkii/botania/client/model/LexiconModel.java index 6293507fb..c8f86adf5 100644 --- a/src/main/java/vazkii/botania/client/model/LexiconModel.java +++ b/src/main/java/vazkii/botania/client/model/LexiconModel.java @@ -1,7 +1,16 @@ +/* + * This class is 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 + */ package vazkii.botania.client.model; import com.google.common.collect.ImmutableList; import com.mojang.blaze3d.matrix.MatrixStack; + import net.minecraft.block.BlockState; import net.minecraft.client.renderer.model.BakedQuad; import net.minecraft.client.renderer.model.IBakedModel; @@ -9,10 +18,11 @@ import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.client.renderer.model.ItemOverrideList; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.Direction; -import org.apache.commons.lang3.tuple.Pair; + import vazkii.botania.common.core.handler.ConfigHandler; import javax.annotation.Nonnull; + import java.util.List; import java.util.Random; @@ -26,19 +36,56 @@ public class LexiconModel implements IBakedModel { @Nonnull @Override public IBakedModel handlePerspective(ItemCameraTransforms.TransformType cameraTransformType, MatrixStack stack) { - if((cameraTransformType == ItemCameraTransforms.TransformType.FIRST_PERSON_RIGHT_HAND + if ((cameraTransformType == ItemCameraTransforms.TransformType.FIRST_PERSON_RIGHT_HAND || cameraTransformType == ItemCameraTransforms.TransformType.FIRST_PERSON_LEFT_HAND) - && ConfigHandler.CLIENT.lexicon3dModel.get()) + && ConfigHandler.CLIENT.lexicon3dModel.get()) { return this; + } return original.handlePerspective(cameraTransformType, stack); } - @Nonnull @Override public List getQuads(BlockState state, Direction side, @Nonnull Random rand) { return ImmutableList.of(); } - @Override public boolean isAmbientOcclusion() { return false; } - @Override public boolean isGui3d() { return false; } - @Override public boolean isBuiltInRenderer() { return false; } - @Override public boolean isSideLit() { return original.isSideLit(); } - @Nonnull @Override public TextureAtlasSprite getParticleTexture() { return original.getParticleTexture(); } - @SuppressWarnings("deprecation") @Nonnull @Override public ItemCameraTransforms getItemCameraTransforms() { return ItemCameraTransforms.DEFAULT; } - @Nonnull @Override public ItemOverrideList getOverrides() { return original.getOverrides(); } + @Nonnull + @Override + public List getQuads(BlockState state, Direction side, @Nonnull Random rand) { + return ImmutableList.of(); + } + + @Override + public boolean isAmbientOcclusion() { + return false; + } + + @Override + public boolean isGui3d() { + return false; + } + + @Override + public boolean isBuiltInRenderer() { + return false; + } + + @Override + public boolean isSideLit() { + return original.isSideLit(); + } + + @Nonnull + @Override + public TextureAtlasSprite getParticleTexture() { + return original.getParticleTexture(); + } + + @SuppressWarnings("deprecation") + @Nonnull + @Override + public ItemCameraTransforms getItemCameraTransforms() { + return ItemCameraTransforms.DEFAULT; + } + + @Nonnull + @Override + public ItemOverrideList getOverrides() { + return original.getOverrides(); + } } diff --git a/src/main/java/vazkii/botania/client/model/ModelAvatar.java b/src/main/java/vazkii/botania/client/model/ModelAvatar.java index 5102a1214..b87b51866 100644 --- a/src/main/java/vazkii/botania/client/model/ModelAvatar.java +++ b/src/main/java/vazkii/botania/client/model/ModelAvatar.java @@ -1,19 +1,17 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [? (GMT)] */ package vazkii.botania.client.model; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.RenderTypeLookup; import net.minecraft.client.renderer.model.Model; import net.minecraft.client.renderer.model.ModelRenderer; @@ -70,4 +68,4 @@ public class ModelAvatar extends Model { modelRenderer.rotateAngleZ = z; } -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/client/model/ModelBellows.java b/src/main/java/vazkii/botania/client/model/ModelBellows.java index 895ae8055..6dde538c1 100644 --- a/src/main/java/vazkii/botania/client/model/ModelBellows.java +++ b/src/main/java/vazkii/botania/client/model/ModelBellows.java @@ -1,18 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 28, 2015, 5:16:17 PM (GMT)] */ package vazkii.botania.client.model; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.model.Model; @@ -29,20 +27,20 @@ public class ModelBellows extends Model { super(RenderType::getEntityCutout); textureWidth = 64; textureHeight = 32; - + top = new ModelRenderer(this, 0, 0); - top.setRotationPoint(0.0F, 16.0F, 0.0F); - top.addCuboid(-4.0F, -2.0F, -4.0F, 8, 1, 8, 0.0F); - base = new ModelRenderer(this, 0, 9); - base.setRotationPoint(0.0F, 16.0F, 0.0F); - base.addCuboid(-5.0F, 6.0F, -5.0F, 10, 2, 10, 0.0F); - pipe = new ModelRenderer(this, 0, 21); - pipe.setRotationPoint(0.0F, 16.0F, 0.0F); - pipe.addCuboid(-1.0F, 6.0F, -8.0F, 2, 2, 3, 0.0F); - - funnel = new ModelRenderer(this, 40, 0); - funnel.setRotationPoint(0.0F, 0.0F, 0.0F); - funnel.addCuboid(0.0F, 0.0F, 0.0F, 6, 7, 6, 0.0F); + top.setRotationPoint(0.0F, 16.0F, 0.0F); + top.addCuboid(-4.0F, -2.0F, -4.0F, 8, 1, 8, 0.0F); + base = new ModelRenderer(this, 0, 9); + base.setRotationPoint(0.0F, 16.0F, 0.0F); + base.addCuboid(-5.0F, 6.0F, -5.0F, 10, 2, 10, 0.0F); + pipe = new ModelRenderer(this, 0, 21); + pipe.setRotationPoint(0.0F, 16.0F, 0.0F); + pipe.addCuboid(-1.0F, 6.0F, -8.0F, 2, 2, 3, 0.0F); + + funnel = new ModelRenderer(this, 40, 0); + funnel.setRotationPoint(0.0F, 0.0F, 0.0F); + funnel.addCuboid(0.0F, 0.0F, 0.0F, 6, 7, 6, 0.0F); } @Override @@ -67,5 +65,4 @@ public class ModelBellows extends Model { ms.scale(1F, 1F / fract, 1F); } - } diff --git a/src/main/java/vazkii/botania/client/model/ModelBrewery.java b/src/main/java/vazkii/botania/client/model/ModelBrewery.java index dc9ab6d38..21bba297f 100644 --- a/src/main/java/vazkii/botania/client/model/ModelBrewery.java +++ b/src/main/java/vazkii/botania/client/model/ModelBrewery.java @@ -1,18 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Oct 31, 2014, 4:33:55 PM (GMT)] */ package vazkii.botania.client.model; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.RenderType; @@ -21,6 +19,7 @@ import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.client.renderer.model.Model; import net.minecraft.client.renderer.model.ModelRenderer; import net.minecraft.item.ItemStack; + import vazkii.botania.client.render.tile.RenderTileBrewery; import vazkii.botania.common.block.tile.TileBrewery; @@ -31,7 +30,7 @@ public class ModelBrewery extends Model { final ModelRenderer top; final ModelRenderer pole; final ModelRenderer bottom; - + final ModelRenderer plate; public ModelBrewery() { @@ -39,20 +38,20 @@ public class ModelBrewery extends Model { textureWidth = 32; textureHeight = 16; - + top = new ModelRenderer(this, 8, 0); - top.setRotationPoint(0.0F, 16.0F, 0.0F); - top.addCuboid(-2.0F, -7.0F, -2.0F, 4, 1, 4, 0.0F); + top.setRotationPoint(0.0F, 16.0F, 0.0F); + top.addCuboid(-2.0F, -7.0F, -2.0F, 4, 1, 4, 0.0F); pole = new ModelRenderer(this, 0, 0); - pole.setRotationPoint(0.0F, 16.0F, 0.0F); - pole.addCuboid(-1.0F, -6.0F, -1.0F, 2, 10, 2, 0.0F); - bottom = new ModelRenderer(this, 8, 5); - bottom.setRotationPoint(0.0F, 16.0F, 0.0F); - bottom.addCuboid(-2.0F, 4.0F, -2.0F, 4, 1, 4, 0.0F); - - plate = new ModelRenderer(this, 8, 5); - plate.setRotationPoint(0.0F, 17.0F, 0.0F); - plate.addCuboid(5.0F, 0.0F, -2.0F, 4, 1, 4, 0.0F); + pole.setRotationPoint(0.0F, 16.0F, 0.0F); + pole.addCuboid(-1.0F, -6.0F, -1.0F, 2, 10, 2, 0.0F); + bottom = new ModelRenderer(this, 8, 5); + bottom.setRotationPoint(0.0F, 16.0F, 0.0F); + bottom.addCuboid(-2.0F, 4.0F, -2.0F, 4, 1, 4, 0.0F); + + plate = new ModelRenderer(this, 8, 5); + plate.setRotationPoint(0.0F, 17.0F, 0.0F); + plate.addCuboid(5.0F, 0.0F, -2.0F, 4, 1, 4, 0.0F); } public void render(@Nullable TileBrewery brewery, double time, MatrixStack ms, IRenderTypeBuffer buffers, int light, int overlay) { @@ -64,7 +63,7 @@ public class ModelBrewery extends Model { ms.translate(0F, offset, 0F); ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(polerot)); - if(hasTile && !brewery.getItemHandler().getStackInSlot(0).isEmpty()) { + if (hasTile && !brewery.getItemHandler().getStackInSlot(0).isEmpty()) { ms.push(); ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(180)); ms.translate(0, -0.45F, 0); @@ -79,14 +78,15 @@ public class ModelBrewery extends Model { ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-polerot)); float degper = (float) (2F * Math.PI) / plates; - for(int i = 0; i < plates; i++) { + for (int i = 0; i < plates; i++) { plate.rotateAngleY = deg; float offset1 = (float) Math.sin(time / 20 + i * 40F) * 0.2F - 0.2F; - if(time == -1) + if (time == -1) { offset1 = 0F; + } ms.translate(0F, offset1, 0F); - if(hasTile && !brewery.getItemHandler().getStackInSlot(i + 1).isEmpty()) { + if (hasTile && !brewery.getItemHandler().getStackInSlot(i + 1).isEmpty()) { float rot = plate.rotateAngleY * 180F / (float) Math.PI; float transX = 0.3125F; float transY = 1.06F; @@ -108,7 +108,7 @@ public class ModelBrewery extends Model { } private void renderItemStack(ItemStack stack, MatrixStack ms, IRenderTypeBuffer buffers, int light, int overlay) { - if(!stack.isEmpty()) { + if (!stack.isEmpty()) { Minecraft mc = Minecraft.getInstance(); ms.push(); diff --git a/src/main/java/vazkii/botania/client/model/ModelCloak.java b/src/main/java/vazkii/botania/client/model/ModelCloak.java index 9d1cc08c7..298ef815f 100644 --- a/src/main/java/vazkii/botania/client/model/ModelCloak.java +++ b/src/main/java/vazkii/botania/client/model/ModelCloak.java @@ -1,7 +1,16 @@ +/* + * This class is 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 + */ package vazkii.botania.client.model; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.model.Model; import net.minecraft.client.renderer.model.ModelRenderer; @@ -15,28 +24,28 @@ public class ModelCloak extends Model { public ModelRenderer collar; public ModelRenderer sideL; public ModelRenderer sideR; - + public ModelCloak() { super(RenderType::getEntityCutout); textureWidth = 64; textureHeight = 64; float s = 0.01F; - + collar = new ModelRenderer(this, 0, 0); - collar.setRotationPoint(0.0F, -3.0F, -4.5F); - collar.addCuboid(-5.5F, 0.0F, -1.5F, 11, 5, 11, s); - setRotateAngle(collar, 0.08726646259971647F, 0.0F, 0.0F); + collar.setRotationPoint(0.0F, -3.0F, -4.5F); + collar.addCuboid(-5.5F, 0.0F, -1.5F, 11, 5, 11, s); + setRotateAngle(collar, 0.08726646259971647F, 0.0F, 0.0F); sideL = new ModelRenderer(this, 0, 16); - sideL.mirror = true; - sideL.setRotationPoint(0.0F, 0.0F, 0.0F); - sideL.addCuboid(-0.5F, -0.5F, -5.5F, 11, 21, 10, s); - setRotateAngle(sideL, 0.08726646259971647F, -0.08726646259971647F, -0.17453292519943295F); - sideR = new ModelRenderer(this, 0, 16); - sideR.setRotationPoint(0.0F, 0.0F, 0.0F); - sideR.addCuboid(-10.5F, -0.5F, -5.5F, 11, 21, 10, s); - setRotateAngle(sideR, 0.08726646259971647F, 0.08726646259971647F, 0.17453292519943295F); - + sideL.mirror = true; + sideL.setRotationPoint(0.0F, 0.0F, 0.0F); + sideL.addCuboid(-0.5F, -0.5F, -5.5F, 11, 21, 10, s); + setRotateAngle(sideL, 0.08726646259971647F, -0.08726646259971647F, -0.17453292519943295F); + sideR = new ModelRenderer(this, 0, 16); + sideR.setRotationPoint(0.0F, 0.0F, 0.0F); + sideR.addCuboid(-10.5F, -0.5F, -5.5F, 11, 21, 10, s); + setRotateAngle(sideR, 0.08726646259971647F, 0.08726646259971647F, 0.17453292519943295F); + } @Override diff --git a/src/main/java/vazkii/botania/client/model/ModelHourglass.java b/src/main/java/vazkii/botania/client/model/ModelHourglass.java index 9b4ce3a6e..bd8e29458 100644 --- a/src/main/java/vazkii/botania/client/model/ModelHourglass.java +++ b/src/main/java/vazkii/botania/client/model/ModelHourglass.java @@ -1,65 +1,60 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [? (GMT)] */ package vazkii.botania.client.model; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.model.Model; import net.minecraft.client.renderer.model.ModelRenderer; -import org.lwjgl.opengl.GL11; - -import java.awt.*; public class ModelHourglass extends Model { - public ModelRenderer top; - public ModelRenderer glassT; + public ModelRenderer top; + public ModelRenderer glassT; public ModelRenderer ring; - public ModelRenderer glassB; - public ModelRenderer bottom; - - public ModelRenderer sandT; - public ModelRenderer sandB; + public ModelRenderer glassB; + public ModelRenderer bottom; + + public ModelRenderer sandT; + public ModelRenderer sandB; public ModelHourglass() { super(RenderType::getEntityTranslucent); - + textureWidth = 64; textureHeight = 32; - top = new ModelRenderer(this, 20, 0); - top.setRotationPoint(0.0F, 0.0F, 0.0F); - top.addCuboid(-3.0F, -6.5F, -3.0F, 6, 1, 6, 0.0F); + top = new ModelRenderer(this, 20, 0); + top.setRotationPoint(0.0F, 0.0F, 0.0F); + top.addCuboid(-3.0F, -6.5F, -3.0F, 6, 1, 6, 0.0F); glassT = new ModelRenderer(this, 0, 0); - glassT.setRotationPoint(0.0F, 0.0F, 0.0F); - glassT.addCuboid(-2.5F, -5.5F, -2.5F, 5, 5, 5, 0.0F); - ring = new ModelRenderer(this, 0, 20); - ring.setRotationPoint(0.0F, 0.0F, 0.0F); - ring.addCuboid(-1.5F, -0.5F, -1.5F, 3, 1, 3, 0.0F); - glassB = new ModelRenderer(this, 0, 10); - glassB.setRotationPoint(0.0F, 0.0F, 0.0F); - glassB.addCuboid(-2.5F, 0.5F, -2.5F, 5, 5, 5, 0.0F); - bottom = new ModelRenderer(this, 20, 7); - bottom.setRotationPoint(0.0F, 0.0F, 0.0F); - bottom.addCuboid(-3.0F, 5.5F, -3.0F, 6, 1, 6, 0.0F); - - sandT = new ModelRenderer(this, 20, 14); - sandT.setRotationPoint(0.0F, 0.0F, 0.0F); - sandT.addCuboid(0.0F, 0.0F, 0.0F, 4, 4, 4, 0.0F); // -2.0F, -5.0F, -2.0F - sandB = new ModelRenderer(this, 20, 14); - sandB.setRotationPoint(0.0F, 0.0F, 0.0F); - sandB.addCuboid(0.0F, 0.0F, 0.0F, 4, 4, 4, 0.0F); // -2.0F, 1.0F, -2.05F + glassT.setRotationPoint(0.0F, 0.0F, 0.0F); + glassT.addCuboid(-2.5F, -5.5F, -2.5F, 5, 5, 5, 0.0F); + ring = new ModelRenderer(this, 0, 20); + ring.setRotationPoint(0.0F, 0.0F, 0.0F); + ring.addCuboid(-1.5F, -0.5F, -1.5F, 3, 1, 3, 0.0F); + glassB = new ModelRenderer(this, 0, 10); + glassB.setRotationPoint(0.0F, 0.0F, 0.0F); + glassB.addCuboid(-2.5F, 0.5F, -2.5F, 5, 5, 5, 0.0F); + bottom = new ModelRenderer(this, 20, 7); + bottom.setRotationPoint(0.0F, 0.0F, 0.0F); + bottom.addCuboid(-3.0F, 5.5F, -3.0F, 6, 1, 6, 0.0F); + + sandT = new ModelRenderer(this, 20, 14); + sandT.setRotationPoint(0.0F, 0.0F, 0.0F); + sandT.addCuboid(0.0F, 0.0F, 0.0F, 4, 4, 4, 0.0F); // -2.0F, -5.0F, -2.0F + sandB = new ModelRenderer(this, 20, 14); + sandB.setRotationPoint(0.0F, 0.0F, 0.0F); + sandB.addCuboid(0.0F, 0.0F, 0.0F, 4, 4, 4, 0.0F); // -2.0F, 1.0F, -2.05F } @Override @@ -68,7 +63,7 @@ public class ModelHourglass extends Model { } public void render(MatrixStack ms, IVertexBuilder buffer, int light, int overlay, float r, float g, float b, float a, float fract1, float fract2, boolean flip) { - if(flip) { + if (flip) { float tmp = fract1; fract1 = fract2; fract2 = tmp; @@ -79,11 +74,11 @@ public class ModelHourglass extends Model { top.render(ms, buffer, light, overlay, 1, 1, 1, a); bottom.render(ms, buffer, light, overlay, 1, 1, 1, a); - if(fract1 > 0) { - ms.push(); - if(flip) + if (fract1 > 0) { + ms.push(); + if (flip) { ms.translate(-2.0F * f, 1.0F * f, -2.0F * f); - else { + } else { ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(180F)); ms.translate(-2.0F * f, -5.0F * f, -2.0F * f); } @@ -92,11 +87,11 @@ public class ModelHourglass extends Model { ms.pop(); } - if(fract2 > 0) { + if (fract2 > 0) { ms.push(); - if(flip) + if (flip) { ms.translate(-2.0F * f, -5.0F * f, -2.0F * f); - else { + } else { ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(180F)); ms.translate(-2.0F * f, 1.0F * f, -2.0F * f); } diff --git a/src/main/java/vazkii/botania/client/model/ModelPixie.java b/src/main/java/vazkii/botania/client/model/ModelPixie.java index 1fe73a787..9c7a91043 100644 --- a/src/main/java/vazkii/botania/client/model/ModelPixie.java +++ b/src/main/java/vazkii/botania/client/model/ModelPixie.java @@ -1,22 +1,22 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [? (GMT)] */ package vazkii.botania.client.model; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.entity.model.EntityModel; import net.minecraft.client.renderer.model.ModelRenderer; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; + import vazkii.botania.client.core.helper.ShaderHelper; import vazkii.botania.client.core.helper.ShaderWrappedRenderLayer; import vazkii.botania.client.render.entity.RenderPixie; @@ -24,48 +24,49 @@ import vazkii.botania.common.entity.EntityPixie; public class ModelPixie extends EntityModel { public ModelRenderer body; - public ModelRenderer leftWingT; - public ModelRenderer leftWingB; - public ModelRenderer rightWingT; - public ModelRenderer rightWingB; + public ModelRenderer leftWingT; + public ModelRenderer leftWingB; + public ModelRenderer rightWingT; + public ModelRenderer rightWingB; private static boolean evil = false; - private static RenderType pixieLayer(ResourceLocation texture) { - RenderType normal = RenderType.getEntityCutoutNoCull(texture); - return evil - ? new ShaderWrappedRenderLayer(ShaderHelper.BotaniaShader.DOPPLEGANGER, RenderPixie.SHADER_CALLBACK, normal) - : normal; - } - public ModelPixie() { - super(ModelPixie::pixieLayer); - textureWidth = 32; - textureHeight = 32; - - body = new ModelRenderer(this, 0, 0); - body.setRotationPoint(0.0F, 16.0F, 0.0F); - body.addCuboid(-2.5F, 0.0F, -2.5F, 5, 5, 5, 0.0F); - - leftWingT = new ModelRenderer(this, 0, 4); - leftWingT.setRotationPoint(2.5F, 18.0F, 0.5F); - leftWingT.addCuboid(0.0F, -5.0F, 0.0F, 0, 5, 6, 0.0F); - setRotateAngle(leftWingT, 0.2617993877991494F, 0.5235987755982988F, 0.2617993877991494F); - leftWingB = new ModelRenderer(this, 0, 11); - leftWingB.setRotationPoint(2.5F, 18.0F, 0.5F); - leftWingB.addCuboid(0.0F, 0.0F, 0.0F, 0, 3, 4, 0.0F); - setRotateAngle(leftWingB, -0.2617993877991494F, 0.2617993877991494F, -0.2617993877991494F); - rightWingT = new ModelRenderer(this, 0, 4); - rightWingT.setRotationPoint(-2.5F, 18.0F, 0.5F); - rightWingT.addCuboid(0.0F, -5.0F, 0.0F, 0, 5, 6, 0.0F); - setRotateAngle(rightWingT, 0.2617993877991494F, -0.5235987755982988F, -0.2617993877991494F); - rightWingB = new ModelRenderer(this, 0, 11); - rightWingB.setRotationPoint(-2.5F, 18.0F, 0.5F); - rightWingB.addCuboid(0.0F, 0.0F, 0.0F, 0, 3, 4, 0.0F); - setRotateAngle(rightWingB, -0.2617993877991494F, -0.2617993877991494F, 0.2617993877991494F); - } + private static RenderType pixieLayer(ResourceLocation texture) { + RenderType normal = RenderType.getEntityCutoutNoCull(texture); + return evil + ? new ShaderWrappedRenderLayer(ShaderHelper.BotaniaShader.DOPPLEGANGER, RenderPixie.SHADER_CALLBACK, normal) + : normal; + } + + public ModelPixie() { + super(ModelPixie::pixieLayer); + textureWidth = 32; + textureHeight = 32; + + body = new ModelRenderer(this, 0, 0); + body.setRotationPoint(0.0F, 16.0F, 0.0F); + body.addCuboid(-2.5F, 0.0F, -2.5F, 5, 5, 5, 0.0F); + + leftWingT = new ModelRenderer(this, 0, 4); + leftWingT.setRotationPoint(2.5F, 18.0F, 0.5F); + leftWingT.addCuboid(0.0F, -5.0F, 0.0F, 0, 5, 6, 0.0F); + setRotateAngle(leftWingT, 0.2617993877991494F, 0.5235987755982988F, 0.2617993877991494F); + leftWingB = new ModelRenderer(this, 0, 11); + leftWingB.setRotationPoint(2.5F, 18.0F, 0.5F); + leftWingB.addCuboid(0.0F, 0.0F, 0.0F, 0, 3, 4, 0.0F); + setRotateAngle(leftWingB, -0.2617993877991494F, 0.2617993877991494F, -0.2617993877991494F); + rightWingT = new ModelRenderer(this, 0, 4); + rightWingT.setRotationPoint(-2.5F, 18.0F, 0.5F); + rightWingT.addCuboid(0.0F, -5.0F, 0.0F, 0, 5, 6, 0.0F); + setRotateAngle(rightWingT, 0.2617993877991494F, -0.5235987755982988F, -0.2617993877991494F); + rightWingB = new ModelRenderer(this, 0, 11); + rightWingB.setRotationPoint(-2.5F, 18.0F, 0.5F); + rightWingB.addCuboid(0.0F, 0.0F, 0.0F, 0, 3, 4, 0.0F); + setRotateAngle(rightWingB, -0.2617993877991494F, -0.2617993877991494F, 0.2617993877991494F); + } @Override - public void render(MatrixStack ms, IVertexBuilder buffer, int light, int overlay, float red, float green, float blue, float alpha) { + public void render(MatrixStack ms, IVertexBuilder buffer, int light, int overlay, float red, float green, float blue, float alpha) { body.render(ms, buffer, light, overlay); leftWingT.render(ms, buffer, light, overlay); @@ -73,22 +74,20 @@ public class ModelPixie extends EntityModel { rightWingT.render(ms, buffer, light, overlay); rightWingB.render(ms, buffer, light, overlay); } - + public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; - } + modelRenderer.rotateAngleX = x; + modelRenderer.rotateAngleY = y; + modelRenderer.rotateAngleZ = z; + } @Override public void setAngles(EntityPixie entity, float f, float f1, float f2, float f3, float f4) { evil = entity.getPixieType() == 1; - rightWingT.rotateAngleY = -(MathHelper.cos(f2 * 1.7F) * (float)Math.PI * 0.5F); - leftWingT.rotateAngleY = MathHelper.cos(f2 * 1.7F) * (float)Math.PI * 0.5F; - rightWingB.rotateAngleY = -(MathHelper.cos(f2 * 1.7F) * (float)Math.PI * 0.25F); - leftWingB.rotateAngleY = MathHelper.cos(f2 * 1.7F) * (float)Math.PI * 0.25F; + rightWingT.rotateAngleY = -(MathHelper.cos(f2 * 1.7F) * (float) Math.PI * 0.5F); + leftWingT.rotateAngleY = MathHelper.cos(f2 * 1.7F) * (float) Math.PI * 0.5F; + rightWingB.rotateAngleY = -(MathHelper.cos(f2 * 1.7F) * (float) Math.PI * 0.25F); + leftWingB.rotateAngleY = MathHelper.cos(f2 * 1.7F) * (float) Math.PI * 0.25F; } - - -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/client/model/ModelPylonGaia.java b/src/main/java/vazkii/botania/client/model/ModelPylonGaia.java index bbd4846bd..c8b2ea6fe 100644 --- a/src/main/java/vazkii/botania/client/model/ModelPylonGaia.java +++ b/src/main/java/vazkii/botania/client/model/ModelPylonGaia.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 18, 2014, 10:05:39 PM (GMT)] */ package vazkii.botania.client.model; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.model.Model; import net.minecraft.client.renderer.model.ModelRenderer; @@ -19,94 +18,94 @@ import net.minecraft.client.renderer.model.ModelRenderer; public class ModelPylonGaia extends Model implements IPylonModel { private final ModelRenderer platef; - private final ModelRenderer plateb; - private final ModelRenderer platel; - private final ModelRenderer plater; - - private final ModelRenderer shardlbt; - private final ModelRenderer shardrbt; - private final ModelRenderer shardlft; - private final ModelRenderer shardrft; - - private final ModelRenderer shardlbb; - private final ModelRenderer shardrbb; - private final ModelRenderer shardlfb; - private final ModelRenderer shardrfb; - + private final ModelRenderer plateb; + private final ModelRenderer platel; + private final ModelRenderer plater; + + private final ModelRenderer shardlbt; + private final ModelRenderer shardrbt; + private final ModelRenderer shardlft; + private final ModelRenderer shardrft; + + private final ModelRenderer shardlbb; + private final ModelRenderer shardrbb; + private final ModelRenderer shardlfb; + private final ModelRenderer shardrfb; + public ModelPylonGaia() { super(RenderType::getEntityTranslucent); - + textureWidth = 64; textureHeight = 64; //plates platel = new ModelRenderer(this, 36, 0); - platel.setRotationPoint(0.0F, 16.0F, 0.0F); - platel.addCuboid(-3.0F, -3.0F, -8.0F, 6, 6, 2, 0.0F); - setRotation(platel, 0.0F, 1.5707963267948966F, 0.0F); - plater = new ModelRenderer(this, 36, 0); - plater.setRotationPoint(0.0F, 16.0F, 0.0F); - plater.addCuboid(-3.0F, -3.0F, -8.0F, 6, 6, 2, 0.0F); - setRotation(plater, 0.0F, -1.5707963267948966F, 0.0F); - platef = new ModelRenderer(this, 36, 0); - platef.setRotationPoint(0.0F, 16.0F, 0.0F); - platef.addCuboid(-3.0F, -3.0F, -8.0F, 6, 6, 2, 0.0F); - plateb = new ModelRenderer(this, 36, 0); - plateb.setRotationPoint(0.0F, 16.0F, 0.0F); - plateb.addCuboid(-3.0F, -3.0F, -8.0F, 6, 6, 2, 0.0F); - setRotation(plateb, 0.0F, 3.141592653589793F, 0.0F); - - //shards - shardrft = new ModelRenderer(this, 16, 32); - shardrft.setRotationPoint(0.0F, 16.0F, 0.0F); - shardrft.addCuboid(2.0F, -6.0F, -5.0F, 3, 2, 3, 0.0F); - shardlbt = new ModelRenderer(this, 0, 0); - shardlbt.setRotationPoint(0.0F, 16.0F, 0.0F); - shardlbt.addCuboid(-5.0F, -6.0F, 0.0F, 6, 5, 5, 0.0F); - shardrbt = new ModelRenderer(this, 22, 9); - shardrbt.setRotationPoint(0.0F, 16.0F, 0.0F); - shardrbt.addCuboid(3.0F, -5.0F, 0.0F, 2, 4, 5, 0.0F); - shardlft = new ModelRenderer(this, 0, 32); - shardlft.setRotationPoint(0.0F, 16.0F, 0.0F); - shardlft.addCuboid(-5.0F, -7.0F, -5.0F, 5, 6, 3, 0.0F); - - shardrfb = new ModelRenderer(this, 16, 37); - shardrfb.setRotationPoint(0.0F, 16.0F, 0.0F); - shardrfb.addCuboid(2.0F, -2.0F, -5.0F, 3, 6, 3, 0.0F); - shardlbb = new ModelRenderer(this, 0, 10); - shardlbb.setRotationPoint(0.0F, 16.0F, 0.0F); - shardlbb.addCuboid(-5.0F, 1.0F, 0.0F, 6, 3, 5, 0.0F); - shardrbb = new ModelRenderer(this, 22, 0); - shardrbb.setRotationPoint(0.0F, 16.0F, 0.0F); - shardrbb.addCuboid(3.0F, 1.0F, 0.0F, 2, 4, 5, 0.0F); - shardlfb = new ModelRenderer(this, 0, 41); - shardlfb.setRotationPoint(0.0F, 16.0F, 0.0F); - shardlfb.addCuboid(-5.0F, 1.0F, -5.0F, 5, 2, 3, 0.0F); + platel.setRotationPoint(0.0F, 16.0F, 0.0F); + platel.addCuboid(-3.0F, -3.0F, -8.0F, 6, 6, 2, 0.0F); + setRotation(platel, 0.0F, 1.5707963267948966F, 0.0F); + plater = new ModelRenderer(this, 36, 0); + plater.setRotationPoint(0.0F, 16.0F, 0.0F); + plater.addCuboid(-3.0F, -3.0F, -8.0F, 6, 6, 2, 0.0F); + setRotation(plater, 0.0F, -1.5707963267948966F, 0.0F); + platef = new ModelRenderer(this, 36, 0); + platef.setRotationPoint(0.0F, 16.0F, 0.0F); + platef.addCuboid(-3.0F, -3.0F, -8.0F, 6, 6, 2, 0.0F); + plateb = new ModelRenderer(this, 36, 0); + plateb.setRotationPoint(0.0F, 16.0F, 0.0F); + plateb.addCuboid(-3.0F, -3.0F, -8.0F, 6, 6, 2, 0.0F); + setRotation(plateb, 0.0F, 3.141592653589793F, 0.0F); + + //shards + shardrft = new ModelRenderer(this, 16, 32); + shardrft.setRotationPoint(0.0F, 16.0F, 0.0F); + shardrft.addCuboid(2.0F, -6.0F, -5.0F, 3, 2, 3, 0.0F); + shardlbt = new ModelRenderer(this, 0, 0); + shardlbt.setRotationPoint(0.0F, 16.0F, 0.0F); + shardlbt.addCuboid(-5.0F, -6.0F, 0.0F, 6, 5, 5, 0.0F); + shardrbt = new ModelRenderer(this, 22, 9); + shardrbt.setRotationPoint(0.0F, 16.0F, 0.0F); + shardrbt.addCuboid(3.0F, -5.0F, 0.0F, 2, 4, 5, 0.0F); + shardlft = new ModelRenderer(this, 0, 32); + shardlft.setRotationPoint(0.0F, 16.0F, 0.0F); + shardlft.addCuboid(-5.0F, -7.0F, -5.0F, 5, 6, 3, 0.0F); + + shardrfb = new ModelRenderer(this, 16, 37); + shardrfb.setRotationPoint(0.0F, 16.0F, 0.0F); + shardrfb.addCuboid(2.0F, -2.0F, -5.0F, 3, 6, 3, 0.0F); + shardlbb = new ModelRenderer(this, 0, 10); + shardlbb.setRotationPoint(0.0F, 16.0F, 0.0F); + shardlbb.addCuboid(-5.0F, 1.0F, 0.0F, 6, 3, 5, 0.0F); + shardrbb = new ModelRenderer(this, 22, 0); + shardrbb.setRotationPoint(0.0F, 16.0F, 0.0F); + shardrbb.addCuboid(3.0F, 1.0F, 0.0F, 2, 4, 5, 0.0F); + shardlfb = new ModelRenderer(this, 0, 41); + shardlfb.setRotationPoint(0.0F, 16.0F, 0.0F); + shardlfb.addCuboid(-5.0F, 1.0F, -5.0F, 5, 2, 3, 0.0F); } @Override public void renderCrystal(MatrixStack ms, IVertexBuilder buffer, int light, int overlay) { shardrft.render(ms, buffer, light, overlay); - shardlbt.render(ms, buffer, light, overlay); - shardrbt.render(ms, buffer, light, overlay); - shardlft.render(ms, buffer, light, overlay); - - shardrfb.render(ms, buffer, light, overlay); - shardlbb.render(ms, buffer, light, overlay); - shardrbb.render(ms, buffer, light, overlay); - shardlfb.render(ms, buffer, light, overlay); + shardlbt.render(ms, buffer, light, overlay); + shardrbt.render(ms, buffer, light, overlay); + shardlft.render(ms, buffer, light, overlay); + + shardrfb.render(ms, buffer, light, overlay); + shardlbb.render(ms, buffer, light, overlay); + shardrbb.render(ms, buffer, light, overlay); + shardlfb.render(ms, buffer, light, overlay); } @Override public void renderRing(MatrixStack ms, IVertexBuilder buffer, int light, int overlay) { - platef.render(ms, buffer, light, overlay); - plateb.render(ms, buffer, light, overlay); - platel.render(ms, buffer, light, overlay); - plater.render(ms, buffer, light, overlay); + platef.render(ms, buffer, light, overlay); + plateb.render(ms, buffer, light, overlay); + platel.render(ms, buffer, light, overlay); + plater.render(ms, buffer, light, overlay); } private void setRotation(ModelRenderer model, float x, float y, float z) { - + model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; @@ -116,4 +115,4 @@ public class ModelPylonGaia extends Model implements IPylonModel { public void render(MatrixStack ms, IVertexBuilder buffer, int light, int overlay, float r, float g, float b, float a) { throw new UnsupportedOperationException("unimplemented"); } -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/client/model/ModelPylonMana.java b/src/main/java/vazkii/botania/client/model/ModelPylonMana.java index db8629c0a..ecd497a33 100644 --- a/src/main/java/vazkii/botania/client/model/ModelPylonMana.java +++ b/src/main/java/vazkii/botania/client/model/ModelPylonMana.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 18, 2014, 10:05:39 PM (GMT)] */ package vazkii.botania.client.model; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.model.Model; import net.minecraft.client.renderer.model.ModelRenderer; @@ -19,15 +18,15 @@ import net.minecraft.client.renderer.model.ModelRenderer; public class ModelPylonMana extends Model implements IPylonModel { private final ModelRenderer platef; - private final ModelRenderer plateb; - private final ModelRenderer platel; - private final ModelRenderer plater; - - private final ModelRenderer shardlf; - private final ModelRenderer shardrf; - private final ModelRenderer shardlb; - private final ModelRenderer shardrb; - + private final ModelRenderer plateb; + private final ModelRenderer platel; + private final ModelRenderer plater; + + private final ModelRenderer shardlf; + private final ModelRenderer shardrf; + private final ModelRenderer shardlb; + private final ModelRenderer shardrb; + public ModelPylonMana() { super(RenderType::getEntityTranslucent); @@ -36,50 +35,50 @@ public class ModelPylonMana extends Model implements IPylonModel { //plates platef = new ModelRenderer(this, 36, 0); - platef.setRotationPoint(0.0F, 16.0F, 0.0F); - platef.addCuboid(-3.0F, -4.0F, -8.0F, 6, 8, 2, 0.0F); - plateb = new ModelRenderer(this, 36, 0); - plateb.setRotationPoint(0.0F, 16.0F, 0.0F); - plateb.addCuboid(-3.0F, -4.0F, -8.0F, 6, 8, 2, 0.0F); - setRotation(plateb, 0.0F, 3.141592653589793F, 0.0F); + platef.setRotationPoint(0.0F, 16.0F, 0.0F); + platef.addCuboid(-3.0F, -4.0F, -8.0F, 6, 8, 2, 0.0F); + plateb = new ModelRenderer(this, 36, 0); + plateb.setRotationPoint(0.0F, 16.0F, 0.0F); + plateb.addCuboid(-3.0F, -4.0F, -8.0F, 6, 8, 2, 0.0F); + setRotation(plateb, 0.0F, 3.141592653589793F, 0.0F); platel = new ModelRenderer(this, 36, 0); - platel.setRotationPoint(0.0F, 16.0F, 0.0F); - platel.addCuboid(-3.0F, -4.0F, -8.0F, 6, 8, 2, 0.0F); - setRotation(platel, 0.0F, 1.5707963267948966F, 0.0F); - plater = new ModelRenderer(this, 36, 0); - plater.setRotationPoint(0.0F, 16.0F, 0.0F); - plater.addCuboid(-3.0F, -4.0F, -8.0F, 6, 8, 2, 0.0F); - setRotation(plater, 0.0F, -1.5707963267948966F, 0.0F); - - //shards - shardlf = new ModelRenderer(this, 0, 21); - shardlf.setRotationPoint(0.0F, 16.0F, 0.0F); - shardlf.addCuboid(-5.0F, -9.0F, -5.0F, 5, 16, 3, 0.0F); - shardrf = new ModelRenderer(this, 16, 21); - shardrf.setRotationPoint(0.0F, 16.0F, 0.0F); - shardrf.addCuboid(2.0F, -12.0F, -5.0F, 3, 16, 3, 0.0F); - shardlb = new ModelRenderer(this, 0, 0); - shardlb.setRotationPoint(0.0F, 16.0F, 0.0F); - shardlb.addCuboid(-5.0F, -10.0F, 0.0F, 6, 16, 5, 0.0F); - shardrb = new ModelRenderer(this, 22, 0); - shardrb.setRotationPoint(0.0F, 16.0F, 0.0F); - shardrb.addCuboid(3.0F, -11.0F, 0.0F, 2, 16, 5, 0.0F); + platel.setRotationPoint(0.0F, 16.0F, 0.0F); + platel.addCuboid(-3.0F, -4.0F, -8.0F, 6, 8, 2, 0.0F); + setRotation(platel, 0.0F, 1.5707963267948966F, 0.0F); + plater = new ModelRenderer(this, 36, 0); + plater.setRotationPoint(0.0F, 16.0F, 0.0F); + plater.addCuboid(-3.0F, -4.0F, -8.0F, 6, 8, 2, 0.0F); + setRotation(plater, 0.0F, -1.5707963267948966F, 0.0F); + + //shards + shardlf = new ModelRenderer(this, 0, 21); + shardlf.setRotationPoint(0.0F, 16.0F, 0.0F); + shardlf.addCuboid(-5.0F, -9.0F, -5.0F, 5, 16, 3, 0.0F); + shardrf = new ModelRenderer(this, 16, 21); + shardrf.setRotationPoint(0.0F, 16.0F, 0.0F); + shardrf.addCuboid(2.0F, -12.0F, -5.0F, 3, 16, 3, 0.0F); + shardlb = new ModelRenderer(this, 0, 0); + shardlb.setRotationPoint(0.0F, 16.0F, 0.0F); + shardlb.addCuboid(-5.0F, -10.0F, 0.0F, 6, 16, 5, 0.0F); + shardrb = new ModelRenderer(this, 22, 0); + shardrb.setRotationPoint(0.0F, 16.0F, 0.0F); + shardrb.addCuboid(3.0F, -11.0F, 0.0F, 2, 16, 5, 0.0F); } @Override public void renderCrystal(MatrixStack ms, IVertexBuilder buffer, int light, int overlay) { shardlf.render(ms, buffer, light, overlay); - shardrf.render(ms, buffer, light, overlay); - shardlb.render(ms, buffer, light, overlay); - shardrb.render(ms, buffer, light, overlay); + shardrf.render(ms, buffer, light, overlay); + shardlb.render(ms, buffer, light, overlay); + shardrb.render(ms, buffer, light, overlay); } @Override public void renderRing(MatrixStack ms, IVertexBuilder buffer, int light, int overlay) { - platef.render(ms, buffer, light, overlay); - plateb.render(ms, buffer, light, overlay); - platel.render(ms, buffer, light, overlay); - plater.render(ms, buffer, light, overlay); + platef.render(ms, buffer, light, overlay); + plateb.render(ms, buffer, light, overlay); + platel.render(ms, buffer, light, overlay); + plater.render(ms, buffer, light, overlay); } private void setRotation(ModelRenderer model, float x, float y, float z) { @@ -92,4 +91,4 @@ public class ModelPylonMana extends Model implements IPylonModel { public void render(MatrixStack ms, IVertexBuilder buffer, int light, int overlay, float r, float g, float b, float a) { throw new UnsupportedOperationException("unimplemented"); } -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/client/model/ModelPylonNatura.java b/src/main/java/vazkii/botania/client/model/ModelPylonNatura.java index 0a321fef3..11a2ee113 100644 --- a/src/main/java/vazkii/botania/client/model/ModelPylonNatura.java +++ b/src/main/java/vazkii/botania/client/model/ModelPylonNatura.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 18, 2014, 10:05:39 PM (GMT)] */ package vazkii.botania.client.model; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.model.Model; import net.minecraft.client.renderer.model.ModelRenderer; @@ -19,94 +18,94 @@ import net.minecraft.client.renderer.model.ModelRenderer; public class ModelPylonNatura extends Model implements IPylonModel { private final ModelRenderer platef; - private final ModelRenderer plateb; - private final ModelRenderer platel; - private final ModelRenderer plater; + private final ModelRenderer plateb; + private final ModelRenderer platel; + private final ModelRenderer plater; - private final ModelRenderer shardlbt; - private final ModelRenderer shardrbt; - private final ModelRenderer shardlft; - private final ModelRenderer shardrft; + private final ModelRenderer shardlbt; + private final ModelRenderer shardrbt; + private final ModelRenderer shardlft; + private final ModelRenderer shardrft; + + private final ModelRenderer shardlbb; + private final ModelRenderer shardrbb; + private final ModelRenderer shardlfb; + private final ModelRenderer shardrfb; - private final ModelRenderer shardlbb; - private final ModelRenderer shardrbb; - private final ModelRenderer shardlfb; - private final ModelRenderer shardrfb; - public ModelPylonNatura() { super(RenderType::getEntityTranslucent); - + textureWidth = 64; textureHeight = 64; //plates - platef = new ModelRenderer(this, 36, 0); - platef.setRotationPoint(0.0F, 16.0F, 0.0F); - platef.addCuboid(-4.0F, -4.0F, -8.0F, 8, 8, 2, 0.0F); - plateb = new ModelRenderer(this, 36, 0); - plateb.setRotationPoint(0.0F, 16.0F, 0.0F); - plateb.addCuboid(-4.0F, -4.0F, -8.0F, 8, 8, 2, 0.0F); - setRotation(plateb, 0.0F, 3.141592653589793F, 0.0F); - platel = new ModelRenderer(this, 36, 0); - platel.setRotationPoint(0.0F, 16.0F, 0.0F); - platel.addCuboid(-4.0F, -4.0F, -8.0F, 8, 8, 2, 0.0F); - setRotation(platel, 0.0F, 1.5707963267948966F, 0.0F); - plater = new ModelRenderer(this, 36, 0); - plater.setRotationPoint(0.0F, 16.0F, 0.0F); - plater.addCuboid(-4.0F, -4.0F, -8.0F, 8, 8, 2, 0.0F); - setRotation(plater, 0.0F, -1.5707963267948966F, 0.0F); - - //shards - shardrft = new ModelRenderer(this, 16, 32); - shardrft.setRotationPoint(0.0F, 16.0F, 0.0F); - shardrft.addCuboid(2.0F, -13.0F, -5.0F, 3, 7, 3, 0.0F); - shardlbt = new ModelRenderer(this, 0, 0); - shardlbt.setRotationPoint(0.0F, 16.0F, 0.0F); - shardlbt.addCuboid(-5.0F, -11.0F, 0.0F, 6, 9, 5, 0.0F); - shardrbt = new ModelRenderer(this, 22, 0); - shardrbt.setRotationPoint(0.0F, 16.0F, 0.0F); - shardrbt.addCuboid(3.0F, -12.0F, 0.0F, 2, 8, 5, 0.0F); - shardlft = new ModelRenderer(this, 0, 32); - shardlft.setRotationPoint(0.0F, 16.0F, 0.0F); - shardlft.addCuboid(-5.0F, -10.0F, -5.0F, 5, 10, 3, 0.0F); - - shardrfb = new ModelRenderer(this, 16, 42); - shardrfb.setRotationPoint(0.0F, 16.0F, 0.0F); - shardrfb.addCuboid(2.0F, -4.0F, -5.0F, 3, 9, 3, 0.0F); - shardlbb = new ModelRenderer(this, 0, 14); - shardlbb.setRotationPoint(0.0F, 16.0F, 0.0F); - shardlbb.addCuboid(-5.0F, 0.0F, 0.0F, 6, 7, 5, 0.0F); - shardrbb = new ModelRenderer(this, 22, 13); - shardrbb.setRotationPoint(0.0F, 16.0F, 0.0F); - shardrbb.addCuboid(3.0F, -2.0F, 0.0F, 2, 8, 5, 0.0F); - shardlfb = new ModelRenderer(this, 0, 45); - shardlfb.setRotationPoint(0.0F, 16.0F, 0.0F); - shardlfb.addCuboid(-5.0F, 2.0F, -5.0F, 5, 6, 3, 0.0F); + platef = new ModelRenderer(this, 36, 0); + platef.setRotationPoint(0.0F, 16.0F, 0.0F); + platef.addCuboid(-4.0F, -4.0F, -8.0F, 8, 8, 2, 0.0F); + plateb = new ModelRenderer(this, 36, 0); + plateb.setRotationPoint(0.0F, 16.0F, 0.0F); + plateb.addCuboid(-4.0F, -4.0F, -8.0F, 8, 8, 2, 0.0F); + setRotation(plateb, 0.0F, 3.141592653589793F, 0.0F); + platel = new ModelRenderer(this, 36, 0); + platel.setRotationPoint(0.0F, 16.0F, 0.0F); + platel.addCuboid(-4.0F, -4.0F, -8.0F, 8, 8, 2, 0.0F); + setRotation(platel, 0.0F, 1.5707963267948966F, 0.0F); + plater = new ModelRenderer(this, 36, 0); + plater.setRotationPoint(0.0F, 16.0F, 0.0F); + plater.addCuboid(-4.0F, -4.0F, -8.0F, 8, 8, 2, 0.0F); + setRotation(plater, 0.0F, -1.5707963267948966F, 0.0F); + + //shards + shardrft = new ModelRenderer(this, 16, 32); + shardrft.setRotationPoint(0.0F, 16.0F, 0.0F); + shardrft.addCuboid(2.0F, -13.0F, -5.0F, 3, 7, 3, 0.0F); + shardlbt = new ModelRenderer(this, 0, 0); + shardlbt.setRotationPoint(0.0F, 16.0F, 0.0F); + shardlbt.addCuboid(-5.0F, -11.0F, 0.0F, 6, 9, 5, 0.0F); + shardrbt = new ModelRenderer(this, 22, 0); + shardrbt.setRotationPoint(0.0F, 16.0F, 0.0F); + shardrbt.addCuboid(3.0F, -12.0F, 0.0F, 2, 8, 5, 0.0F); + shardlft = new ModelRenderer(this, 0, 32); + shardlft.setRotationPoint(0.0F, 16.0F, 0.0F); + shardlft.addCuboid(-5.0F, -10.0F, -5.0F, 5, 10, 3, 0.0F); + + shardrfb = new ModelRenderer(this, 16, 42); + shardrfb.setRotationPoint(0.0F, 16.0F, 0.0F); + shardrfb.addCuboid(2.0F, -4.0F, -5.0F, 3, 9, 3, 0.0F); + shardlbb = new ModelRenderer(this, 0, 14); + shardlbb.setRotationPoint(0.0F, 16.0F, 0.0F); + shardlbb.addCuboid(-5.0F, 0.0F, 0.0F, 6, 7, 5, 0.0F); + shardrbb = new ModelRenderer(this, 22, 13); + shardrbb.setRotationPoint(0.0F, 16.0F, 0.0F); + shardrbb.addCuboid(3.0F, -2.0F, 0.0F, 2, 8, 5, 0.0F); + shardlfb = new ModelRenderer(this, 0, 45); + shardlfb.setRotationPoint(0.0F, 16.0F, 0.0F); + shardlfb.addCuboid(-5.0F, 2.0F, -5.0F, 5, 6, 3, 0.0F); } @Override public void renderCrystal(MatrixStack ms, IVertexBuilder buffer, int light, int overlay) { shardrft.render(ms, buffer, light, overlay); - shardlbt.render(ms, buffer, light, overlay); - shardrbt.render(ms, buffer, light, overlay); - shardlft.render(ms, buffer, light, overlay); - - shardrfb.render(ms, buffer, light, overlay); - shardlbb.render(ms, buffer, light, overlay); - shardrbb.render(ms, buffer, light, overlay); - shardlfb.render(ms, buffer, light, overlay); + shardlbt.render(ms, buffer, light, overlay); + shardrbt.render(ms, buffer, light, overlay); + shardlft.render(ms, buffer, light, overlay); + + shardrfb.render(ms, buffer, light, overlay); + shardlbb.render(ms, buffer, light, overlay); + shardrbb.render(ms, buffer, light, overlay); + shardlfb.render(ms, buffer, light, overlay); } @Override public void renderRing(MatrixStack ms, IVertexBuilder buffer, int light, int overlay) { - platef.render(ms, buffer, light, overlay); - plateb.render(ms, buffer, light, overlay); - platel.render(ms, buffer, light, overlay); - plater.render(ms, buffer, light, overlay); + platef.render(ms, buffer, light, overlay); + plateb.render(ms, buffer, light, overlay); + platel.render(ms, buffer, light, overlay); + plater.render(ms, buffer, light, overlay); } private void setRotation(ModelRenderer model, float x, float y, float z) { - + model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; @@ -116,4 +115,4 @@ public class ModelPylonNatura extends Model implements IPylonModel { public void render(MatrixStack ms, IVertexBuilder buffer, int light, int overlay, float r, float g, float b, float a) { throw new UnsupportedOperationException("unimplemented"); } -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/client/model/ModelTeruTeruBozu.java b/src/main/java/vazkii/botania/client/model/ModelTeruTeruBozu.java index 815d5f9b1..ad10a97d5 100644 --- a/src/main/java/vazkii/botania/client/model/ModelTeruTeruBozu.java +++ b/src/main/java/vazkii/botania/client/model/ModelTeruTeruBozu.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [? (GMT)] */ package vazkii.botania.client.model; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.model.Model; @@ -47,9 +46,11 @@ public class ModelTeruTeruBozu extends Model { @Override public void render(MatrixStack ms, IVertexBuilder buffer, int light, int overlay, float r, float g, float b, float a) { - if(Minecraft.getInstance().world.isRaining()) + if (Minecraft.getInstance().world.isRaining()) { sadFace.render(ms, buffer, light, overlay, r, g, b, a); - else happyFace.render(ms, buffer, light, overlay, r, g, b, a); + } else { + happyFace.render(ms, buffer, light, overlay, r, g, b, a); + } thread.render(ms, buffer, light, overlay, r, g, b, a); cloth.render(ms, buffer, light, overlay, r, g, b, a); } diff --git a/src/main/java/vazkii/botania/client/model/PlatformModel.java b/src/main/java/vazkii/botania/client/model/PlatformModel.java index 7a0d75f2f..288e12777 100644 --- a/src/main/java/vazkii/botania/client/model/PlatformModel.java +++ b/src/main/java/vazkii/botania/client/model/PlatformModel.java @@ -1,14 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 */ package vazkii.botania.client.model; import com.google.common.collect.ImmutableList; + import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderType; @@ -21,11 +22,13 @@ import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.client.model.BakedModelWrapper; import net.minecraftforge.client.model.data.EmptyModelData; import net.minecraftforge.client.model.data.IModelData; + import vazkii.botania.common.block.BlockPlatform; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.tile.TilePlatform; import javax.annotation.Nonnull; + import java.util.List; import java.util.Random; @@ -37,14 +40,16 @@ public class PlatformModel extends BakedModelWrapper { @Nonnull @Override public List getQuads(BlockState state, Direction side, @Nonnull Random rand, @Nonnull IModelData data) { - if(state == null) + if (state == null) { return ImmutableList.of(); + } - if(!(state.getBlock() instanceof BlockPlatform)) + if (!(state.getBlock() instanceof BlockPlatform)) { return Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelShapes().getModelManager().getMissingModel().getQuads(state, side, rand); + } RenderType layer = MinecraftForgeClient.getRenderLayer(); - if(layer == null) { + if (layer == null) { layer = RenderType.getSolid(); // workaround for when this isn't set (digging, etc.) } @@ -56,16 +61,17 @@ public class PlatformModel extends BakedModelWrapper { } Minecraft mc = Minecraft.getInstance(); - if(heldState == null && layer == RenderType.getSolid()) { + if (heldState == null && layer == RenderType.getSolid()) { // No camo return originalModel.getQuads(state, side, rand, data); - } else if(heldState != null) { + } else if (heldState != null) { // Some people used this to get an invisible block in the past, accommodate that. - if(heldState.getBlock() == ModBlocks.manaGlass) + if (heldState.getBlock() == ModBlocks.manaGlass) { return ImmutableList.of(); + } - if(RenderTypeLookup.canRenderInLayer(heldState, layer)) { + if (RenderTypeLookup.canRenderInLayer(heldState, layer)) { // Steal camo's model IBakedModel model = mc.getBlockRendererDispatcher().getBlockModelShapes().getModel(heldState); diff --git a/src/main/java/vazkii/botania/client/model/armor/ModelArmor.java b/src/main/java/vazkii/botania/client/model/armor/ModelArmor.java index 6ce2bbc5c..f6feb9360 100644 --- a/src/main/java/vazkii/botania/client/model/armor/ModelArmor.java +++ b/src/main/java/vazkii/botania/client/model/armor/ModelArmor.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.client.model.armor; import net.minecraft.client.renderer.entity.model.BipedModel; @@ -24,26 +32,26 @@ public class ModelArmor extends BipedModel { } ArmorStandEntity entityIn = (ArmorStandEntity) entity; - this.bipedHead.rotateAngleX = ((float)Math.PI / 180F) * entityIn.getHeadRotation().getX(); - this.bipedHead.rotateAngleY = ((float)Math.PI / 180F) * entityIn.getHeadRotation().getY(); - this.bipedHead.rotateAngleZ = ((float)Math.PI / 180F) * entityIn.getHeadRotation().getZ(); + this.bipedHead.rotateAngleX = ((float) Math.PI / 180F) * entityIn.getHeadRotation().getX(); + this.bipedHead.rotateAngleY = ((float) Math.PI / 180F) * entityIn.getHeadRotation().getY(); + this.bipedHead.rotateAngleZ = ((float) Math.PI / 180F) * entityIn.getHeadRotation().getZ(); this.bipedHead.setRotationPoint(0.0F, 1.0F, 0.0F); - this.bipedBody.rotateAngleX = ((float)Math.PI / 180F) * entityIn.getBodyRotation().getX(); - this.bipedBody.rotateAngleY = ((float)Math.PI / 180F) * entityIn.getBodyRotation().getY(); - this.bipedBody.rotateAngleZ = ((float)Math.PI / 180F) * entityIn.getBodyRotation().getZ(); - this.bipedLeftArm.rotateAngleX = ((float)Math.PI / 180F) * entityIn.getLeftArmRotation().getX(); - this.bipedLeftArm.rotateAngleY = ((float)Math.PI / 180F) * entityIn.getLeftArmRotation().getY(); - this.bipedLeftArm.rotateAngleZ = ((float)Math.PI / 180F) * entityIn.getLeftArmRotation().getZ(); - this.bipedRightArm.rotateAngleX = ((float)Math.PI / 180F) * entityIn.getRightArmRotation().getX(); - this.bipedRightArm.rotateAngleY = ((float)Math.PI / 180F) * entityIn.getRightArmRotation().getY(); - this.bipedRightArm.rotateAngleZ = ((float)Math.PI / 180F) * entityIn.getRightArmRotation().getZ(); - this.bipedLeftLeg.rotateAngleX = ((float)Math.PI / 180F) * entityIn.getLeftLegRotation().getX(); - this.bipedLeftLeg.rotateAngleY = ((float)Math.PI / 180F) * entityIn.getLeftLegRotation().getY(); - this.bipedLeftLeg.rotateAngleZ = ((float)Math.PI / 180F) * entityIn.getLeftLegRotation().getZ(); + this.bipedBody.rotateAngleX = ((float) Math.PI / 180F) * entityIn.getBodyRotation().getX(); + this.bipedBody.rotateAngleY = ((float) Math.PI / 180F) * entityIn.getBodyRotation().getY(); + this.bipedBody.rotateAngleZ = ((float) Math.PI / 180F) * entityIn.getBodyRotation().getZ(); + this.bipedLeftArm.rotateAngleX = ((float) Math.PI / 180F) * entityIn.getLeftArmRotation().getX(); + this.bipedLeftArm.rotateAngleY = ((float) Math.PI / 180F) * entityIn.getLeftArmRotation().getY(); + this.bipedLeftArm.rotateAngleZ = ((float) Math.PI / 180F) * entityIn.getLeftArmRotation().getZ(); + this.bipedRightArm.rotateAngleX = ((float) Math.PI / 180F) * entityIn.getRightArmRotation().getX(); + this.bipedRightArm.rotateAngleY = ((float) Math.PI / 180F) * entityIn.getRightArmRotation().getY(); + this.bipedRightArm.rotateAngleZ = ((float) Math.PI / 180F) * entityIn.getRightArmRotation().getZ(); + this.bipedLeftLeg.rotateAngleX = ((float) Math.PI / 180F) * entityIn.getLeftLegRotation().getX(); + this.bipedLeftLeg.rotateAngleY = ((float) Math.PI / 180F) * entityIn.getLeftLegRotation().getY(); + this.bipedLeftLeg.rotateAngleZ = ((float) Math.PI / 180F) * entityIn.getLeftLegRotation().getZ(); this.bipedLeftLeg.setRotationPoint(1.9F, 11.0F, 0.0F); - this.bipedRightLeg.rotateAngleX = ((float)Math.PI / 180F) * entityIn.getRightLegRotation().getX(); - this.bipedRightLeg.rotateAngleY = ((float)Math.PI / 180F) * entityIn.getRightLegRotation().getY(); - this.bipedRightLeg.rotateAngleZ = ((float)Math.PI / 180F) * entityIn.getRightLegRotation().getZ(); + this.bipedRightLeg.rotateAngleX = ((float) Math.PI / 180F) * entityIn.getRightLegRotation().getX(); + this.bipedRightLeg.rotateAngleY = ((float) Math.PI / 180F) * entityIn.getRightLegRotation().getY(); + this.bipedRightLeg.rotateAngleZ = ((float) Math.PI / 180F) * entityIn.getRightLegRotation().getZ(); this.bipedRightLeg.setRotationPoint(-1.9F, 11.0F, 0.0F); this.bipedHeadwear.copyModelAngles(this.bipedHead); } diff --git a/src/main/java/vazkii/botania/client/model/armor/ModelArmorElementium.java b/src/main/java/vazkii/botania/client/model/armor/ModelArmorElementium.java index 92a42f325..f565a2012 100644 --- a/src/main/java/vazkii/botania/client/model/armor/ModelArmorElementium.java +++ b/src/main/java/vazkii/botania/client/model/armor/ModelArmorElementium.java @@ -1,228 +1,223 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [? (GMT)] */ package vazkii.botania.client.model.armor; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.renderer.model.ModelRenderer; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; import net.minecraft.inventory.EquipmentSlotType; -import javax.annotation.Nonnull; - public class ModelArmorElementium extends ModelArmor { - + private final ModelRenderer helmAnchor; private final ModelRenderer helm; - private final ModelRenderer helmFairy; - private final ModelRenderer helmWing1r; - private final ModelRenderer helmWing2l; + private final ModelRenderer helmFairy; + private final ModelRenderer helmWing1r; + private final ModelRenderer helmWing2l; private final ModelRenderer helmWing1l; - private final ModelRenderer helmWing2r; - + private final ModelRenderer helmWing2r; + private final ModelRenderer bodyAnchor; private final ModelRenderer bodyTop; private final ModelRenderer bodyBottom; - + private final ModelRenderer armLAnchor; private final ModelRenderer armL; private final ModelRenderer armLpauldron; private final ModelRenderer armLwing1; - private final ModelRenderer armLwing2; - + private final ModelRenderer armLwing2; + private final ModelRenderer armRAnchor; private final ModelRenderer armR; private final ModelRenderer armRpauldron; - private final ModelRenderer armRwing1; - private final ModelRenderer armRwing2; - + private final ModelRenderer armRwing1; + private final ModelRenderer armRwing2; + private final ModelRenderer pantsAnchor; private final ModelRenderer belt; - private final ModelRenderer legL; - private final ModelRenderer legR; - - private final ModelRenderer bootL; - private final ModelRenderer bootLwing1; - private final ModelRenderer bootLwing2; + private final ModelRenderer legL; + private final ModelRenderer legR; + + private final ModelRenderer bootL; + private final ModelRenderer bootLwing1; + private final ModelRenderer bootLwing2; private final ModelRenderer bootR; private final ModelRenderer bootRwing1; - private final ModelRenderer bootRwing2; - + private final ModelRenderer bootRwing2; + public ModelArmorElementium(EquipmentSlotType slot) { super(slot); this.textureWidth = 64; - this.textureHeight = 128; + this.textureHeight = 128; float s = 0.01F; - + //helm - this.helmAnchor = new ModelRenderer(this, 0, 0); - this.helmAnchor.setRotationPoint(0.0F, 0.0F, 0.0F); - this.helmAnchor.addCuboid(-1.0F, -2.0F, 0.0F, 2, 2, 2, s); - this.helm = new ModelRenderer(this, 0, 0); - this.helm.setRotationPoint(0.0F, 0.0F, 0.0F); - this.helm.addCuboid(-4.5F, -9.0F, -4.5F, 9, 9, 9, s); - this.helmFairy = new ModelRenderer(this, 36, 11); - this.helmFairy.setRotationPoint(0.0F, 0.0F, 0.0F); - this.helmFairy.addCuboid(-2.5F, -10.0F, -5.5F, 5, 5, 5, s); - this.helmWing1l = new ModelRenderer(this, 36, 0); - this.helmWing1l.mirror = true; - this.helmWing1l.setRotationPoint(4.5F, -6.0F, -0.5F); - this.helmWing1l.addCuboid(-1.0F, -5.0F, 0.0F, 1, 5, 6, s); - this.setRotateAngle(helmWing1l, 0.2617993877991494F, 0.5235987755982988F, 0.2617993877991494F); - this.helmWing2l = new ModelRenderer(this, 50, 0); - this.helmWing2l.setRotationPoint(4.5F, -6.0F, -0.5F); - this.helmWing2l.addCuboid(-1.0F, 0.0F, 0.0F, 1, 3, 4, s); - this.setRotateAngle(helmWing2l, -0.2617993877991494F, 0.2617993877991494F, -0.2617993877991494F); - this.helmWing1r = new ModelRenderer(this, 36, 0); - this.helmWing1r.setRotationPoint(-4.5F, -6.0F, -0.5F); - this.helmWing1r.addCuboid(0.0F, -5.0F, 0.0F, 1, 5, 6, s); - this.setRotateAngle(helmWing1r, 0.2617993877991494F, -0.5235987755982988F, -0.2617993877991494F); - this.helmWing2r = new ModelRenderer(this, 50, 0); - this.helmWing2r.mirror = true; - this.helmWing2r.setRotationPoint(-4.5F, -6.0F, -0.5F); - this.helmWing2r.addCuboid(0.0F, 0.0F, 0.0F, 1, 3, 4, s); - this.setRotateAngle(helmWing2r, -0.2617993877991494F, -0.2617993877991494F, 0.2617993877991494F); - - //body - this.bodyAnchor = new ModelRenderer(this, 0, 0); - this.bodyAnchor.setRotationPoint(0.0F, 0.0F, 0.0F); - this.bodyAnchor.addCuboid(-1.0F, 0.0F, -1.0F, 2, 2, 2, s); - this.bodyTop = new ModelRenderer(this, 0, 19); - this.bodyTop.setRotationPoint(0.0F, 0.0F, 0.0F); - this.bodyTop.addCuboid(-4.5F, 0.0F, -3.0F, 9, 6, 6, s); - this.bodyBottom = new ModelRenderer(this, 0, 31); - this.bodyBottom.setRotationPoint(0.0F, 0.0F, 0.0F); - this.bodyBottom.addCuboid(-3.5F, 5.0F, -2.5F, 7, 3, 5, s); - - //armL - this.armLAnchor = new ModelRenderer(this, 0, 0); - this.armLAnchor.mirror = true; - this.armLAnchor.setRotationPoint(4.0F, 2.0F, 0.0F); - this.armLAnchor.addCuboid(0.0F, -1.0F, -1.0F, 2, 2, 2, s); - this.armL = new ModelRenderer(this, 24, 40); - this.armL.mirror = true; - this.armL.setRotationPoint(0.0F, 0.0F, -0.0F); - this.armL.addCuboid(0.5F, 4.5F, -2.49F, 3, 6, 5, s); - this.armLpauldron = new ModelRenderer(this, 0, 40); - this.armLpauldron.mirror = true; - this.armLpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); - this.armLpauldron.addCuboid(-0.5F, -3.0F, -3.0F, 6, 7, 6, s); - this.armLwing1 = new ModelRenderer(this, 40, 35); - this.armLwing1.setRotationPoint(6.0F, -1.0F, 0.0F); - this.armLwing1.addCuboid(0.0F, -4.0F, 0.0F, 0, 4, 5, s); - this.setRotateAngle(armLwing1, 0.2617993877991494F, 0.5235987755982988F, 0.2617993877991494F); - this.armLwing2 = new ModelRenderer(this, 40, 40); - this.armLwing2.setRotationPoint(6.0F, -1.0F, 0.0F); - this.armLwing2.addCuboid(0.0F, 0.0F, 0.0F, 0, 3, 4, s); - this.setRotateAngle(armLwing2, -0.2617993877991494F, 0.2617993877991494F, -0.2617993877991494F); - - //armR - this.armRAnchor = new ModelRenderer(this, 0, 0); - this.armRAnchor.mirror = true; - this.armRAnchor.setRotationPoint(-4.0F, 2.0F, 0.0F); - this.armRAnchor.addCuboid(-2.0F, -1.0F, -1.0F, 2, 2, 2, s); - this.armR = new ModelRenderer(this, 24, 40); - this.armR.setRotationPoint(0.0F, 0.0F, 0.0F); - this.armR.addCuboid(-3.5F, 4.5F, -2.51F, 3, 6, 5, s); - this.armRpauldron = new ModelRenderer(this, 0, 40); - this.armRpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); - this.armRpauldron.addCuboid(-5.5F, -3.0F, -3.0F, 6, 7, 6, s); - this.setRotateAngle(armRpauldron, 0.0F, 0.0F, 0.0017453292519943296F); - this.armRwing1 = new ModelRenderer(this, 40, 35); - this.armRwing1.mirror = true; - this.armRwing1.setRotationPoint(-6.5F, -1.0F, 0.0F); - this.armRwing1.addCuboid(0.0F, -4.0F, 0.0F, 0, 4, 5, s); - this.setRotateAngle(armRwing1, 0.2617993877991494F, -0.5235987755982988F, -0.2617993877991494F); - this.armRwing2 = new ModelRenderer(this, 40, 40); - this.armRwing2.mirror = true; - this.armRwing2.setRotationPoint(-6.5F, -1.0F, 0.0F); - this.armRwing2.addCuboid(0.0F, 0.0F, 0.0F, 0, 3, 4, s); - this.setRotateAngle(armRwing2, -0.2617993877991494F, -0.2617993877991494F, 0.2617993877991494F); - - //pants - this.pantsAnchor = new ModelRenderer(this, 0, 0); - this.pantsAnchor.setRotationPoint(0.0F, 0.0F, 0.0F); - this.pantsAnchor.addCuboid(-1.0F, 0.0F, -1.0F, 2, 2, 2, s); - this.belt = new ModelRenderer(this, 0, 53); - this.belt.setRotationPoint(0.0F, 0.0F, 0.0F); - this.belt.addCuboid(-4.5F, 8.0F, -3.0F, 9, 5, 6, s); - this.legL = new ModelRenderer(this, 0, 64); - this.legL.mirror = true; - this.legL.setRotationPoint(1.9F, 12.0F, 0.0F); - this.legL.addCuboid(-2.39F, 0.0F, -2.49F, 5, 6, 5, s); - this.legR = new ModelRenderer(this, 0, 64); - this.legR.setRotationPoint(-1.9F, 12.0F, 0.0F); - this.legR.addCuboid(-2.61F, 0.0F, -2.51F, 5, 6, 5, s); - - //boots - this.bootL = new ModelRenderer(this, 0, 75); - this.bootL.mirror = true; - this.bootL.setRotationPoint(1.9F, 12.0F, 0.0F); - this.bootL.addCuboid(-2.39F, 8.5F, -2.49F, 5, 5, 5, s); - this.bootLwing1 = new ModelRenderer(this, 40, 40); - this.bootLwing1.setRotationPoint(2.5F, 8.5F, 0.0F); - this.bootLwing1.addCuboid(0.0F, -3.0F, 0.0F, 0, 3, 4, s); - this.setRotateAngle(bootLwing1, 0.2617993877991494F, 0.5235987755982988F, 0.2617993877991494F); + this.helmAnchor = new ModelRenderer(this, 0, 0); + this.helmAnchor.setRotationPoint(0.0F, 0.0F, 0.0F); + this.helmAnchor.addCuboid(-1.0F, -2.0F, 0.0F, 2, 2, 2, s); + this.helm = new ModelRenderer(this, 0, 0); + this.helm.setRotationPoint(0.0F, 0.0F, 0.0F); + this.helm.addCuboid(-4.5F, -9.0F, -4.5F, 9, 9, 9, s); + this.helmFairy = new ModelRenderer(this, 36, 11); + this.helmFairy.setRotationPoint(0.0F, 0.0F, 0.0F); + this.helmFairy.addCuboid(-2.5F, -10.0F, -5.5F, 5, 5, 5, s); + this.helmWing1l = new ModelRenderer(this, 36, 0); + this.helmWing1l.mirror = true; + this.helmWing1l.setRotationPoint(4.5F, -6.0F, -0.5F); + this.helmWing1l.addCuboid(-1.0F, -5.0F, 0.0F, 1, 5, 6, s); + this.setRotateAngle(helmWing1l, 0.2617993877991494F, 0.5235987755982988F, 0.2617993877991494F); + this.helmWing2l = new ModelRenderer(this, 50, 0); + this.helmWing2l.setRotationPoint(4.5F, -6.0F, -0.5F); + this.helmWing2l.addCuboid(-1.0F, 0.0F, 0.0F, 1, 3, 4, s); + this.setRotateAngle(helmWing2l, -0.2617993877991494F, 0.2617993877991494F, -0.2617993877991494F); + this.helmWing1r = new ModelRenderer(this, 36, 0); + this.helmWing1r.setRotationPoint(-4.5F, -6.0F, -0.5F); + this.helmWing1r.addCuboid(0.0F, -5.0F, 0.0F, 1, 5, 6, s); + this.setRotateAngle(helmWing1r, 0.2617993877991494F, -0.5235987755982988F, -0.2617993877991494F); + this.helmWing2r = new ModelRenderer(this, 50, 0); + this.helmWing2r.mirror = true; + this.helmWing2r.setRotationPoint(-4.5F, -6.0F, -0.5F); + this.helmWing2r.addCuboid(0.0F, 0.0F, 0.0F, 1, 3, 4, s); + this.setRotateAngle(helmWing2r, -0.2617993877991494F, -0.2617993877991494F, 0.2617993877991494F); + + //body + this.bodyAnchor = new ModelRenderer(this, 0, 0); + this.bodyAnchor.setRotationPoint(0.0F, 0.0F, 0.0F); + this.bodyAnchor.addCuboid(-1.0F, 0.0F, -1.0F, 2, 2, 2, s); + this.bodyTop = new ModelRenderer(this, 0, 19); + this.bodyTop.setRotationPoint(0.0F, 0.0F, 0.0F); + this.bodyTop.addCuboid(-4.5F, 0.0F, -3.0F, 9, 6, 6, s); + this.bodyBottom = new ModelRenderer(this, 0, 31); + this.bodyBottom.setRotationPoint(0.0F, 0.0F, 0.0F); + this.bodyBottom.addCuboid(-3.5F, 5.0F, -2.5F, 7, 3, 5, s); + + //armL + this.armLAnchor = new ModelRenderer(this, 0, 0); + this.armLAnchor.mirror = true; + this.armLAnchor.setRotationPoint(4.0F, 2.0F, 0.0F); + this.armLAnchor.addCuboid(0.0F, -1.0F, -1.0F, 2, 2, 2, s); + this.armL = new ModelRenderer(this, 24, 40); + this.armL.mirror = true; + this.armL.setRotationPoint(0.0F, 0.0F, -0.0F); + this.armL.addCuboid(0.5F, 4.5F, -2.49F, 3, 6, 5, s); + this.armLpauldron = new ModelRenderer(this, 0, 40); + this.armLpauldron.mirror = true; + this.armLpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); + this.armLpauldron.addCuboid(-0.5F, -3.0F, -3.0F, 6, 7, 6, s); + this.armLwing1 = new ModelRenderer(this, 40, 35); + this.armLwing1.setRotationPoint(6.0F, -1.0F, 0.0F); + this.armLwing1.addCuboid(0.0F, -4.0F, 0.0F, 0, 4, 5, s); + this.setRotateAngle(armLwing1, 0.2617993877991494F, 0.5235987755982988F, 0.2617993877991494F); + this.armLwing2 = new ModelRenderer(this, 40, 40); + this.armLwing2.setRotationPoint(6.0F, -1.0F, 0.0F); + this.armLwing2.addCuboid(0.0F, 0.0F, 0.0F, 0, 3, 4, s); + this.setRotateAngle(armLwing2, -0.2617993877991494F, 0.2617993877991494F, -0.2617993877991494F); + + //armR + this.armRAnchor = new ModelRenderer(this, 0, 0); + this.armRAnchor.mirror = true; + this.armRAnchor.setRotationPoint(-4.0F, 2.0F, 0.0F); + this.armRAnchor.addCuboid(-2.0F, -1.0F, -1.0F, 2, 2, 2, s); + this.armR = new ModelRenderer(this, 24, 40); + this.armR.setRotationPoint(0.0F, 0.0F, 0.0F); + this.armR.addCuboid(-3.5F, 4.5F, -2.51F, 3, 6, 5, s); + this.armRpauldron = new ModelRenderer(this, 0, 40); + this.armRpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); + this.armRpauldron.addCuboid(-5.5F, -3.0F, -3.0F, 6, 7, 6, s); + this.setRotateAngle(armRpauldron, 0.0F, 0.0F, 0.0017453292519943296F); + this.armRwing1 = new ModelRenderer(this, 40, 35); + this.armRwing1.mirror = true; + this.armRwing1.setRotationPoint(-6.5F, -1.0F, 0.0F); + this.armRwing1.addCuboid(0.0F, -4.0F, 0.0F, 0, 4, 5, s); + this.setRotateAngle(armRwing1, 0.2617993877991494F, -0.5235987755982988F, -0.2617993877991494F); + this.armRwing2 = new ModelRenderer(this, 40, 40); + this.armRwing2.mirror = true; + this.armRwing2.setRotationPoint(-6.5F, -1.0F, 0.0F); + this.armRwing2.addCuboid(0.0F, 0.0F, 0.0F, 0, 3, 4, s); + this.setRotateAngle(armRwing2, -0.2617993877991494F, -0.2617993877991494F, 0.2617993877991494F); + + //pants + this.pantsAnchor = new ModelRenderer(this, 0, 0); + this.pantsAnchor.setRotationPoint(0.0F, 0.0F, 0.0F); + this.pantsAnchor.addCuboid(-1.0F, 0.0F, -1.0F, 2, 2, 2, s); + this.belt = new ModelRenderer(this, 0, 53); + this.belt.setRotationPoint(0.0F, 0.0F, 0.0F); + this.belt.addCuboid(-4.5F, 8.0F, -3.0F, 9, 5, 6, s); + this.legL = new ModelRenderer(this, 0, 64); + this.legL.mirror = true; + this.legL.setRotationPoint(1.9F, 12.0F, 0.0F); + this.legL.addCuboid(-2.39F, 0.0F, -2.49F, 5, 6, 5, s); + this.legR = new ModelRenderer(this, 0, 64); + this.legR.setRotationPoint(-1.9F, 12.0F, 0.0F); + this.legR.addCuboid(-2.61F, 0.0F, -2.51F, 5, 6, 5, s); + + //boots + this.bootL = new ModelRenderer(this, 0, 75); + this.bootL.mirror = true; + this.bootL.setRotationPoint(1.9F, 12.0F, 0.0F); + this.bootL.addCuboid(-2.39F, 8.5F, -2.49F, 5, 5, 5, s); + this.bootLwing1 = new ModelRenderer(this, 40, 40); + this.bootLwing1.setRotationPoint(2.5F, 8.5F, 0.0F); + this.bootLwing1.addCuboid(0.0F, -3.0F, 0.0F, 0, 3, 4, s); + this.setRotateAngle(bootLwing1, 0.2617993877991494F, 0.5235987755982988F, 0.2617993877991494F); this.bootLwing2 = new ModelRenderer(this, 40, 44); - this.bootLwing2.setRotationPoint(2.5F, 8.5F, 0.0F); - this.bootLwing2.addCuboid(0.0F, 0.0F, 0.0F, 0, 2, 3, s); - this.setRotateAngle(bootLwing2, -0.2617993877991494F, 0.2617993877991494F, -0.2617993877991494F); + this.bootLwing2.setRotationPoint(2.5F, 8.5F, 0.0F); + this.bootLwing2.addCuboid(0.0F, 0.0F, 0.0F, 0, 2, 3, s); + this.setRotateAngle(bootLwing2, -0.2617993877991494F, 0.2617993877991494F, -0.2617993877991494F); this.bootR = new ModelRenderer(this, 0, 75); - this.bootR.setRotationPoint(-1.9F, 12.0F, 0.0F); - this.bootR.addCuboid(-2.61F, 8.5F, -2.51F, 5, 5, 5, s); + this.bootR.setRotationPoint(-1.9F, 12.0F, 0.0F); + this.bootR.addCuboid(-2.61F, 8.5F, -2.51F, 5, 5, 5, s); this.bootRwing1 = new ModelRenderer(this, 40, 40); - this.bootRwing1.mirror = true; - this.bootRwing1.setRotationPoint(-2.6F, 8.5F, 0.0F); - this.bootRwing1.addCuboid(0.0F, -3.0F, 0.0F, 0, 3, 4, s); - this.setRotateAngle(bootRwing1, 0.2617993877991494F, -0.5235987755982988F, -0.2617993877991494F); + this.bootRwing1.mirror = true; + this.bootRwing1.setRotationPoint(-2.6F, 8.5F, 0.0F); + this.bootRwing1.addCuboid(0.0F, -3.0F, 0.0F, 0, 3, 4, s); + this.setRotateAngle(bootRwing1, 0.2617993877991494F, -0.5235987755982988F, -0.2617993877991494F); this.bootRwing2 = new ModelRenderer(this, 40, 44); - this.bootRwing2.mirror = true; - this.bootRwing2.setRotationPoint(-2.5F, 8.5F, 0.0F); - this.bootRwing2.addCuboid(0.0F, 0.0F, 0.0F, 0, 2, 3, s); - this.setRotateAngle(bootRwing2, -0.2617993877991494F, -0.2617993877991494F, 0.2617993877991494F); - - //hierarchy - this.helmAnchor.addChild(this.helm); - this.helm.addChild(this.helmFairy); - this.helm.addChild(this.helmWing1l); - this.helm.addChild(this.helmWing2l); - this.helm.addChild(this.helmWing1r); - this.helm.addChild(this.helmWing2r); - - this.bodyAnchor.addChild(this.bodyTop); - this.bodyTop.addChild(this.bodyBottom); - this.armLAnchor.addChild(this.armL); - this.armL.addChild(this.armLpauldron); - this.armLpauldron.addChild(this.armLwing1); - this.armLpauldron.addChild(this.armLwing2); - this.armRAnchor.addChild(this.armR); - this.armR.addChild(this.armRpauldron); - this.armRpauldron.addChild(this.armRwing1); - this.armRpauldron.addChild(this.armRwing2); - - this.pantsAnchor.addChild(this.belt); - this.belt.addChild(this.legL); - this.belt.addChild(this.legR);; - - this.bootL.addChild(bootLwing1); - this.bootL.addChild(bootLwing2); - this.bootR.addChild(bootRwing1); - this.bootR.addChild(bootRwing2); + this.bootRwing2.mirror = true; + this.bootRwing2.setRotationPoint(-2.5F, 8.5F, 0.0F); + this.bootRwing2.addCuboid(0.0F, 0.0F, 0.0F, 0, 2, 3, s); + this.setRotateAngle(bootRwing2, -0.2617993877991494F, -0.2617993877991494F, 0.2617993877991494F); + + //hierarchy + this.helmAnchor.addChild(this.helm); + this.helm.addChild(this.helmFairy); + this.helm.addChild(this.helmWing1l); + this.helm.addChild(this.helmWing2l); + this.helm.addChild(this.helmWing1r); + this.helm.addChild(this.helmWing2r); + + this.bodyAnchor.addChild(this.bodyTop); + this.bodyTop.addChild(this.bodyBottom); + this.armLAnchor.addChild(this.armL); + this.armL.addChild(this.armLpauldron); + this.armLpauldron.addChild(this.armLwing1); + this.armLpauldron.addChild(this.armLwing2); + this.armRAnchor.addChild(this.armR); + this.armR.addChild(this.armRpauldron); + this.armRpauldron.addChild(this.armRwing1); + this.armRpauldron.addChild(this.armRwing2); + + this.pantsAnchor.addChild(this.belt); + this.belt.addChild(this.legL); + this.belt.addChild(this.legR);; + + this.bootL.addChild(bootLwing1); + this.bootL.addChild(bootLwing2); + this.bootR.addChild(bootRwing1); + this.bootR.addChild(bootRwing2); } @Override public void render(MatrixStack ms, IVertexBuilder buffer, int light, int overlay, float r, float g, float b, float a) { - + helmAnchor.showModel = slot == EquipmentSlotType.HEAD; bodyAnchor.showModel = slot == EquipmentSlotType.CHEST; armRAnchor.showModel = slot == EquipmentSlotType.CHEST; @@ -237,7 +232,7 @@ public class ModelArmorElementium extends ModelArmor { bipedBody = bodyAnchor; bipedRightArm = armRAnchor; bipedLeftArm = armLAnchor; - if(slot == EquipmentSlotType.LEGS) { + if (slot == EquipmentSlotType.LEGS) { bipedBody = pantsAnchor; bipedRightLeg = legR; bipedLeftLeg = legL; @@ -248,4 +243,4 @@ public class ModelArmorElementium extends ModelArmor { super.render(ms, buffer, light, overlay, r, g, b, a); } -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/client/model/armor/ModelArmorManasteel.java b/src/main/java/vazkii/botania/client/model/armor/ModelArmorManasteel.java index fee6b1e3b..fd165aff2 100644 --- a/src/main/java/vazkii/botania/client/model/armor/ModelArmorManasteel.java +++ b/src/main/java/vazkii/botania/client/model/armor/ModelArmorManasteel.java @@ -1,177 +1,172 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [? (GMT)] */ package vazkii.botania.client.model.armor; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.renderer.model.ModelRenderer; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; import net.minecraft.inventory.EquipmentSlotType; -import javax.annotation.Nonnull; - public class ModelArmorManasteel extends ModelArmor { - + private final ModelRenderer helmAnchor; private final ModelRenderer helm; - private final ModelRenderer helmTop; - private final ModelRenderer helmCrystal; - + private final ModelRenderer helmTop; + private final ModelRenderer helmCrystal; + private final ModelRenderer bodyAnchor; private final ModelRenderer bodyTop; private final ModelRenderer bodyBottom; - + private final ModelRenderer armLAnchor; private final ModelRenderer armL; private final ModelRenderer armLpauldron; private final ModelRenderer armLcrystal; - + private final ModelRenderer armRAnchor; private final ModelRenderer armR; private final ModelRenderer armRpauldron; - private final ModelRenderer armRcrystal; + private final ModelRenderer armRcrystal; private final ModelRenderer pantsAnchor; private final ModelRenderer belt; - private final ModelRenderer legL; - private final ModelRenderer legR; - - private final ModelRenderer bootL; - private final ModelRenderer bootLcrystal; - private final ModelRenderer bootR; + private final ModelRenderer legL; + private final ModelRenderer legR; + + private final ModelRenderer bootL; + private final ModelRenderer bootLcrystal; + private final ModelRenderer bootR; private final ModelRenderer bootRcrystal; - + public ModelArmorManasteel(EquipmentSlotType slot) { super(slot); this.textureWidth = 64; - this.textureHeight = 128; + this.textureHeight = 128; float s = 0.01F; - + //helm - this.helmAnchor = new ModelRenderer(this, 0, 0); - this.helmAnchor.setRotationPoint(0.0F, 0.0F, 0.0F); - this.helmAnchor.addCuboid(-1.0F, -2.0F, 0.0F, 2, 2, 2, s); - this.helm = new ModelRenderer(this, 0, 0); - this.helm.setRotationPoint(0.0F, 0.0F, 0.0F); - this.helm.addCuboid(-4.5F, -8.5F, -4.5F, 9, 9, 9, s); - this.helmTop = new ModelRenderer(this, 36, 6); - this.helmTop.setRotationPoint(0.0F, -8.5F, 3.5F); - this.helmTop.addCuboid(-1.5F, 0.0F, -7.0F, 3, 3, 7, s); - this.setRotateAngle(helmTop, -0.2617993877991494F, 0.0F, 0.0F); - this.helmCrystal = new ModelRenderer(this, 36, 0); - this.helmCrystal.setRotationPoint(0.0F, -7.5F, -4.5F); - this.helmCrystal.addCuboid(-1.5F, -4.0F, -1.0F, 3, 5, 1, s); - this.setRotateAngle(helmCrystal, 0.08726646259971647F, 0.0F, 0.0F); - - //body - this.bodyAnchor = new ModelRenderer(this, 0, 0); - this.bodyAnchor.setRotationPoint(0.0F, 0.0F, 0.0F); - this.bodyAnchor.addCuboid(-1.0F, 0.0F, -1.0F, 2, 2, 2, s); - this.bodyTop = new ModelRenderer(this, 0, 18); - this.bodyTop.setRotationPoint(0.0F, 0.0F, 0.0F); - this.bodyTop.addCuboid(-4.5F, -0.5F, -3.0F, 9, 6, 6, s); - this.setRotateAngle(bodyTop, 0.0F, 0.0F, 0.0F); - this.bodyBottom = new ModelRenderer(this, 0, 30); - this.bodyBottom.setRotationPoint(0.0F, 0.0F, 0.0F); - this.bodyBottom.addCuboid(-2.5F, 5.5F, -2.5F, 5, 3, 5, 0.0F); - - //armL - this.armLAnchor = new ModelRenderer(this, 0, 0); - this.armLAnchor.mirror = true; - this.armLAnchor.setRotationPoint(4.0F, 2.0F, 0.0F); - this.armLAnchor.addCuboid(0.0F, -1.0F, -1.0F, 2, 2, 2, s); - this.armL = new ModelRenderer(this, 22, 40); - this.armL.mirror = true; - this.armL.setRotationPoint(0.0F, 0.0F, 0.0F); - this.armL.addCuboid(1.5F, 2.0F, -2.49F, 2, 6, 5, s); - this.armLpauldron = new ModelRenderer(this, 0, 40); - this.armLpauldron.mirror = true; - this.armLpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); - this.armLpauldron.addCuboid(-0.5F, -3.0F, -3.0F, 5, 4, 6, s); - this.armLcrystal = new ModelRenderer(this, 36, 40); - this.armLcrystal.mirror = true; - this.armLcrystal.setRotationPoint(2.0F, -2.5F, 0.0F); - this.armLcrystal.addCuboid(-0.5F, -2.5F, -1.5F, 2, 3, 3, s); - this.setRotateAngle(armLcrystal, 0.0F, 0.0F, -0.08726646259971647F); - - //armR - this.armRAnchor = new ModelRenderer(this, 0, 0); - this.armRAnchor.mirror = true; - this.armRAnchor.setRotationPoint(-4.0F, 2.0F, 0.0F); - this.armRAnchor.addCuboid(-2.0F, -1.0F, -1.0F, 2, 2, 2, s); - this.armR = new ModelRenderer(this, 22, 40); - this.armR.setRotationPoint(0.0F, 0.0F, 0.0F); - this.armR.addCuboid(-3.5F, 2.0F, -2.51F, 2, 6, 5, s); - this.armRpauldron = new ModelRenderer(this, 0, 40); - this.armRpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); - this.armRpauldron.addCuboid(-4.5F, -3.0F, -3.0F, 5, 4, 6, s); - this.armRcrystal = new ModelRenderer(this, 36, 40); - this.armRcrystal.setRotationPoint(-2.0F, -2.5F, 0.0F); - this.armRcrystal.addCuboid(-1.5F, -2.5F, -1.5F, 2, 3, 3, s); - this.setRotateAngle(armRcrystal, 0.0F, 0.0F, 0.08726646259971647F); - - //pants - this.pantsAnchor = new ModelRenderer(this, 0, 0); - this.pantsAnchor.setRotationPoint(0.0F, 0.0F, 0.0F); - this.pantsAnchor.addCuboid(-1.0F, 0.0F, -1.0F, 2, 2, 2, s); - this.belt = new ModelRenderer(this, 0, 51); - this.belt.setRotationPoint(0.0F, 0.0F, 0.0F); - this.belt.addCuboid(-4.5F, 9.0F, -3.0F, 9, 3, 6, s); - this.legL = new ModelRenderer(this, 0, 60); - this.legL.mirror = true; - this.legL.setRotationPoint(1.9F, 12.0F, 0.0F); - this.legL.addCuboid(-0.39F, 0.0F, -2.49F, 3, 6, 5, s); - this.legR = new ModelRenderer(this, 0, 60); - this.legR.setRotationPoint(-1.9F, 12.0F, 0.0F); - this.legR.addCuboid(-2.61F, 0.0F, -2.51F, 3, 6, 5, s); - - //boots - this.bootL = new ModelRenderer(this, 0, 71); - this.bootL.mirror = true; - this.bootL.setRotationPoint(1.9F, 12.0F, 0.0F); - this.bootL.addCuboid(-2.39F, 8.5F, -2.49F, 5, 4, 5, s); - this.bootLcrystal = new ModelRenderer(this, 36, 46); - this.bootLcrystal.mirror = true; - this.bootLcrystal.setRotationPoint(2.5F, 9.0F, 2.0F); - this.bootLcrystal.addCuboid(-1.0F, -2.0F, -1.5F, 2, 3, 3, s); - this.setRotateAngle(bootLcrystal, 0.0F, 0.0F, 0.08726646259971647F); - this.bootR = new ModelRenderer(this, 0, 71); - this.bootR.setRotationPoint(-2.0F, 12.0F, 0.0F); - this.bootR.addCuboid(-2.5F, 8.5F, -2.51F, 5, 4, 5, s); - this.bootRcrystal = new ModelRenderer(this, 36, 46); - this.bootRcrystal.setRotationPoint(-2.5F, 9.0F, 2.0F); - this.bootRcrystal.addCuboid(-1.0F, -2.0F, -1.5F, 2, 3, 3, s); - this.setRotateAngle(bootRcrystal, 0.0F, 0.0F, -0.08726646259971647F); - - //hierarchy - this.helmAnchor.addChild(this.helm); - this.helm.addChild(this.helmTop); - this.helm.addChild(this.helmCrystal); - - this.bodyAnchor.addChild(this.bodyTop); - this.bodyTop.addChild(this.bodyBottom); - this.armLAnchor.addChild(this.armL); - this.armL.addChild(this.armLpauldron); - this.armLpauldron.addChild(this.armLcrystal); - this.armRAnchor.addChild(this.armR); - this.armR.addChild(this.armRpauldron); - this.armRpauldron.addChild(this.armRcrystal); - - this.pantsAnchor.addChild(this.belt); - this.belt.addChild(this.legL); - this.belt.addChild(this.legR);; - - this.bootL.addChild(bootLcrystal); - this.bootR.addChild(bootRcrystal); + this.helmAnchor = new ModelRenderer(this, 0, 0); + this.helmAnchor.setRotationPoint(0.0F, 0.0F, 0.0F); + this.helmAnchor.addCuboid(-1.0F, -2.0F, 0.0F, 2, 2, 2, s); + this.helm = new ModelRenderer(this, 0, 0); + this.helm.setRotationPoint(0.0F, 0.0F, 0.0F); + this.helm.addCuboid(-4.5F, -8.5F, -4.5F, 9, 9, 9, s); + this.helmTop = new ModelRenderer(this, 36, 6); + this.helmTop.setRotationPoint(0.0F, -8.5F, 3.5F); + this.helmTop.addCuboid(-1.5F, 0.0F, -7.0F, 3, 3, 7, s); + this.setRotateAngle(helmTop, -0.2617993877991494F, 0.0F, 0.0F); + this.helmCrystal = new ModelRenderer(this, 36, 0); + this.helmCrystal.setRotationPoint(0.0F, -7.5F, -4.5F); + this.helmCrystal.addCuboid(-1.5F, -4.0F, -1.0F, 3, 5, 1, s); + this.setRotateAngle(helmCrystal, 0.08726646259971647F, 0.0F, 0.0F); + + //body + this.bodyAnchor = new ModelRenderer(this, 0, 0); + this.bodyAnchor.setRotationPoint(0.0F, 0.0F, 0.0F); + this.bodyAnchor.addCuboid(-1.0F, 0.0F, -1.0F, 2, 2, 2, s); + this.bodyTop = new ModelRenderer(this, 0, 18); + this.bodyTop.setRotationPoint(0.0F, 0.0F, 0.0F); + this.bodyTop.addCuboid(-4.5F, -0.5F, -3.0F, 9, 6, 6, s); + this.setRotateAngle(bodyTop, 0.0F, 0.0F, 0.0F); + this.bodyBottom = new ModelRenderer(this, 0, 30); + this.bodyBottom.setRotationPoint(0.0F, 0.0F, 0.0F); + this.bodyBottom.addCuboid(-2.5F, 5.5F, -2.5F, 5, 3, 5, 0.0F); + + //armL + this.armLAnchor = new ModelRenderer(this, 0, 0); + this.armLAnchor.mirror = true; + this.armLAnchor.setRotationPoint(4.0F, 2.0F, 0.0F); + this.armLAnchor.addCuboid(0.0F, -1.0F, -1.0F, 2, 2, 2, s); + this.armL = new ModelRenderer(this, 22, 40); + this.armL.mirror = true; + this.armL.setRotationPoint(0.0F, 0.0F, 0.0F); + this.armL.addCuboid(1.5F, 2.0F, -2.49F, 2, 6, 5, s); + this.armLpauldron = new ModelRenderer(this, 0, 40); + this.armLpauldron.mirror = true; + this.armLpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); + this.armLpauldron.addCuboid(-0.5F, -3.0F, -3.0F, 5, 4, 6, s); + this.armLcrystal = new ModelRenderer(this, 36, 40); + this.armLcrystal.mirror = true; + this.armLcrystal.setRotationPoint(2.0F, -2.5F, 0.0F); + this.armLcrystal.addCuboid(-0.5F, -2.5F, -1.5F, 2, 3, 3, s); + this.setRotateAngle(armLcrystal, 0.0F, 0.0F, -0.08726646259971647F); + + //armR + this.armRAnchor = new ModelRenderer(this, 0, 0); + this.armRAnchor.mirror = true; + this.armRAnchor.setRotationPoint(-4.0F, 2.0F, 0.0F); + this.armRAnchor.addCuboid(-2.0F, -1.0F, -1.0F, 2, 2, 2, s); + this.armR = new ModelRenderer(this, 22, 40); + this.armR.setRotationPoint(0.0F, 0.0F, 0.0F); + this.armR.addCuboid(-3.5F, 2.0F, -2.51F, 2, 6, 5, s); + this.armRpauldron = new ModelRenderer(this, 0, 40); + this.armRpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); + this.armRpauldron.addCuboid(-4.5F, -3.0F, -3.0F, 5, 4, 6, s); + this.armRcrystal = new ModelRenderer(this, 36, 40); + this.armRcrystal.setRotationPoint(-2.0F, -2.5F, 0.0F); + this.armRcrystal.addCuboid(-1.5F, -2.5F, -1.5F, 2, 3, 3, s); + this.setRotateAngle(armRcrystal, 0.0F, 0.0F, 0.08726646259971647F); + + //pants + this.pantsAnchor = new ModelRenderer(this, 0, 0); + this.pantsAnchor.setRotationPoint(0.0F, 0.0F, 0.0F); + this.pantsAnchor.addCuboid(-1.0F, 0.0F, -1.0F, 2, 2, 2, s); + this.belt = new ModelRenderer(this, 0, 51); + this.belt.setRotationPoint(0.0F, 0.0F, 0.0F); + this.belt.addCuboid(-4.5F, 9.0F, -3.0F, 9, 3, 6, s); + this.legL = new ModelRenderer(this, 0, 60); + this.legL.mirror = true; + this.legL.setRotationPoint(1.9F, 12.0F, 0.0F); + this.legL.addCuboid(-0.39F, 0.0F, -2.49F, 3, 6, 5, s); + this.legR = new ModelRenderer(this, 0, 60); + this.legR.setRotationPoint(-1.9F, 12.0F, 0.0F); + this.legR.addCuboid(-2.61F, 0.0F, -2.51F, 3, 6, 5, s); + + //boots + this.bootL = new ModelRenderer(this, 0, 71); + this.bootL.mirror = true; + this.bootL.setRotationPoint(1.9F, 12.0F, 0.0F); + this.bootL.addCuboid(-2.39F, 8.5F, -2.49F, 5, 4, 5, s); + this.bootLcrystal = new ModelRenderer(this, 36, 46); + this.bootLcrystal.mirror = true; + this.bootLcrystal.setRotationPoint(2.5F, 9.0F, 2.0F); + this.bootLcrystal.addCuboid(-1.0F, -2.0F, -1.5F, 2, 3, 3, s); + this.setRotateAngle(bootLcrystal, 0.0F, 0.0F, 0.08726646259971647F); + this.bootR = new ModelRenderer(this, 0, 71); + this.bootR.setRotationPoint(-2.0F, 12.0F, 0.0F); + this.bootR.addCuboid(-2.5F, 8.5F, -2.51F, 5, 4, 5, s); + this.bootRcrystal = new ModelRenderer(this, 36, 46); + this.bootRcrystal.setRotationPoint(-2.5F, 9.0F, 2.0F); + this.bootRcrystal.addCuboid(-1.0F, -2.0F, -1.5F, 2, 3, 3, s); + this.setRotateAngle(bootRcrystal, 0.0F, 0.0F, -0.08726646259971647F); + + //hierarchy + this.helmAnchor.addChild(this.helm); + this.helm.addChild(this.helmTop); + this.helm.addChild(this.helmCrystal); + + this.bodyAnchor.addChild(this.bodyTop); + this.bodyTop.addChild(this.bodyBottom); + this.armLAnchor.addChild(this.armL); + this.armL.addChild(this.armLpauldron); + this.armLpauldron.addChild(this.armLcrystal); + this.armRAnchor.addChild(this.armR); + this.armR.addChild(this.armRpauldron); + this.armRpauldron.addChild(this.armRcrystal); + + this.pantsAnchor.addChild(this.belt); + this.belt.addChild(this.legL); + this.belt.addChild(this.legR);; + + this.bootL.addChild(bootLcrystal); + this.bootR.addChild(bootRcrystal); } @Override @@ -191,7 +186,7 @@ public class ModelArmorManasteel extends ModelArmor { bipedBody = bodyAnchor; bipedRightArm = armRAnchor; bipedLeftArm = armLAnchor; - if(slot == EquipmentSlotType.LEGS) { + if (slot == EquipmentSlotType.LEGS) { bipedBody = pantsAnchor; bipedRightLeg = legR; bipedLeftLeg = legL; @@ -202,4 +197,4 @@ public class ModelArmorManasteel extends ModelArmor { super.render(ms, buffer, light, overlay, r, g, b, a); } -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/client/model/armor/ModelArmorManaweave.java b/src/main/java/vazkii/botania/client/model/armor/ModelArmorManaweave.java index 401a08e24..de4892d10 100644 --- a/src/main/java/vazkii/botania/client/model/armor/ModelArmorManaweave.java +++ b/src/main/java/vazkii/botania/client/model/armor/ModelArmorManaweave.java @@ -1,151 +1,147 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [? (GMT)] */ package vazkii.botania.client.model.armor; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.renderer.model.ModelRenderer; -import net.minecraft.entity.LivingEntity; import net.minecraft.inventory.EquipmentSlotType; -import javax.annotation.Nonnull; - public class ModelArmorManaweave extends ModelArmor { - + private final ModelRenderer helmAnchor; private final ModelRenderer helm; private final ModelRenderer bodyAnchor; private final ModelRenderer bodyTop; private final ModelRenderer bodyBottom; - + private final ModelRenderer armLAnchor; private final ModelRenderer armL; private final ModelRenderer armLpauldron; private final ModelRenderer armRAnchor; private final ModelRenderer armR; - private final ModelRenderer armRpauldron; - - private final ModelRenderer pantsAnchor; - private final ModelRenderer legL; - private final ModelRenderer skirtL; - private final ModelRenderer legR; - private final ModelRenderer skirtR; - - private final ModelRenderer bootL; - private final ModelRenderer bootR; - + private final ModelRenderer armRpauldron; + + private final ModelRenderer pantsAnchor; + private final ModelRenderer legL; + private final ModelRenderer skirtL; + private final ModelRenderer legR; + private final ModelRenderer skirtR; + + private final ModelRenderer bootL; + private final ModelRenderer bootR; + public ModelArmorManaweave(EquipmentSlotType slot) { super(slot); textureWidth = 64; textureHeight = 128; float s = 0.01F; - + //helm - this.helmAnchor = new ModelRenderer(this, 0, 0); - this.helmAnchor.setRotationPoint(0.0F, 0.0F, 0.0F); - this.helmAnchor.addCuboid(-1.0F, -2.0F, 0.0F, 2, 2, 2, s); - this.helm = new ModelRenderer(this, 0, 0); - this.helm.setRotationPoint(0.0F, 0.0F, 0.0F); - this.helm.addCuboid(-4.5F, -9.5F, -4.0F, 9, 11, 10, s); - this.setRotateAngle(helm, 0.17453292519943295F, 0.0F, 0.0F); - - //body - this.bodyAnchor = new ModelRenderer(this, 0, 0); - this.bodyAnchor.setRotationPoint(0.0F, 0.0F, 0.0F); - this.bodyAnchor.addCuboid(-1.0F, 0.0F, -1.0F, 2, 2, 2, s); - this.bodyTop = new ModelRenderer(this, 0, 21); - this.bodyTop.setRotationPoint(0.0F, 0.0F, 0.0F); - this.bodyTop.addCuboid(-4.5F, -0.5F, -3.0F, 9, 7, 6, s); - this.setRotateAngle(bodyTop, 0.0F, 0.0F, 0.0F); + this.helmAnchor = new ModelRenderer(this, 0, 0); + this.helmAnchor.setRotationPoint(0.0F, 0.0F, 0.0F); + this.helmAnchor.addCuboid(-1.0F, -2.0F, 0.0F, 2, 2, 2, s); + this.helm = new ModelRenderer(this, 0, 0); + this.helm.setRotationPoint(0.0F, 0.0F, 0.0F); + this.helm.addCuboid(-4.5F, -9.5F, -4.0F, 9, 11, 10, s); + this.setRotateAngle(helm, 0.17453292519943295F, 0.0F, 0.0F); + + //body + this.bodyAnchor = new ModelRenderer(this, 0, 0); + this.bodyAnchor.setRotationPoint(0.0F, 0.0F, 0.0F); + this.bodyAnchor.addCuboid(-1.0F, 0.0F, -1.0F, 2, 2, 2, s); + this.bodyTop = new ModelRenderer(this, 0, 21); + this.bodyTop.setRotationPoint(0.0F, 0.0F, 0.0F); + this.bodyTop.addCuboid(-4.5F, -0.5F, -3.0F, 9, 7, 6, s); + this.setRotateAngle(bodyTop, 0.0F, 0.0F, 0.0F); this.bodyBottom = new ModelRenderer(this, 0, 34); - this.bodyBottom.setRotationPoint(0.0F, 0.0F, 0.0F); - this.bodyBottom.addCuboid(-4.5F, 6.5F, -2.5F, 9, 5, 5, s); - this.setRotateAngle(bodyBottom, -0F, 0.0F, 0.0F); - - //armL - this.armLAnchor = new ModelRenderer(this, 0, 0); - this.armLAnchor.mirror = true; - this.armLAnchor.setRotationPoint(4.0F, 2.0F, 0.0F); - this.armLAnchor.addCuboid(0.0F, -1.0F, -1.0F, 2, 2, 2, s); - this.armL = new ModelRenderer(this, 0, 44); - this.armL.mirror = true; - this.armL.setRotationPoint(0.0F, 0.0F, 0.0F); - this.armL.addCuboid(-1.5F, -2.5F, -2.49F, 5, 10, 5, s); - this.armLpauldron = new ModelRenderer(this, 20, 44); - this.armLpauldron.mirror = true; - this.armLpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); - this.armLpauldron.addCuboid(-1.0F, -3.0F, -3.0F, 6, 5, 6, s); - this.setRotateAngle(armLpauldron, 0.0F, 0.0F, -0.08726646259971647F); - - //armR - this.armRAnchor = new ModelRenderer(this, 0, 0); - this.armRAnchor.mirror = true; - this.armRAnchor.setRotationPoint(-4.0F, 2.0F, 0.0F); - this.armRAnchor.addCuboid(-2.0F, -1.0F, -1.0F, 2, 2, 2, s); - this.armR = new ModelRenderer(this, 0, 44); - this.armR.setRotationPoint(0.0F, 0.0F, 0.0F); - this.armR.addCuboid(-3.5F, -2.5F, -2.51F, 5, 10, 5, s); - this.armRpauldron = new ModelRenderer(this, 20, 44); - this.armRpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); - this.armRpauldron.addCuboid(-5.0F, -3.0F, -3.0F, 6, 5, 6, s); - this.setRotateAngle(armRpauldron, 0.0F, 0.0F, 0.08726646259971647F); - - //pants - this.pantsAnchor = new ModelRenderer(this, 0, 0); - this.pantsAnchor.setRotationPoint(0.0F, 0.0F, 0.0F); - this.pantsAnchor.addCuboid(-1.0F, 0.0F, -1.0F, 2, 2, 2, s); - this.legL = new ModelRenderer(this, 0, 78); - this.legL.mirror = true; - this.legL.setRotationPoint(1.9F, 12.0F, 0.0F); - this.legL.addCuboid(-2.39F, -0.5F, -2.49F, 5, 6, 5, s); - this.skirtL = new ModelRenderer(this, 0, 59); - this.skirtL.mirror = true; - this.skirtL.setRotationPoint(-0.5F, -2.0F, -2.5F); - this.skirtL.addCuboid(-1.0F, 0.0F, -0.5F, 5, 13, 6, s); - this.setRotateAngle(skirtL, 0.0F, -0.17453292519943295F, -0.2617993877991494F); - this.legR = new ModelRenderer(this, 0, 78); - this.legR.setRotationPoint(-1.9F, 12.0F, 0.0F); - this.legR.addCuboid(-2.61F, 0.0F, -2.51F, 5, 6, 5, s); + this.bodyBottom.setRotationPoint(0.0F, 0.0F, 0.0F); + this.bodyBottom.addCuboid(-4.5F, 6.5F, -2.5F, 9, 5, 5, s); + this.setRotateAngle(bodyBottom, -0F, 0.0F, 0.0F); + + //armL + this.armLAnchor = new ModelRenderer(this, 0, 0); + this.armLAnchor.mirror = true; + this.armLAnchor.setRotationPoint(4.0F, 2.0F, 0.0F); + this.armLAnchor.addCuboid(0.0F, -1.0F, -1.0F, 2, 2, 2, s); + this.armL = new ModelRenderer(this, 0, 44); + this.armL.mirror = true; + this.armL.setRotationPoint(0.0F, 0.0F, 0.0F); + this.armL.addCuboid(-1.5F, -2.5F, -2.49F, 5, 10, 5, s); + this.armLpauldron = new ModelRenderer(this, 20, 44); + this.armLpauldron.mirror = true; + this.armLpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); + this.armLpauldron.addCuboid(-1.0F, -3.0F, -3.0F, 6, 5, 6, s); + this.setRotateAngle(armLpauldron, 0.0F, 0.0F, -0.08726646259971647F); + + //armR + this.armRAnchor = new ModelRenderer(this, 0, 0); + this.armRAnchor.mirror = true; + this.armRAnchor.setRotationPoint(-4.0F, 2.0F, 0.0F); + this.armRAnchor.addCuboid(-2.0F, -1.0F, -1.0F, 2, 2, 2, s); + this.armR = new ModelRenderer(this, 0, 44); + this.armR.setRotationPoint(0.0F, 0.0F, 0.0F); + this.armR.addCuboid(-3.5F, -2.5F, -2.51F, 5, 10, 5, s); + this.armRpauldron = new ModelRenderer(this, 20, 44); + this.armRpauldron.setRotationPoint(0.0F, 0.0F, 0.0F); + this.armRpauldron.addCuboid(-5.0F, -3.0F, -3.0F, 6, 5, 6, s); + this.setRotateAngle(armRpauldron, 0.0F, 0.0F, 0.08726646259971647F); + + //pants + this.pantsAnchor = new ModelRenderer(this, 0, 0); + this.pantsAnchor.setRotationPoint(0.0F, 0.0F, 0.0F); + this.pantsAnchor.addCuboid(-1.0F, 0.0F, -1.0F, 2, 2, 2, s); + this.legL = new ModelRenderer(this, 0, 78); + this.legL.mirror = true; + this.legL.setRotationPoint(1.9F, 12.0F, 0.0F); + this.legL.addCuboid(-2.39F, -0.5F, -2.49F, 5, 6, 5, s); + this.skirtL = new ModelRenderer(this, 0, 59); + this.skirtL.mirror = true; + this.skirtL.setRotationPoint(-0.5F, -2.0F, -2.5F); + this.skirtL.addCuboid(-1.0F, 0.0F, -0.5F, 5, 13, 6, s); + this.setRotateAngle(skirtL, 0.0F, -0.17453292519943295F, -0.2617993877991494F); + this.legR = new ModelRenderer(this, 0, 78); + this.legR.setRotationPoint(-1.9F, 12.0F, 0.0F); + this.legR.addCuboid(-2.61F, 0.0F, -2.51F, 5, 6, 5, s); this.skirtR = new ModelRenderer(this, 0, 59); - this.skirtR.setRotationPoint(0.5F, -2.0F, -2.5F); - this.skirtR.addCuboid(-4.0F, 0.0F, -0.5F, 5, 13, 6, s); - this.setRotateAngle(skirtR, 0.0F, 0.17453292519943295F, 0.2617993877991494F); - - //boot - this.bootL = new ModelRenderer(this, 0, 89); - this.bootL.mirror = true; - this.bootL.setRotationPoint(1.9F, 12.0F, 0.0F); - this.bootL.addCuboid(-2.39F, 8.5F, -2.49F, 5, 4, 5, s); - this.bootR = new ModelRenderer(this, 0, 89); - this.bootR.setRotationPoint(-1.9F, 12.0F, 0.0F); - this.bootR.addCuboid(-2.61F, 8.5F, -2.51F, 5, 4, 5, s); - - //hierarchy - this.helmAnchor.addChild(this.helm); - - this.bodyAnchor.addChild(this.bodyTop); - this.bodyTop.addChild(this.bodyBottom); - - this.armLAnchor.addChild(this.armL); - this.armL.addChild(this.armLpauldron); - - this.armRAnchor.addChild(this.armR); - this.armR.addChild(this.armRpauldron); - - this.pantsAnchor.addChild(this.legL); - this.pantsAnchor.addChild(this.legR); - this.legL.addChild(this.skirtL); - this.legR.addChild(this.skirtR); + this.skirtR.setRotationPoint(0.5F, -2.0F, -2.5F); + this.skirtR.addCuboid(-4.0F, 0.0F, -0.5F, 5, 13, 6, s); + this.setRotateAngle(skirtR, 0.0F, 0.17453292519943295F, 0.2617993877991494F); + + //boot + this.bootL = new ModelRenderer(this, 0, 89); + this.bootL.mirror = true; + this.bootL.setRotationPoint(1.9F, 12.0F, 0.0F); + this.bootL.addCuboid(-2.39F, 8.5F, -2.49F, 5, 4, 5, s); + this.bootR = new ModelRenderer(this, 0, 89); + this.bootR.setRotationPoint(-1.9F, 12.0F, 0.0F); + this.bootR.addCuboid(-2.61F, 8.5F, -2.51F, 5, 4, 5, s); + + //hierarchy + this.helmAnchor.addChild(this.helm); + + this.bodyAnchor.addChild(this.bodyTop); + this.bodyTop.addChild(this.bodyBottom); + + this.armLAnchor.addChild(this.armL); + this.armL.addChild(this.armLpauldron); + + this.armRAnchor.addChild(this.armR); + this.armR.addChild(this.armRpauldron); + + this.pantsAnchor.addChild(this.legL); + this.pantsAnchor.addChild(this.legR); + this.legL.addChild(this.skirtL); + this.legR.addChild(this.skirtR); } @Override @@ -165,7 +161,7 @@ public class ModelArmorManaweave extends ModelArmor { bipedBody = bodyAnchor; bipedRightArm = armRAnchor; bipedLeftArm = armLAnchor; - if(slot == EquipmentSlotType.LEGS) { + if (slot == EquipmentSlotType.LEGS) { bipedRightLeg = legR; bipedLeftLeg = legL; } else { @@ -175,4 +171,4 @@ public class ModelArmorManaweave extends ModelArmor { super.render(ms, buffer, light, overlay, r, g, b, a); } -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/client/model/armor/ModelArmorTerrasteel.java b/src/main/java/vazkii/botania/client/model/armor/ModelArmorTerrasteel.java index 60a3838ca..bcec650ec 100644 --- a/src/main/java/vazkii/botania/client/model/armor/ModelArmorTerrasteel.java +++ b/src/main/java/vazkii/botania/client/model/armor/ModelArmorTerrasteel.java @@ -1,23 +1,18 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [? (GMT)] */ package vazkii.botania.client.model.armor; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; -import net.minecraft.client.renderer.model.ModelRenderer; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.inventory.EquipmentSlotType; -import javax.annotation.Nonnull; +import net.minecraft.client.renderer.model.ModelRenderer; +import net.minecraft.inventory.EquipmentSlotType; public class ModelArmorTerrasteel extends ModelArmor { @@ -38,236 +33,236 @@ public class ModelArmorTerrasteel extends ModelArmor { private final ModelRenderer bodyAnchor; private final ModelRenderer bodyTop; private final ModelRenderer bodyBottom; - + private final ModelRenderer armLAnchor; private final ModelRenderer armL; private final ModelRenderer armLpauldron; private final ModelRenderer armLbranch1; private final ModelRenderer armLbranch2; - + private final ModelRenderer armRAnchor; private final ModelRenderer armR; private final ModelRenderer armRpauldron; private final ModelRenderer armRbranch1; private final ModelRenderer armRbranch2; - + private final ModelRenderer pantsAnchor; private final ModelRenderer belt; private final ModelRenderer legL; private final ModelRenderer legR; - + private final ModelRenderer bootL; private final ModelRenderer bootLtop; private final ModelRenderer bootLbranch1; private final ModelRenderer bootLbranch2; - + private final ModelRenderer bootR; private final ModelRenderer bootRtop; private final ModelRenderer bootRbranch1; private final ModelRenderer bootRbranch2; - + public ModelArmorTerrasteel(EquipmentSlotType slot) { super(slot); textureWidth = 64; textureHeight = 128; float s = 0.01F; - + //helm - this.helmAnchor = new ModelRenderer(this, 0, 0); - this.helmAnchor.setRotationPoint(0.0F, 0.0F, 0.0F); - this.helmAnchor.addCuboid(-1.0F, -2.0F, 0.0F, 2, 2, 2, s); - this.helm = new ModelRenderer(this, 0, 0); - this.helm.setRotationPoint(0.0F, 0.0F, 0.0F); - this.helm.addCuboid(-4.5F, -9.0F, -4.5F, 9, 11, 9, s); - this.helmFront = new ModelRenderer(this, 36, 0); - this.helmFront.setRotationPoint(0.0F, 0.0F, 0.0F); - this.helmFront.addCuboid(-1.5F, -10.0F, -5.5F, 3, 8, 7, s); - this.helmLeaf1l = new ModelRenderer(this, 56, 14); - this.helmLeaf1l.mirror = true; - this.helmLeaf1l.setRotationPoint(4.5F, -6.0F, -2.5F); - this.helmLeaf1l.addCuboid(0.0F, -3.0F, -1.0F, 2, 3, 1, s); - this.setRotateAngle(helmLeaf1l, -0.2617993877991494F, -0.2617993877991494F, 0.5235987755982988F); - this.helmLeaf2l = new ModelRenderer(this, 56, 8); - this.helmLeaf2l.mirror = true; - this.helmLeaf2l.setRotationPoint(4.5F, -6.0F, -0.5F); - this.helmLeaf2l.addCuboid(0.0F, -5.0F, -1.0F, 2, 5, 1, s); - this.setRotateAngle(helmLeaf2l, -0.5235987755982988F, -0.5235987755982988F, 0.7853981633974483F); - this.helmLeaf3l = new ModelRenderer(this, 56, 0); - this.helmLeaf3l.mirror = true; - this.helmLeaf3l.setRotationPoint(4.5F, -6.0F, 2.5F); - this.helmLeaf3l.addCuboid(0.0F, -7.0F, -1.0F, 2, 7, 1, s); - this.setRotateAngle(helmLeaf3l, -0.7853981633974483F, -0.7853981633974483F, 0.7853981633974483F); - this.helmLeaf1r = new ModelRenderer(this, 56, 14); - this.helmLeaf1r.setRotationPoint(-4.5F, -6.0F, -2.5F); - this.helmLeaf1r.addCuboid(-2.0F, -3.0F, -1.0F, 2, 3, 1, s); - this.setRotateAngle(helmLeaf1r, -0.2617993877991494F, 0.2617993877991494F, -0.5235987755982988F); - this.helmLeaf2r = new ModelRenderer(this, 56, 8); - this.helmLeaf2r.setRotationPoint(-4.5F, -6.0F, -0.5F); - this.helmLeaf2r.addCuboid(-2.0F, -5.0F, -1.0F, 2, 5, 1, s); - this.setRotateAngle(helmLeaf2r, -0.5235987755982988F, 0.5235987755982988F, -0.7853981633974483F); - this.helmLeaf3r = new ModelRenderer(this, 56, 0); - this.helmLeaf3r.setRotationPoint(-4.5F, -6.0F, 2.5F); - this.helmLeaf3r.addCuboid(-2.0F, -7.0F, -1.0F, 2, 7, 1, s); - this.setRotateAngle(helmLeaf3r, -0.7853981633974483F, 0.7853981633974483F, -0.7853981633974483F); - this.helmbranch1l = new ModelRenderer(this, 36, 15); - this.helmbranch1l.mirror = true; - this.helmbranch1l.setRotationPoint(2.5F, -9.0F, -3.5F); - this.helmbranch1l.addCuboid(-1.0F, -1.0F, 0.0F, 2, 2, 7, s); - this.setRotateAngle(helmbranch1l, 0.5235987755982988F, 0.2617993877991494F, 0.0F); - this.helmbranch2l = new ModelRenderer(this, 36, 15); - this.helmbranch2l.mirror = true; - this.helmbranch2l.setRotationPoint(4.5F, -3.0F, -2.5F); - this.helmbranch2l.addCuboid(-1.0F, -1.0F, 0.0F, 2, 2, 7, s); - this.setRotateAngle(helmbranch2l, 0.08726646259971647F, 0.2617993877991494F, 0.0F); - this.helmbranch1r = new ModelRenderer(this, 36, 15); - this.helmbranch1r.setRotationPoint(-2.5F, -9.0F, -3.5F); - this.helmbranch1r.addCuboid(-1.0F, -1.0F, 0.0F, 2, 2, 7, s); - this.setRotateAngle(helmbranch1r, 0.5235987755982988F, -0.2617993877991494F, 0.0F); - this.helmbranch2r = new ModelRenderer(this, 36, 15); - this.helmbranch2r.setRotationPoint(-4.5F, -3.0F, -2.5F); - this.helmbranch2r.addCuboid(-1.0F, -1.0F, 0.0F, 2, 2, 7, s); - this.setRotateAngle(helmbranch2r, 0.08726646259971647F, -0.2617993877991494F, 0.0F); - - //body - this.bodyAnchor = new ModelRenderer(this, 0, 0); - this.bodyAnchor.setRotationPoint(0.0F, 0.0F, 0.0F); - this.bodyAnchor.addCuboid(-1.0F, 0.0F, -1.0F, 2, 2, 2, s); - this.bodyTop = new ModelRenderer(this, 0, 20); - this.bodyTop.setRotationPoint(0.0F, 0.0F, 0.0F); - this.bodyTop.addCuboid(-5.5F, 0.0F, -3.0F, 11, 6, 6, s); - this.bodyBottom = new ModelRenderer(this, 0, 32); - this.bodyBottom.setRotationPoint(0.0F, 0.0F, 0.0F); - this.bodyBottom.addCuboid(-4.5F, 5.0F, -2.5F, 9, 3, 5, s); - - //armL - this.armLAnchor = new ModelRenderer(this, 0, 0); - this.armLAnchor.mirror = true; - this.armLAnchor.setRotationPoint(4.0F, 2.0F, 0.0F); - this.armLAnchor.addCuboid(0.0F, -1.0F, -1.0F, 2, 2, 2, s); + this.helmAnchor = new ModelRenderer(this, 0, 0); + this.helmAnchor.setRotationPoint(0.0F, 0.0F, 0.0F); + this.helmAnchor.addCuboid(-1.0F, -2.0F, 0.0F, 2, 2, 2, s); + this.helm = new ModelRenderer(this, 0, 0); + this.helm.setRotationPoint(0.0F, 0.0F, 0.0F); + this.helm.addCuboid(-4.5F, -9.0F, -4.5F, 9, 11, 9, s); + this.helmFront = new ModelRenderer(this, 36, 0); + this.helmFront.setRotationPoint(0.0F, 0.0F, 0.0F); + this.helmFront.addCuboid(-1.5F, -10.0F, -5.5F, 3, 8, 7, s); + this.helmLeaf1l = new ModelRenderer(this, 56, 14); + this.helmLeaf1l.mirror = true; + this.helmLeaf1l.setRotationPoint(4.5F, -6.0F, -2.5F); + this.helmLeaf1l.addCuboid(0.0F, -3.0F, -1.0F, 2, 3, 1, s); + this.setRotateAngle(helmLeaf1l, -0.2617993877991494F, -0.2617993877991494F, 0.5235987755982988F); + this.helmLeaf2l = new ModelRenderer(this, 56, 8); + this.helmLeaf2l.mirror = true; + this.helmLeaf2l.setRotationPoint(4.5F, -6.0F, -0.5F); + this.helmLeaf2l.addCuboid(0.0F, -5.0F, -1.0F, 2, 5, 1, s); + this.setRotateAngle(helmLeaf2l, -0.5235987755982988F, -0.5235987755982988F, 0.7853981633974483F); + this.helmLeaf3l = new ModelRenderer(this, 56, 0); + this.helmLeaf3l.mirror = true; + this.helmLeaf3l.setRotationPoint(4.5F, -6.0F, 2.5F); + this.helmLeaf3l.addCuboid(0.0F, -7.0F, -1.0F, 2, 7, 1, s); + this.setRotateAngle(helmLeaf3l, -0.7853981633974483F, -0.7853981633974483F, 0.7853981633974483F); + this.helmLeaf1r = new ModelRenderer(this, 56, 14); + this.helmLeaf1r.setRotationPoint(-4.5F, -6.0F, -2.5F); + this.helmLeaf1r.addCuboid(-2.0F, -3.0F, -1.0F, 2, 3, 1, s); + this.setRotateAngle(helmLeaf1r, -0.2617993877991494F, 0.2617993877991494F, -0.5235987755982988F); + this.helmLeaf2r = new ModelRenderer(this, 56, 8); + this.helmLeaf2r.setRotationPoint(-4.5F, -6.0F, -0.5F); + this.helmLeaf2r.addCuboid(-2.0F, -5.0F, -1.0F, 2, 5, 1, s); + this.setRotateAngle(helmLeaf2r, -0.5235987755982988F, 0.5235987755982988F, -0.7853981633974483F); + this.helmLeaf3r = new ModelRenderer(this, 56, 0); + this.helmLeaf3r.setRotationPoint(-4.5F, -6.0F, 2.5F); + this.helmLeaf3r.addCuboid(-2.0F, -7.0F, -1.0F, 2, 7, 1, s); + this.setRotateAngle(helmLeaf3r, -0.7853981633974483F, 0.7853981633974483F, -0.7853981633974483F); + this.helmbranch1l = new ModelRenderer(this, 36, 15); + this.helmbranch1l.mirror = true; + this.helmbranch1l.setRotationPoint(2.5F, -9.0F, -3.5F); + this.helmbranch1l.addCuboid(-1.0F, -1.0F, 0.0F, 2, 2, 7, s); + this.setRotateAngle(helmbranch1l, 0.5235987755982988F, 0.2617993877991494F, 0.0F); + this.helmbranch2l = new ModelRenderer(this, 36, 15); + this.helmbranch2l.mirror = true; + this.helmbranch2l.setRotationPoint(4.5F, -3.0F, -2.5F); + this.helmbranch2l.addCuboid(-1.0F, -1.0F, 0.0F, 2, 2, 7, s); + this.setRotateAngle(helmbranch2l, 0.08726646259971647F, 0.2617993877991494F, 0.0F); + this.helmbranch1r = new ModelRenderer(this, 36, 15); + this.helmbranch1r.setRotationPoint(-2.5F, -9.0F, -3.5F); + this.helmbranch1r.addCuboid(-1.0F, -1.0F, 0.0F, 2, 2, 7, s); + this.setRotateAngle(helmbranch1r, 0.5235987755982988F, -0.2617993877991494F, 0.0F); + this.helmbranch2r = new ModelRenderer(this, 36, 15); + this.helmbranch2r.setRotationPoint(-4.5F, -3.0F, -2.5F); + this.helmbranch2r.addCuboid(-1.0F, -1.0F, 0.0F, 2, 2, 7, s); + this.setRotateAngle(helmbranch2r, 0.08726646259971647F, -0.2617993877991494F, 0.0F); + + //body + this.bodyAnchor = new ModelRenderer(this, 0, 0); + this.bodyAnchor.setRotationPoint(0.0F, 0.0F, 0.0F); + this.bodyAnchor.addCuboid(-1.0F, 0.0F, -1.0F, 2, 2, 2, s); + this.bodyTop = new ModelRenderer(this, 0, 20); + this.bodyTop.setRotationPoint(0.0F, 0.0F, 0.0F); + this.bodyTop.addCuboid(-5.5F, 0.0F, -3.0F, 11, 6, 6, s); + this.bodyBottom = new ModelRenderer(this, 0, 32); + this.bodyBottom.setRotationPoint(0.0F, 0.0F, 0.0F); + this.bodyBottom.addCuboid(-4.5F, 5.0F, -2.5F, 9, 3, 5, s); + + //armL + this.armLAnchor = new ModelRenderer(this, 0, 0); + this.armLAnchor.mirror = true; + this.armLAnchor.setRotationPoint(4.0F, 2.0F, 0.0F); + this.armLAnchor.addCuboid(0.0F, -1.0F, -1.0F, 2, 2, 2, s); this.armL = new ModelRenderer(this, 0, 52); - this.armL.mirror = true; - this.armL.setRotationPoint(0.0F, 0.0F, 0.0F); - this.armL.addCuboid(-1.5F, 3.0F, -2.49F, 5, 8, 5, s); - this.armLpauldron = new ModelRenderer(this, 0, 40); - this.armLpauldron.mirror = true; - this.armLpauldron.setRotationPoint(1.5F, 0.0F, 0.0F); - this.armLpauldron.addCuboid(-1.0F, -3.0F, -3.0F, 6, 6, 6, s); - this.armLbranch1 = new ModelRenderer(this, 36, 15); - this.armLbranch1.mirror = true; - this.armLbranch1.setRotationPoint(4.0F, -3.0F, -1.0F); - this.armLbranch1.addCuboid(-1.0F, -1.0F, 0.0F, 2, 2, 7, s); - this.setRotateAngle(armLbranch1, 0.5235987755982988F, 0.5235987755982988F, 0.0F); - this.armLbranch2 = new ModelRenderer(this, 36, 24); - this.armLbranch2.mirror = true; - this.armLbranch2.setRotationPoint(5.0F, -2.0F, 0.0F); - this.armLbranch2.addCuboid(-1.0F, 0.0F, 0.0F, 2, 2, 5, s); - this.setRotateAngle(armLbranch2, 0.08726646259971647F, 0.7853981633974483F, 0.0F); - - //armR - this.armRAnchor = new ModelRenderer(this, 0, 0); - this.armRAnchor.mirror = true; - this.armRAnchor.setRotationPoint(-4.0F, 2.0F, 0.0F); - this.armRAnchor.addCuboid(-2.0F, -1.0F, -1.0F, 2, 2, 2, s); + this.armL.mirror = true; + this.armL.setRotationPoint(0.0F, 0.0F, 0.0F); + this.armL.addCuboid(-1.5F, 3.0F, -2.49F, 5, 8, 5, s); + this.armLpauldron = new ModelRenderer(this, 0, 40); + this.armLpauldron.mirror = true; + this.armLpauldron.setRotationPoint(1.5F, 0.0F, 0.0F); + this.armLpauldron.addCuboid(-1.0F, -3.0F, -3.0F, 6, 6, 6, s); + this.armLbranch1 = new ModelRenderer(this, 36, 15); + this.armLbranch1.mirror = true; + this.armLbranch1.setRotationPoint(4.0F, -3.0F, -1.0F); + this.armLbranch1.addCuboid(-1.0F, -1.0F, 0.0F, 2, 2, 7, s); + this.setRotateAngle(armLbranch1, 0.5235987755982988F, 0.5235987755982988F, 0.0F); + this.armLbranch2 = new ModelRenderer(this, 36, 24); + this.armLbranch2.mirror = true; + this.armLbranch2.setRotationPoint(5.0F, -2.0F, 0.0F); + this.armLbranch2.addCuboid(-1.0F, 0.0F, 0.0F, 2, 2, 5, s); + this.setRotateAngle(armLbranch2, 0.08726646259971647F, 0.7853981633974483F, 0.0F); + + //armR + this.armRAnchor = new ModelRenderer(this, 0, 0); + this.armRAnchor.mirror = true; + this.armRAnchor.setRotationPoint(-4.0F, 2.0F, 0.0F); + this.armRAnchor.addCuboid(-2.0F, -1.0F, -1.0F, 2, 2, 2, s); this.armR = new ModelRenderer(this, 0, 52); - this.armR.setRotationPoint(0.0F, 0.0F, 0.0F); - this.armR.addCuboid(-3.5F, 3.0F, -2.51F, 5, 8, 5, s); - this.armRpauldron = new ModelRenderer(this, 0, 40); - this.armRpauldron.setRotationPoint(-1.5F, 0.0F, 0.0F); - this.armRpauldron.addCuboid(-5.0F, -3.0F, -3.0F, 6, 6, 6, s); - this.armRbranch1 = new ModelRenderer(this, 36, 15); - this.armRbranch1.setRotationPoint(-4.0F, -3.0F, -1.0F); - this.armRbranch1.addCuboid(-1.0F, -1.0F, 0.0F, 2, 2, 7, s); - this.setRotateAngle(armRbranch1, 0.5235987755982988F, -0.5235987755982988F, 0.0F); - this.armRbranch2 = new ModelRenderer(this, 36, 24); - this.armRbranch2.setRotationPoint(-5.0F, -2.0F, 0.0F); - this.armRbranch2.addCuboid(-1.0F, 0.0F, 0.0F, 2, 2, 5, s); - this.setRotateAngle(armRbranch2, 0.08726646259971647F, -0.7853981633974483F, 0.0F); - - //pants - this.pantsAnchor = new ModelRenderer(this, 0, 0); - this.pantsAnchor.setRotationPoint(0.0F, 0.0F, 0.0F); - this.pantsAnchor.addCuboid(-1.0F, 0.0F, -1.0F, 2, 2, 2, s); - this.belt = new ModelRenderer(this, 0, 65); - this.belt.setRotationPoint(0.0F, 0.0F, 0.0F); - this.belt.addCuboid(-4.5F, 8.0F, -3.0F, 9, 5, 6, s); + this.armR.setRotationPoint(0.0F, 0.0F, 0.0F); + this.armR.addCuboid(-3.5F, 3.0F, -2.51F, 5, 8, 5, s); + this.armRpauldron = new ModelRenderer(this, 0, 40); + this.armRpauldron.setRotationPoint(-1.5F, 0.0F, 0.0F); + this.armRpauldron.addCuboid(-5.0F, -3.0F, -3.0F, 6, 6, 6, s); + this.armRbranch1 = new ModelRenderer(this, 36, 15); + this.armRbranch1.setRotationPoint(-4.0F, -3.0F, -1.0F); + this.armRbranch1.addCuboid(-1.0F, -1.0F, 0.0F, 2, 2, 7, s); + this.setRotateAngle(armRbranch1, 0.5235987755982988F, -0.5235987755982988F, 0.0F); + this.armRbranch2 = new ModelRenderer(this, 36, 24); + this.armRbranch2.setRotationPoint(-5.0F, -2.0F, 0.0F); + this.armRbranch2.addCuboid(-1.0F, 0.0F, 0.0F, 2, 2, 5, s); + this.setRotateAngle(armRbranch2, 0.08726646259971647F, -0.7853981633974483F, 0.0F); + + //pants + this.pantsAnchor = new ModelRenderer(this, 0, 0); + this.pantsAnchor.setRotationPoint(0.0F, 0.0F, 0.0F); + this.pantsAnchor.addCuboid(-1.0F, 0.0F, -1.0F, 2, 2, 2, s); + this.belt = new ModelRenderer(this, 0, 65); + this.belt.setRotationPoint(0.0F, 0.0F, 0.0F); + this.belt.addCuboid(-4.5F, 8.0F, -3.0F, 9, 5, 6, s); this.legL = new ModelRenderer(this, 0, 76); - this.legL.mirror = true; - this.legL.setRotationPoint(1.9F, 12.0F, 0.0F); - this.legL.addCuboid(-2.39F, -0.01F, -2.49F, 5, 6, 5, s); + this.legL.mirror = true; + this.legL.setRotationPoint(1.9F, 12.0F, 0.0F); + this.legL.addCuboid(-2.39F, -0.01F, -2.49F, 5, 6, 5, s); this.legR = new ModelRenderer(this, 0, 76); - this.legR.setRotationPoint(-1.9F, 12.0F, 0.0F); - this.legR.addCuboid(-2.61F, -0.01F, -2.51F, 5, 6, 5, s); - - //boots - this.bootL = new ModelRenderer(this, 0, 94); - this.bootL.mirror = true; - this.bootL.setRotationPoint(1.9F, 12.0F, 0.0F); - this.bootL.addCuboid(-2.39F, 8.5F, -2.49F, 5, 4, 5, s); - this.bootLtop = new ModelRenderer(this, 0, 87); - this.bootLtop.mirror = true; - this.bootLtop.setRotationPoint(0.0F, 0.0F, 0.0F); - this.bootLtop.addCuboid(-2.39F, 6.0F, -2.49F, 6, 2, 5, s); - this.bootLbranch1 = new ModelRenderer(this, 36, 15); - this.bootLbranch1.mirror = true; - this.bootLbranch1.setRotationPoint(3.5F, 6.0F, 0.0F); - this.bootLbranch1.addCuboid(-1.0F, -1.0F, 0.0F, 2, 2, 7,s); - this.setRotateAngle(bootLbranch1, 0.2617993877991494F, 0.2617993877991494F, -0.08726646259971647F); - this.bootLbranch2 = new ModelRenderer(this, 36, 24); - this.bootLbranch2.mirror = true; - this.bootLbranch2.setRotationPoint(2.5F, 9.0F, 0.0F); - this.bootLbranch2.addCuboid(-1.0F, -1.0F, 0.0F, 2, 2, 5, s); - this.setRotateAngle(bootLbranch2, 0.08726646259971647F, 0.7853981633974483F, 0.0F); - this.bootR = new ModelRenderer(this, 0, 94); - this.bootR.setRotationPoint(-1.9F, 12.0F, 0.0F); - this.bootR.addCuboid(-2.61F, 8.5F, -2.51F, 5, 4, 5, s); + this.legR.setRotationPoint(-1.9F, 12.0F, 0.0F); + this.legR.addCuboid(-2.61F, -0.01F, -2.51F, 5, 6, 5, s); + + //boots + this.bootL = new ModelRenderer(this, 0, 94); + this.bootL.mirror = true; + this.bootL.setRotationPoint(1.9F, 12.0F, 0.0F); + this.bootL.addCuboid(-2.39F, 8.5F, -2.49F, 5, 4, 5, s); + this.bootLtop = new ModelRenderer(this, 0, 87); + this.bootLtop.mirror = true; + this.bootLtop.setRotationPoint(0.0F, 0.0F, 0.0F); + this.bootLtop.addCuboid(-2.39F, 6.0F, -2.49F, 6, 2, 5, s); + this.bootLbranch1 = new ModelRenderer(this, 36, 15); + this.bootLbranch1.mirror = true; + this.bootLbranch1.setRotationPoint(3.5F, 6.0F, 0.0F); + this.bootLbranch1.addCuboid(-1.0F, -1.0F, 0.0F, 2, 2, 7, s); + this.setRotateAngle(bootLbranch1, 0.2617993877991494F, 0.2617993877991494F, -0.08726646259971647F); + this.bootLbranch2 = new ModelRenderer(this, 36, 24); + this.bootLbranch2.mirror = true; + this.bootLbranch2.setRotationPoint(2.5F, 9.0F, 0.0F); + this.bootLbranch2.addCuboid(-1.0F, -1.0F, 0.0F, 2, 2, 5, s); + this.setRotateAngle(bootLbranch2, 0.08726646259971647F, 0.7853981633974483F, 0.0F); + this.bootR = new ModelRenderer(this, 0, 94); + this.bootR.setRotationPoint(-1.9F, 12.0F, 0.0F); + this.bootR.addCuboid(-2.61F, 8.5F, -2.51F, 5, 4, 5, s); this.bootRtop = new ModelRenderer(this, 0, 87); - this.bootRtop.setRotationPoint(0.0F, 0.0F, 0.0F); - this.bootRtop.addCuboid(-3.61F, 6.0F, -2.51F, 6, 2, 5, s); - this.bootRbranch1 = new ModelRenderer(this, 36, 15); - this.bootRbranch1.setRotationPoint(-3.5F, 6.0F, 0.0F); - this.bootRbranch1.addCuboid(-1.0F, -1.0F, 0.0F, 2, 2, 7, s); - this.setRotateAngle(bootRbranch1, 0.2617993877991494F, -0.2617993877991494F, 0.08726646259971647F); - this.bootRbranch2 = new ModelRenderer(this, 36, 24); - this.bootRbranch2.setRotationPoint(-2.5F, 9.0F, 0.5F); - this.bootRbranch2.addCuboid(-1.0F, -1.0F, 0.0F, 2, 2, 5, s); - this.setRotateAngle(bootRbranch2, 0.08726646259971647F, -0.7853981633974483F, 0.0F); - - //hierarchy - this.helmAnchor.addChild(this.helm); - this.helm.addChild(this.helmFront); - this.helm.addChild(this.helmLeaf1l); - this.helm.addChild(this.helmLeaf2l); - this.helm.addChild(this.helmLeaf3l); - this.helm.addChild(this.helmLeaf1r); - this.helm.addChild(this.helmLeaf2r); - this.helm.addChild(this.helmLeaf3r); - this.helm.addChild(this.helmbranch1l); - this.helm.addChild(this.helmbranch2l); - this.helm.addChild(this.helmbranch1r); - this.helm.addChild(this.helmbranch2r); - - this.bodyAnchor.addChild(this.bodyTop); - this.bodyTop.addChild(this.bodyBottom); - this.armLAnchor.addChild(this.armL); - this.armL.addChild(this.armLpauldron); - this.armLpauldron.addChild(this.armLbranch1); - this.armLpauldron.addChild(this.armLbranch2); - this.armRAnchor.addChild(this.armR); - this.armR.addChild(this.armRpauldron); - this.armRpauldron.addChild(this.armRbranch1); - this.armRpauldron.addChild(this.armRbranch2); - - this.pantsAnchor.addChild(this.belt); - this.belt.addChild(this.legL); - this.belt.addChild(this.legR); - - this.bootL.addChild(bootLtop); - this.bootLtop.addChild(bootLbranch1); - this.bootLtop.addChild(bootLbranch2); - this.bootR.addChild(bootRtop); - this.bootRtop.addChild(bootRbranch1); - this.bootRtop.addChild(bootRbranch2); + this.bootRtop.setRotationPoint(0.0F, 0.0F, 0.0F); + this.bootRtop.addCuboid(-3.61F, 6.0F, -2.51F, 6, 2, 5, s); + this.bootRbranch1 = new ModelRenderer(this, 36, 15); + this.bootRbranch1.setRotationPoint(-3.5F, 6.0F, 0.0F); + this.bootRbranch1.addCuboid(-1.0F, -1.0F, 0.0F, 2, 2, 7, s); + this.setRotateAngle(bootRbranch1, 0.2617993877991494F, -0.2617993877991494F, 0.08726646259971647F); + this.bootRbranch2 = new ModelRenderer(this, 36, 24); + this.bootRbranch2.setRotationPoint(-2.5F, 9.0F, 0.5F); + this.bootRbranch2.addCuboid(-1.0F, -1.0F, 0.0F, 2, 2, 5, s); + this.setRotateAngle(bootRbranch2, 0.08726646259971647F, -0.7853981633974483F, 0.0F); + + //hierarchy + this.helmAnchor.addChild(this.helm); + this.helm.addChild(this.helmFront); + this.helm.addChild(this.helmLeaf1l); + this.helm.addChild(this.helmLeaf2l); + this.helm.addChild(this.helmLeaf3l); + this.helm.addChild(this.helmLeaf1r); + this.helm.addChild(this.helmLeaf2r); + this.helm.addChild(this.helmLeaf3r); + this.helm.addChild(this.helmbranch1l); + this.helm.addChild(this.helmbranch2l); + this.helm.addChild(this.helmbranch1r); + this.helm.addChild(this.helmbranch2r); + + this.bodyAnchor.addChild(this.bodyTop); + this.bodyTop.addChild(this.bodyBottom); + this.armLAnchor.addChild(this.armL); + this.armL.addChild(this.armLpauldron); + this.armLpauldron.addChild(this.armLbranch1); + this.armLpauldron.addChild(this.armLbranch2); + this.armRAnchor.addChild(this.armR); + this.armR.addChild(this.armRpauldron); + this.armRpauldron.addChild(this.armRbranch1); + this.armRpauldron.addChild(this.armRbranch2); + + this.pantsAnchor.addChild(this.belt); + this.belt.addChild(this.legL); + this.belt.addChild(this.legR); + + this.bootL.addChild(bootLtop); + this.bootLtop.addChild(bootLbranch1); + this.bootLtop.addChild(bootLbranch2); + this.bootR.addChild(bootRtop); + this.bootRtop.addChild(bootRbranch1); + this.bootRtop.addChild(bootRbranch2); } @Override @@ -281,14 +276,14 @@ public class ModelArmorTerrasteel extends ModelArmor { legL.showModel = slot == EquipmentSlotType.LEGS; bootL.showModel = slot == EquipmentSlotType.FEET; bootR.showModel = slot == EquipmentSlotType.FEET; - + bipedHeadwear.showModel = false; bipedHead = helmAnchor; bipedBody = bodyAnchor; bipedRightArm = armRAnchor; bipedLeftArm = armLAnchor; - if(slot == EquipmentSlotType.LEGS) { + if (slot == EquipmentSlotType.LEGS) { bipedBody = pantsAnchor; bipedRightLeg = legR; bipedLeftLeg = legL; diff --git a/src/main/java/vazkii/botania/client/patchouli/PatchouliUtils.java b/src/main/java/vazkii/botania/client/patchouli/PatchouliUtils.java index dafb1c90f..b2c9084db 100644 --- a/src/main/java/vazkii/botania/client/patchouli/PatchouliUtils.java +++ b/src/main/java/vazkii/botania/client/patchouli/PatchouliUtils.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 2019, 3:04 PM (GMT)] */ package vazkii.botania.client.patchouli; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; + import vazkii.patchouli.api.PatchouliAPI; import java.util.ArrayList; @@ -25,27 +24,27 @@ public class PatchouliUtils { * looping back ingredients that run out of matched stacks, until the ingredients reach the length * of the longest ingredient in the recipe set. * - * @param ingredients List of ingredients in the specific slot - * @param longestIngredientSize Longest ingredient in the entire recipe - * @return Serialized Patchouli ingredient string + * @param ingredients List of ingredients in the specific slot + * @param longestIngredientSize Longest ingredient in the entire recipe + * @return Serialized Patchouli ingredient string */ public static String interweaveIngredients(List ingredients, int longestIngredientSize) { - if(ingredients.size() == 1) { + if (ingredients.size() == 1) { return PatchouliAPI.instance.serializeIngredient(ingredients.get(0)); } - ItemStack[] empty = {ItemStack.EMPTY}; + ItemStack[] empty = { ItemStack.EMPTY }; List stacks = new ArrayList<>(); - for(Ingredient ingredient : ingredients) { - if(ingredient != null && !ingredient.hasNoMatchingItems()) { + for (Ingredient ingredient : ingredients) { + if (ingredient != null && !ingredient.hasNoMatchingItems()) { stacks.add(ingredient.getMatchingStacks()); } else { stacks.add(empty); } } StringJoiner joiner = new StringJoiner(","); - for(int i = 0; i < longestIngredientSize; i++) { - for(ItemStack[] stack : stacks) { + for (int i = 0; i < longestIngredientSize; i++) { + for (ItemStack[] stack : stacks) { joiner.add(PatchouliAPI.instance.serializeItemStack(stack[i % stack.length])); } } diff --git a/src/main/java/vazkii/botania/client/patchouli/component/ManaComponent.java b/src/main/java/vazkii/botania/client/patchouli/component/ManaComponent.java index 9dcc09b55..22f5ade65 100644 --- a/src/main/java/vazkii/botania/client/patchouli/component/ManaComponent.java +++ b/src/main/java/vazkii/botania/client/patchouli/component/ManaComponent.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 08 2019, 10:31 PM (GMT)] */ package vazkii.botania.client.patchouli.component; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.resources.I18n; + import vazkii.botania.client.core.handler.HUDHandler; import vazkii.botania.common.block.tile.mana.TilePool; import vazkii.patchouli.api.IComponentRenderContext; @@ -35,10 +34,10 @@ public class ManaComponent implements ICustomComponent { public void build(int componentX, int componentY, int pageNum) { this.x = componentX != -1 ? componentX : 7; this.y = componentY; - if(mana.length() > 0) { + if (mana.length() > 0) { this.manaValues = Arrays.stream(mana.split(";")).mapToInt(Integer::valueOf).toArray(); } else { - this.manaValues = new int[]{0}; + this.manaValues = new int[] { 0 }; } } @@ -50,10 +49,10 @@ public class ManaComponent implements ICustomComponent { font.drawString(manaUsage, x + 102 / 2 - font.getStringWidth(manaUsage) / 2, y, 0x66000000); int ratio = 10; - if(context.isAreaHovered(mouseX, mouseY, x, y - 2, 102, 5 + 20)) { + if (context.isAreaHovered(mouseX, mouseY, x, y - 2, 102, 5 + 20)) { ratio = 1; } - HUDHandler.renderManaBar(x, y + 10, 0x0000FF, 0.75F, + HUDHandler.renderManaBar(x, y + 10, 0x0000FF, 0.75F, manaValues[(context.getTicksInBook() / 20) % manaValues.length], TilePool.MAX_MANA / ratio); String ratioString = I18n.format("botaniamisc.ratio", ratio); diff --git a/src/main/java/vazkii/botania/client/patchouli/component/RotatingItemListComponent.java b/src/main/java/vazkii/botania/client/patchouli/component/RotatingItemListComponent.java index 4c883458a..052a627ab 100644 --- a/src/main/java/vazkii/botania/client/patchouli/component/RotatingItemListComponent.java +++ b/src/main/java/vazkii/botania/client/patchouli/component/RotatingItemListComponent.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 20 2019, 8:49 PM (GMT)] */ package vazkii.botania.client.patchouli.component; import net.minecraft.item.crafting.Ingredient; + import vazkii.patchouli.api.PatchouliAPI; import java.util.List; diff --git a/src/main/java/vazkii/botania/client/patchouli/component/RotatingItemListComponentBase.java b/src/main/java/vazkii/botania/client/patchouli/component/RotatingItemListComponentBase.java index 4b590a63d..35b9462fc 100644 --- a/src/main/java/vazkii/botania/client/patchouli/component/RotatingItemListComponentBase.java +++ b/src/main/java/vazkii/botania/client/patchouli/component/RotatingItemListComponentBase.java @@ -1,19 +1,18 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 20 2019, 2:59 PM (GMT)] */ package vazkii.botania.client.patchouli.component; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.client.gui.screen.Screen; import net.minecraft.item.crafting.Ingredient; + import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.patchouli.api.IComponentRenderContext; import vazkii.patchouli.api.ICustomComponent; @@ -46,11 +45,11 @@ abstract class RotatingItemListComponentBase implements ICustomComponent { float currentDegree = ConfigHandler.CLIENT.lexiconRotatingItems.get() ? Screen.hasShiftDown() - ? ticksElapsed - : ticksElapsed + pticks + ? ticksElapsed + : ticksElapsed + pticks : 0; - for(Ingredient input : ingredients) { + for (Ingredient input : ingredients) { renderIngredientAtAngle(context, currentDegree, input, mouseX, mouseY); currentDegree += degreePerInput; @@ -58,8 +57,9 @@ abstract class RotatingItemListComponentBase implements ICustomComponent { } private void renderIngredientAtAngle(IComponentRenderContext context, float angle, Ingredient ingredient, int mouseX, int mouseY) { - if(ingredient.hasNoMatchingItems()) + if (ingredient.hasNoMatchingItems()) { return; + } angle -= 90; int radius = 32; diff --git a/src/main/java/vazkii/botania/client/patchouli/component/RotatingRecipeComponent.java b/src/main/java/vazkii/botania/client/patchouli/component/RotatingRecipeComponent.java index 96011e976..3278ec769 100644 --- a/src/main/java/vazkii/botania/client/patchouli/component/RotatingRecipeComponent.java +++ b/src/main/java/vazkii/botania/client/patchouli/component/RotatingRecipeComponent.java @@ -1,18 +1,18 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 20 2019, 8:49 PM (GMT)] */ package vazkii.botania.client.patchouli.component; import com.google.gson.annotations.SerializedName; + import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.ResourceLocation; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.IModRecipe; @@ -24,18 +24,16 @@ import java.util.function.Function; * Patchouli custom component that draws a rotating circle of items from the defined recipe. */ public class RotatingRecipeComponent extends RotatingItemListComponentBase { - @SerializedName("recipe_name") - public String recipeName; + @SerializedName("recipe_name") public String recipeName; - @SerializedName("recipe_type") - public String recipeType; + @SerializedName("recipe_type") public String recipeType; @Override protected List makeIngredients() { Map map; - if("runic_altar".equals(recipeType)) { + if ("runic_altar".equals(recipeType)) { map = BotaniaAPI.runeAltarRecipes; - } else if("petal_apothecary".equals(recipeType)) { + } else if ("petal_apothecary".equals(recipeType)) { map = BotaniaAPI.petalRecipes; } else { throw new IllegalArgumentException("Type must be 'runic_altar' or 'petal_apothecary'!"); diff --git a/src/main/java/vazkii/botania/client/patchouli/component/TerraPlateComponent.java b/src/main/java/vazkii/botania/client/patchouli/component/TerraPlateComponent.java index 8188ca3cc..ad3efc40f 100644 --- a/src/main/java/vazkii/botania/client/patchouli/component/TerraPlateComponent.java +++ b/src/main/java/vazkii/botania/client/patchouli/component/TerraPlateComponent.java @@ -1,18 +1,17 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 24 2019, 2:31 PM (GMT)] */ package vazkii.botania.client.patchouli.component; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.item.ItemStack; + import vazkii.patchouli.api.IComponentRenderContext; import vazkii.patchouli.api.ICustomComponent; import vazkii.patchouli.api.PatchouliAPI; diff --git a/src/main/java/vazkii/botania/client/patchouli/processor/BrewRecipeProcessor.java b/src/main/java/vazkii/botania/client/patchouli/processor/BrewRecipeProcessor.java index 24a286b7f..a738ba247 100644 --- a/src/main/java/vazkii/botania/client/patchouli/processor/BrewRecipeProcessor.java +++ b/src/main/java/vazkii/botania/client/patchouli/processor/BrewRecipeProcessor.java @@ -1,18 +1,17 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 22 2019, 7:03 PM (GMT)] */ package vazkii.botania.client.patchouli.processor; import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipeBrew; import vazkii.botania.common.item.ModItems; @@ -30,24 +29,25 @@ public class BrewRecipeProcessor implements IComponentProcessor { @Override public String process(String key) { - if(recipe == null) { + if (recipe == null) { return null; - } else if(key.equals("heading")) { + } else if (key.equals("heading")) { return I18n.format("botaniamisc.brewOf", I18n.format(recipe.getBrew().getUnlocalizedName())); - } else if(key.equals("vial")) { + } else if (key.equals("vial")) { return PatchouliAPI.instance.serializeItemStack(recipe.getOutput(new ItemStack(ModItems.vial))); - } else if(key.equals("flask")) { + } else if (key.equals("flask")) { return PatchouliAPI.instance.serializeItemStack(recipe.getOutput(new ItemStack(ModItems.flask))); - } else if(key.startsWith("input")) { + } else if (key.startsWith("input")) { int requestedIndex = Integer.parseInt(key.substring(5)) - 1; int indexOffset = (6 - recipe.getInputs().size()) / 2; //Center the brew ingredients int index = requestedIndex - indexOffset; - - if(index < recipe.getInputs().size() && index >= 0) + + if (index < recipe.getInputs().size() && index >= 0) { return PatchouliAPI.instance.serializeIngredient(recipe.getInputs().get(index)); - else + } else { return null; - } else if(key.equals("is_offset")) { + } + } else if (key.equals("is_offset")) { return Boolean.toString(recipe.getInputs().size() % 2 == 0); } return null; diff --git a/src/main/java/vazkii/botania/client/patchouli/processor/ElvenTradeProcessor.java b/src/main/java/vazkii/botania/client/patchouli/processor/ElvenTradeProcessor.java index ee9ff20d2..03e66aa89 100644 --- a/src/main/java/vazkii/botania/client/patchouli/processor/ElvenTradeProcessor.java +++ b/src/main/java/vazkii/botania/client/patchouli/processor/ElvenTradeProcessor.java @@ -1,19 +1,19 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 09 2019, 10:20 PM (GMT)] */ package vazkii.botania.client.patchouli.processor; import com.google.common.collect.ImmutableList; + import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.ResourceLocation; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipeElvenTrade; import vazkii.botania.client.patchouli.PatchouliUtils; @@ -31,25 +31,25 @@ public class ElvenTradeProcessor implements IComponentProcessor { @Override public void setup(IVariableProvider variables) { ImmutableList.Builder builder = ImmutableList.builder(); - for(String s : variables.get("recipes").split(";")) { + for (String s : variables.get("recipes").split(";")) { RecipeElvenTrade recipeElvenTrade = BotaniaAPI.elvenTradeRecipes.get(new ResourceLocation(s)); - if(recipeElvenTrade != null) { + if (recipeElvenTrade != null) { builder.add(recipeElvenTrade); } } recipes = builder.build(); - for(RecipeElvenTrade recipe : recipes) { + for (RecipeElvenTrade recipe : recipes) { List inputs = recipe.getInputs(); - for(Ingredient ingredient : inputs) { + for (Ingredient ingredient : inputs) { int length = ingredient.getMatchingStacks().length; - if(length > longestIngredientSize) { + if (length > longestIngredientSize) { longestIngredientSize = length; } } - if(inputs.size() > mostInputs) { + if (inputs.size() > mostInputs) { mostInputs = inputs.size(); } - if(recipe.getOutputs().size() > mostOutputs) { + if (recipe.getOutputs().size() > mostOutputs) { mostOutputs = recipe.getOutputs().size(); } } @@ -57,35 +57,39 @@ public class ElvenTradeProcessor implements IComponentProcessor { @Override public String process(String key) { - if(recipes.isEmpty()) { + if (recipes.isEmpty()) { return null; } - if(key.equals("heading")) { + if (key.equals("heading")) { return recipes.get(0).getOutputs().get(0).getDisplayName().getString(); - } else if(key.startsWith("input")) { + } else if (key.startsWith("input")) { int index = Integer.parseInt(key.substring(5)) - 1; - if(index < mostInputs) + if (index < mostInputs) { return interweaveIngredients(index); - else + } else { return null; - } - if(key.startsWith("output")) { + } + } + if (key.startsWith("output")) { int index = Integer.parseInt(key.substring(6)) - 1; - if(index < mostOutputs) + if (index < mostOutputs) { return recipes.stream().map(RecipeElvenTrade::getOutputs) .map(l -> index < l.size() ? l.get(index) : ItemStack.EMPTY) .map(PatchouliAPI.instance::serializeItemStack).collect(Collectors.joining(",")); - else + } else { return null; + } } return null; } private String interweaveIngredients(int inputIndex) { List recipes = this.recipes.stream().map(RecipeElvenTrade::getInputs).map(ingredients -> { - if(inputIndex < ingredients.size()) { + if (inputIndex < ingredients.size()) { return ingredients.get(inputIndex); - } else return Ingredient.EMPTY; + } else { + return Ingredient.EMPTY; + } }).collect(Collectors.toList()); return PatchouliUtils.interweaveIngredients(recipes, longestIngredientSize); } diff --git a/src/main/java/vazkii/botania/client/patchouli/processor/ManaInfusionProcessor.java b/src/main/java/vazkii/botania/client/patchouli/processor/ManaInfusionProcessor.java index e8b0de3ec..6979c8099 100644 --- a/src/main/java/vazkii/botania/client/patchouli/processor/ManaInfusionProcessor.java +++ b/src/main/java/vazkii/botania/client/patchouli/processor/ManaInfusionProcessor.java @@ -1,20 +1,20 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 09 2019, 9:34 PM (GMT)] */ package vazkii.botania.client.patchouli.processor; import com.google.common.collect.ImmutableList; + import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.TextFormatting; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipeManaInfusion; import vazkii.botania.client.core.helper.RenderHelper; @@ -44,9 +44,9 @@ public class ManaInfusionProcessor implements IComponentProcessor { .filter(r -> r.getGroup().equals(group)) .forEach(builder::add); } else { - for(String s : variables.get("recipes").split(";")) { + for (String s : variables.get("recipes").split(";")) { RecipeManaInfusion recipe = BotaniaAPI.manaInfusionRecipes.get(new ResourceLocation(s)); - if(recipe != null) { + if (recipe != null) { builder.add(recipe); } else { Botania.LOGGER.warn("Mana infusion template references nonexistent recipe {}", s); @@ -60,13 +60,14 @@ public class ManaInfusionProcessor implements IComponentProcessor { @Override public String process(String key) { - if(recipes.isEmpty()) { + if (recipes.isEmpty()) { return null; } switch (key) { case "heading": - if(!hasCustomHeading) + if (!hasCustomHeading) { return recipes.get(0).getOutput().getDisplayName().getString(); + } return null; case "input": return PatchouliUtils.interweaveIngredients(recipes.stream().map(RecipeManaInfusion::getInput).collect(Collectors.toList())); @@ -75,8 +76,9 @@ public class ManaInfusionProcessor implements IComponentProcessor { case "catalyst": return recipes.stream().map(RecipeManaInfusion::getCatalyst) .map(state -> { - if(state == null) + if (state == null) { return ItemStack.EMPTY; + } return new ItemStack(state.getBlock().asItem()); }) .map(PatchouliAPI.instance::serializeItemStack) @@ -87,10 +89,9 @@ public class ManaInfusionProcessor implements IComponentProcessor { return I18n.format("botaniamisc.drop") + TextFormatting.BOLD + " (?)"; case "dropTip0": case "dropTip1": - return I18n.format("botaniamisc.dropTip" + key.substring(7), + return I18n.format("botaniamisc.dropTip" + key.substring(7), TextFormatting.GREEN + RenderHelper.getKeyDisplayString("key.drop") + TextFormatting.WHITE); } return null; } } - diff --git a/src/main/java/vazkii/botania/client/patchouli/processor/MultiCraftingProcessor.java b/src/main/java/vazkii/botania/client/patchouli/processor/MultiCraftingProcessor.java index fd4b45c11..66cc7814b 100644 --- a/src/main/java/vazkii/botania/client/patchouli/processor/MultiCraftingProcessor.java +++ b/src/main/java/vazkii/botania/client/patchouli/processor/MultiCraftingProcessor.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 24 2019, 6:55 PM (GMT)] */ package vazkii.botania.client.patchouli.processor; @@ -19,6 +17,7 @@ import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.crafting.IShapedRecipe; + import vazkii.botania.client.patchouli.PatchouliUtils; import vazkii.patchouli.api.IComponentProcessor; import vazkii.patchouli.api.IVariableProvider; @@ -40,16 +39,16 @@ public class MultiCraftingProcessor implements IComponentProcessor { Map> recipeMap = Minecraft.getInstance().world.getRecipeManager().getRecipes(IRecipeType.CRAFTING); String[] names = variables.get("recipes").split(";"); this.recipes = new ArrayList<>(); - for(String name : names) { + for (String name : names) { IRecipe recipe = recipeMap.get(new ResourceLocation(name)); - if(recipe != null) { + if (recipe != null) { recipes.add((ICraftingRecipe) recipe); - if(shapeless) { + if (shapeless) { shapeless = !(recipe instanceof IShapedRecipe); } - for(Ingredient ingredient : recipe.getIngredients()) { + for (Ingredient ingredient : recipe.getIngredients()) { int size = ingredient.getMatchingStacks().length; - if(longestIngredientSize < size) { + if (longestIngredientSize < size) { longestIngredientSize = size; } } @@ -60,23 +59,24 @@ public class MultiCraftingProcessor implements IComponentProcessor { @Override public String process(String key) { - if(recipes.isEmpty()) { + if (recipes.isEmpty()) { return null; } - if(key.equals("heading")) { - if(!hasCustomHeading) + if (key.equals("heading")) { + if (!hasCustomHeading) { return recipes.get(0).getRecipeOutput().getDisplayName().getString(); + } return null; } - if(key.startsWith("input")) { + if (key.startsWith("input")) { int index = Integer.parseInt(key.substring(5)) - 1; int shapedX = index % 3; int shapedY = index / 3; List ingredients = new ArrayList<>(); - for(ICraftingRecipe recipe : recipes) { - if(recipe instanceof IShapedRecipe) { + for (ICraftingRecipe recipe : recipes) { + if (recipe instanceof IShapedRecipe) { IShapedRecipe shaped = (IShapedRecipe) recipe; - if(shaped.getRecipeWidth() < shapedX + 1) { + if (shaped.getRecipeWidth() < shapedX + 1) { ingredients.add(Ingredient.EMPTY); } else { int realIndex = index - (shapedY * (3 - shaped.getRecipeWidth())); @@ -91,11 +91,10 @@ public class MultiCraftingProcessor implements IComponentProcessor { } return PatchouliUtils.interweaveIngredients(ingredients, longestIngredientSize); } - if(key.equals("output")) { + if (key.equals("output")) { return recipes.stream().map(IRecipe::getRecipeOutput).map(PatchouliAPI.instance::serializeItemStack).collect(Collectors.joining(",")); } - if(key.equals("shapeless")) { - } + if (key.equals("shapeless")) {} return null; } } diff --git a/src/main/java/vazkii/botania/client/patchouli/processor/PetalApothecaryProcessor.java b/src/main/java/vazkii/botania/client/patchouli/processor/PetalApothecaryProcessor.java index 632a650af..154c6b34a 100644 --- a/src/main/java/vazkii/botania/client/patchouli/processor/PetalApothecaryProcessor.java +++ b/src/main/java/vazkii/botania/client/patchouli/processor/PetalApothecaryProcessor.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 10 2019, 9:32 PM (GMT)] */ package vazkii.botania.client.patchouli.processor; import net.minecraft.util.ResourceLocation; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.IModRecipe; import vazkii.patchouli.api.IComponentProcessor; @@ -27,7 +26,7 @@ public class PetalApothecaryProcessor implements IComponentProcessor { @Override public String process(String key) { - if(recipe == null) { + if (recipe == null) { return null; } switch (key) { diff --git a/src/main/java/vazkii/botania/client/patchouli/processor/RunicAltarProcessor.java b/src/main/java/vazkii/botania/client/patchouli/processor/RunicAltarProcessor.java index 345722d37..9a8f238d7 100644 --- a/src/main/java/vazkii/botania/client/patchouli/processor/RunicAltarProcessor.java +++ b/src/main/java/vazkii/botania/client/patchouli/processor/RunicAltarProcessor.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 10 2019, 9:52 AM (GMT)] */ package vazkii.botania.client.patchouli.processor; import net.minecraft.util.ResourceLocation; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipeRuneAltar; import vazkii.patchouli.api.IVariableProvider; @@ -23,8 +22,9 @@ public class RunicAltarProcessor extends PetalApothecaryProcessor { @Override public String process(String key) { - if(key.equals("mana")) + if (key.equals("mana")) { return String.valueOf(((RecipeRuneAltar) recipe).getManaUsage()); + } return super.process(key); } } diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderBabylonWeapon.java b/src/main/java/vazkii/botania/client/render/entity/RenderBabylonWeapon.java index 9bb083077..68c7e19bc 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderBabylonWeapon.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderBabylonWeapon.java @@ -1,42 +1,34 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 16, 2015, 6:42:09 PM (GMT)] */ package vazkii.botania.client.render.entity; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GLX; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Atlases; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.Matrix4f; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRendererManager; import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.MiscellaneousIcons; -import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.client.core.helper.RenderHelper; -import vazkii.botania.client.core.helper.ShaderHelper; -import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.entity.EntityBabylonWeapon; import javax.annotation.Nonnull; + import java.util.Random; public class RenderBabylonWeapon extends EntityRenderer { @@ -73,8 +65,9 @@ public class RenderBabylonWeapon extends EntityRenderer { ms.translate(0F, -0.3F + rand.nextFloat() * 0.1F, 1F); s = chargeMul; - if(live > delay) + if (live > delay) { s -= Math.min(1F, (live - delay + partialTicks) * 0.2F); + } s *= 2F; ms.scale(s, s, s); diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderCorporeaSpark.java b/src/main/java/vazkii/botania/client/render/entity/RenderCorporeaSpark.java index 2b99e7d7c..e8bd97fbe 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderCorporeaSpark.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderCorporeaSpark.java @@ -1,28 +1,23 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 14, 2015, 1:04:34 AM (GMT)] */ package vazkii.botania.client.render.entity; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.entity.EntityRendererManager; -import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.item.ItemStack; -import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.MiscellaneousIcons; -import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.entity.EntityCorporeaSpark; public class RenderCorporeaSpark extends RenderSparkBase { @@ -39,14 +34,16 @@ public class RenderCorporeaSpark extends RenderSparkBase { @Override public void renderCallback(EntityCorporeaSpark entity, float pticks, MatrixStack ms, IRenderTypeBuffer buffers) { int time = entity.getItemDisplayTicks(); - if(time == 0) + if (time == 0) { return; + } float absTime = Math.abs(time) - pticks; ItemStack stack = entity.getDisplayedItem(); - if(stack.isEmpty()) + if (stack.isEmpty()) { return; + } ms.push(); ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(90)); @@ -57,7 +54,7 @@ public class RenderCorporeaSpark extends RenderSparkBase { TextureAtlasSprite icon = Minecraft.getInstance().getItemRenderer().getItemModelWithOverrides(stack, entity.world, null).getParticleTexture(); - if(icon != null) { + if (icon != null) { float minU = icon.getMinU(); float maxU = icon.getMaxU(); float minV = icon.getMinV(); @@ -71,9 +68,9 @@ public class RenderCorporeaSpark extends RenderSparkBase { float scale = 1F / pieces * 3F; ms.scale(scale, scale, 1F); - for(int i = -shift; i < shift; i++) { + for (int i = -shift; i < shift; i++) { ms.translate(gap * i, 0F, 0F); - for(int j = -shift; j < shift; j++) { + for (int j = -shift; j < shift; j++) { ms.translate(0F, gap * j, 0F); // todo 1.15 do this another way IconHelper.renderIconIn3D(Tessellator.getInstance(), minU + stepU * (i + shift), minV + stepV * (j + shift + 1), minU + stepU * (i + shift + 1), minV + stepV * (j + shift), icon.getWidth() / pieces, icon.getHeight() / pieces, 1F / 8F); ms.translate(0F, -gap * j, 0F); diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderDoppleganger.java b/src/main/java/vazkii/botania/client/render/entity/RenderDoppleganger.java index 4e0cba82c..03499cca9 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderDoppleganger.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderDoppleganger.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 12, 2014, 4:07:26 PM (GMT)] */ package vazkii.botania.client.render.entity; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.platform.GlStateManager; + import net.minecraft.client.Minecraft; import net.minecraft.client.entity.player.AbstractClientPlayerEntity; import net.minecraft.client.renderer.IRenderTypeBuffer; @@ -19,9 +18,9 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.entity.BipedRenderer; import net.minecraft.client.renderer.entity.EntityRendererManager; import net.minecraft.client.renderer.entity.model.BipedModel; -import net.minecraft.client.renderer.entity.model.PlayerModel; import net.minecraft.client.resources.DefaultPlayerSkin; import net.minecraft.util.ResourceLocation; + import vazkii.botania.api.internal.ShaderCallback; import vazkii.botania.client.core.helper.ShaderHelper; import vazkii.botania.client.core.helper.ShaderWrappedRenderLayer; @@ -72,7 +71,7 @@ public class RenderDoppleganger extends BipedRenderer 0) { + if (invulTime > 0) { grainIntensity = invulTime > 20 ? 1F : invulTime * 0.05F; disfiguration = grainIntensity * 0.3F; } else { @@ -88,8 +87,9 @@ public class RenderDoppleganger extends BipedRenderer. It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 25, 2015, 2:32:31 AM (GMT)] */ package vazkii.botania.client.render.entity; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; + import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRendererManager; import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.util.ResourceLocation; + import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.common.entity.EntityManaStorm; diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderNoop.java b/src/main/java/vazkii/botania/client/render/entity/RenderNoop.java index ba8973f70..2b72581af 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderNoop.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderNoop.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.client.render.entity; import net.minecraft.client.renderer.culling.ClippingHelperImpl; @@ -10,18 +18,18 @@ import net.minecraft.util.ResourceLocation; import javax.annotation.Nonnull; public class RenderNoop extends EntityRenderer { - public RenderNoop(EntityRendererManager manager) { - super(manager); - } + public RenderNoop(EntityRendererManager manager) { + super(manager); + } - @Override - public boolean shouldRender(T entity, @Nonnull ClippingHelperImpl clipping, double x, double y, double z) { - return false; - } + @Override + public boolean shouldRender(T entity, @Nonnull ClippingHelperImpl clipping, double x, double y, double z) { + return false; + } - @Nonnull - @Override - public ResourceLocation getEntityTexture(@Nonnull T entity) { - return AtlasTexture.LOCATION_BLOCKS_TEXTURE; - } + @Nonnull + @Override + public ResourceLocation getEntityTexture(@Nonnull T entity) { + return AtlasTexture.LOCATION_BLOCKS_TEXTURE; + } } diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderPinkWither.java b/src/main/java/vazkii/botania/client/render/entity/RenderPinkWither.java index c66ac5c99..1d6813556 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderPinkWither.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderPinkWither.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 25, 2015, 5:55:59 PM (GMT)] */ package vazkii.botania.client.render.entity; @@ -14,6 +12,7 @@ import net.minecraft.client.renderer.entity.EntityRendererManager; import net.minecraft.client.renderer.entity.WitherRenderer; import net.minecraft.entity.boss.WitherEntity; import net.minecraft.util.ResourceLocation; + import vazkii.botania.client.lib.LibResources; import javax.annotation.Nonnull; diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderPixie.java b/src/main/java/vazkii/botania/client/render/entity/RenderPixie.java index 0cc0f1f65..248dce97f 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderPixie.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderPixie.java @@ -1,19 +1,19 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [? (GMT)] */ package vazkii.botania.client.render.entity; import com.mojang.blaze3d.platform.GlStateManager; + import net.minecraft.client.renderer.entity.EntityRendererManager; import net.minecraft.client.renderer.entity.MobRenderer; import net.minecraft.util.ResourceLocation; + import vazkii.botania.api.internal.ShaderCallback; import vazkii.botania.client.core.helper.ShaderHelper; import vazkii.botania.client.lib.LibResources; @@ -47,4 +47,4 @@ public class RenderPixie extends MobRenderer { public ResourceLocation getEntityTexture(@Nonnull EntityPixie entity) { return new ResourceLocation(LibResources.MODEL_PIXIE); } -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderPoolMinecart.java b/src/main/java/vazkii/botania/client/render/entity/RenderPoolMinecart.java index f96067dfc..dacf0cab2 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderPoolMinecart.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderPoolMinecart.java @@ -1,25 +1,24 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 17, 2015, 11:17:48 PM (GMT)] */ package vazkii.botania.client.render.entity; import com.mojang.blaze3d.matrix.MatrixStack; + import net.minecraft.block.BlockState; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.entity.EntityRendererManager; import net.minecraft.client.renderer.entity.MinecartRenderer; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.render.tile.RenderTilePool; -import vazkii.botania.common.block.mana.BlockPool; import vazkii.botania.common.block.tile.mana.TilePool; import vazkii.botania.common.entity.EntityPoolMinecart; @@ -39,5 +38,4 @@ public class RenderPoolMinecart extends MinecartRenderer { TileEntityRendererDispatcher.instance.getRenderer(DUMMY).render(null, ClientTickHandler.partialTicks, ms, buffers, light, OverlayTexture.DEFAULT_UV); } - } diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderSpark.java b/src/main/java/vazkii/botania/client/render/entity/RenderSpark.java index f47bb4012..6c149cc9d 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderSpark.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderSpark.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 14, 2015, 1:03:11 AM (GMT)] */ package vazkii.botania.client.render.entity; import net.minecraft.client.renderer.entity.EntityRendererManager; import net.minecraft.client.renderer.texture.TextureAtlasSprite; + import vazkii.botania.client.core.handler.MiscellaneousIcons; import vazkii.botania.common.entity.EntitySpark; diff --git a/src/main/java/vazkii/botania/client/render/entity/RenderSparkBase.java b/src/main/java/vazkii/botania/client/render/entity/RenderSparkBase.java index 5df946bb8..4d3c34add 100644 --- a/src/main/java/vazkii/botania/client/render/entity/RenderSparkBase.java +++ b/src/main/java/vazkii/botania/client/render/entity/RenderSparkBase.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 21, 2014, 5:53:22 PM (GMT)] */ package vazkii.botania.client.render.entity; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.Matrix4f; import net.minecraft.client.renderer.Vector3f; @@ -20,6 +19,7 @@ import net.minecraft.client.renderer.entity.EntityRendererManager; import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.ResourceLocation; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.handler.MiscellaneousIcons; import vazkii.botania.client.core.helper.RenderHelper; @@ -27,6 +27,7 @@ import vazkii.botania.common.entity.EntitySparkBase; import javax.annotation.Nonnull; import javax.annotation.Nullable; + import java.util.Random; public abstract class RenderSparkBase extends EntityRenderer { @@ -38,41 +39,41 @@ public abstract class RenderSparkBase extends EntityR @Override public void render(@Nonnull T tEntity, float yaw, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int light) { TextureAtlasSprite iicon = getBaseIcon(tEntity); - + ms.push(); - + double time = ClientTickHandler.ticksInGame + partialTicks + new Random(tEntity.getEntityId()).nextInt(); float a = 0.1F + (tEntity.isInvisible() ? 0 : 1) * 0.8F; - + int alpha = (int) ((0.7F + 0.3F * (float) (Math.sin(time / 5.0) + 0.5) * 2) * a * 255.0F); int iconColor = 0xFFFFFF | (alpha << 24); - + float scale = 0.75F + 0.1F * (float) Math.sin(time / 10); ms.scale(scale, scale, scale); - + IVertexBuilder buffer = buffers.getBuffer(RenderHelper.SPARK); ms.push(); ms.multiply(renderManager.getRotation()); ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(180)); renderIcon(ms, buffer, iicon, iconColor); - + ms.push(); ms.translate(-0.02F + (float) Math.sin(time / 20) * 0.2F, 0.24F + (float) Math.cos(time / 20) * 0.2F, 0.005F); ms.scale(0.2F, 0.2F, 0.2F); int starColor = tEntity.getNetwork().colorValue | ((int) (a * 255.0F) << 24); renderIcon(ms, buffer, MiscellaneousIcons.INSTANCE.corporeaIconStar, starColor); ms.pop(); - + TextureAtlasSprite spinningIcon = getSpinningIcon(tEntity); if (spinningIcon != null) { ms.translate(-0.02F + (float) Math.sin(time / 20) * -0.2F, 0.24F + (float) Math.cos(time / 20) * -0.2F, 0.005F); ms.scale(0.2F, 0.2F, 0.2F); renderIcon(ms, buffer, spinningIcon, iconColor); } - + ms.pop(); renderCallback(tEntity, partialTicks, ms, buffers); - + ms.pop(); } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileAlfPortal.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileAlfPortal.java index 841ba2c47..4b4a311e2 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileAlfPortal.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileAlfPortal.java @@ -1,36 +1,29 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 9, 2014, 9:55:07 PM (GMT)] */ package vazkii.botania.client.render.tile; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; -import net.minecraft.client.Minecraft; + import net.minecraft.client.renderer.Atlases; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.Matrix3f; import net.minecraft.client.renderer.Matrix4f; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Vector3f; -import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import org.lwjgl.opengl.GL11; + import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.api.state.enums.AlfPortalState; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.handler.MiscellaneousIcons; -import vazkii.botania.client.core.proxy.ClientProxy; -import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.tile.TileAlfPortal; import javax.annotation.Nonnull; @@ -44,15 +37,16 @@ public class RenderTileAlfPortal extends TileEntityRenderer { @Override public void render(@Nonnull TileAlfPortal portal, float f, MatrixStack ms, IRenderTypeBuffer buffers, int light, int overlay) { AlfPortalState state = portal.getBlockState().get(BotaniaStateProps.ALFPORTAL_STATE); - if(state == AlfPortalState.OFF) + if (state == AlfPortalState.OFF) { return; + } ms.push(); ms.translate(-1F, 1F, 0.25F); float alpha = (float) Math.min(1F, (Math.sin((ClientTickHandler.ticksInGame + f) / 8D) + 1D) / 7D + 0.6D) * (Math.min(60, portal.ticksOpen) / 60F) * 0.5F; - if(state == AlfPortalState.ON_X) { + if (state == AlfPortalState.ON_X) { ms.translate(1.25F, 0F, 1.75F); ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(90F)); } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileAltar.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileAltar.java index 7e73e2ffa..2c28507d0 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileAltar.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileAltar.java @@ -1,34 +1,28 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 21, 2014, 7:55:47 PM (GMT)] */ package vazkii.botania.client.render.tile; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.block.Blocks; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Atlases; -import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.model.ItemCameraTransforms; -import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.fluid.Fluids; import net.minecraft.item.ItemStack; -import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.common.block.tile.TileAltar; @@ -42,28 +36,32 @@ public class RenderTileAltar extends TileEntityRenderer { @Override public void render(@Nonnull TileAltar altar, float pticks, MatrixStack ms, IRenderTypeBuffer buffers, int light, int overlay) { - if(!altar.getWorld().isBlockLoaded(altar.getPos())) + if (!altar.getWorld().isBlockLoaded(altar.getPos())) { return; + } ms.push(); ms.translate(0.5, 1.5, 0.5); boolean water = altar.getFluid() == Fluids.WATER; boolean lava = altar.getFluid() == Fluids.LAVA; - if(water || lava) { + if (water || lava) { ms.push(); float s = 1F / 256F * 10F; float v = 1F / 8F; float w = -v * 2.5F; - if(water) { + if (water) { int petals = 0; - for(int i = 0; i < altar.getSizeInventory(); i++) - if(!altar.getItemHandler().getStackInSlot(i).isEmpty()) + for (int i = 0; i < altar.getSizeInventory(); i++) { + if (!altar.getItemHandler().getStackInSlot(i).isEmpty()) { petals++; - else break; + } else { + break; + } + } - if(petals > 0) { + if (petals > 0) { final float modifier = 6F; final float rotationModifier = 0.25F; final float radiusBase = 1.2F; @@ -75,13 +73,13 @@ public class RenderTileAltar extends TileEntityRenderer { ms.push(); ms.translate(-0.05F, -0.5F, 0F); ms.scale(v, v, v); - for(int i = 0; i < petals; i++) { + for (int i = 0; i < petals; i++) { float offset = offsetPerPetal * i; float deg = (int) (ticks / rotationModifier % 360F + offset); float rad = deg * (float) Math.PI / 180F; float radiusX = (float) (radiusBase + radiusMod * Math.sin(ticks / modifier)); float radiusZ = (float) (radiusBase + radiusMod * Math.cos(ticks / modifier)); - float x = (float) (radiusX * Math.cos(rad)); + float x = (float) (radiusX * Math.cos(rad)); float z = (float) (radiusZ * Math.sin(rad)); float y = (float) Math.cos((ticks + 50 * i) / 5F) / 10F; diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileAnimatedTorch.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileAnimatedTorch.java index a5c194f93..d7383ccdc 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileAnimatedTorch.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileAnimatedTorch.java @@ -1,17 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [28/09/2016, 17:55:36 (GMT)] */ package vazkii.botania.client.render.tile; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; + import net.minecraft.block.Blocks; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; @@ -20,6 +18,7 @@ import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.item.ItemStack; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.common.block.tile.TileAnimatedTorch; @@ -38,8 +37,9 @@ public class RenderTileAnimatedTorch extends TileEntityRenderer. It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Oct 24, 2015, 3:51:35 PM (GMT)] */ package vazkii.botania.client.render.tile; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.RenderType; @@ -23,6 +22,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.util.Direction; import net.minecraft.util.ResourceLocation; + import vazkii.botania.api.item.IAvatarWieldable; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.lib.LibResources; @@ -47,10 +47,12 @@ public class RenderTileAvatar extends TileEntityRenderer { @Override public void render(@Nullable TileAvatar avatar, float pticks, MatrixStack ms, IRenderTypeBuffer buffers, int light, int overlay) { - if (avatar != null) + if (avatar != null) { if (!avatar.getWorld().isBlockLoaded(avatar.getPos()) - || avatar.getBlockState().getBlock() != ModBlocks.avatar) + || avatar.getBlockState().getBlock() != ModBlocks.avatar) { return; + } + } ms.push(); Direction facing = avatar != null && avatar.getWorld() != null ? avatar.getBlockState().get(BlockStateProperties.HORIZONTAL_FACING) : Direction.SOUTH; diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileBellows.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileBellows.java index 79a2728e6..9fbbd3780 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileBellows.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileBellows.java @@ -1,23 +1,23 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 28, 2015, 5:30:41 PM (GMT)] */ package vazkii.botania.client.render.tile; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.util.ResourceLocation; + import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.ModelBellows; import vazkii.botania.common.block.tile.mana.TileBellows; @@ -38,12 +38,19 @@ public class RenderTileBellows extends TileEntityRenderer { ms.translate(0.5F, 1.5F, 0.5F); ms.scale(1F, -1F, -1F); float angle = 0; - if(bellows != null) { - switch(bellows.getBlockState().get(BlockStateProperties.HORIZONTAL_FACING)) { - case SOUTH: break; - case NORTH: angle = 180F; break; - case EAST: angle = 270F; break; - case WEST: angle = 90F; break; + if (bellows != null) { + switch (bellows.getBlockState().get(BlockStateProperties.HORIZONTAL_FACING)) { + case SOUTH: + break; + case NORTH: + angle = 180F; + break; + case EAST: + angle = 270F; + break; + case WEST: + angle = 90F; + break; } } ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(angle)); diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileBrewery.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileBrewery.java index 1111e68a7..61e4a4554 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileBrewery.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileBrewery.java @@ -1,22 +1,21 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Oct 31, 2014, 4:53:15 PM (GMT)] */ package vazkii.botania.client.render.tile; import com.mojang.blaze3d.matrix.MatrixStack; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.ModelBrewery; diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileCocoon.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileCocoon.java index 2479783bc..a4e4fae19 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileCocoon.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileCocoon.java @@ -1,33 +1,28 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 8, 2015, 4:44:23 PM (GMT)] */ package vazkii.botania.client.render.tile; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.RenderTypeLookup; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.texture.AtlasTexture; -import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import org.lwjgl.opengl.GL11; + import vazkii.botania.common.block.tile.TileCocoon; import javax.annotation.Nonnull; -import java.util.Random; public class RenderTileCocoon extends TileEntityRenderer { @@ -39,7 +34,7 @@ public class RenderTileCocoon extends TileEntityRenderer { public void render(@Nonnull TileCocoon cocoon, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int light, int overlay) { float rot = 0F; float modval = 60F - (float) cocoon.timePassed / (float) TileCocoon.TOTAL_TIME * 30F; - if(cocoon.timePassed % modval < 10) { + if (cocoon.timePassed % modval < 10) { float mod = (cocoon.timePassed + partialTicks) % modval; float v = mod / 5 * (float) Math.PI * 2; rot = (float) Math.sin(v) * (float) Math.log(cocoon.timePassed + partialTicks); diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileCorporeaCrystalCube.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileCorporeaCrystalCube.java index 547e5e372..e7206ec2b 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileCorporeaCrystalCube.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileCorporeaCrystalCube.java @@ -1,32 +1,29 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 30, 2015, 4:10:14 PM (GMT)] */ package vazkii.botania.client.render.tile; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.block.Blocks; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Atlases; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.entity.ItemRenderer; import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.BlockItem; import net.minecraft.item.ItemStack; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.common.block.tile.corporea.TileCorporeaCrystalCube; @@ -46,16 +43,18 @@ public class RenderTileCorporeaCrystalCube extends TileEntityRenderer 9999) { + if (count > 9999) { countStr = count / 1000 + "K"; color = 0xFFFF00; - if(count > 9999999) { + if (count > 9999999) { countStr = count / 10000000 + "M"; color = 0x00FF00; } @@ -110,7 +109,7 @@ public class RenderTileCorporeaCrystalCube extends TileEntityRenderer. It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 15, 2015, 12:54:49 AM (GMT)] */ package vazkii.botania.client.render.tile; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; -import net.minecraft.client.Minecraft; + import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.Quaternion; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.model.ModelRenderer; -import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.util.ResourceLocation; + import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex; @@ -67,7 +64,7 @@ public class RenderTileCorporeaIndex extends TileEntityRenderer 0F) { + if (index != null && index.closeby > 0F) { float starScale = 0.02F; float starRadius = (float) TileCorporeaIndex.RADIUS * index.closeby + (index.closeby == 1F ? 0F : index.hasCloseby ? partialTicks : -partialTicks) * 0.2F; double rads = (index.ticksWithCloseby + partialTicks) * 2 * Math.PI / 180; diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileEnchanter.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileEnchanter.java index 6f14ff21c..882903ffa 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileEnchanter.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileEnchanter.java @@ -1,36 +1,27 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 15, 2014, 5:04:42 PM (GMT)] */ package vazkii.botania.client.render.tile; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GLX; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Vector3f; -import net.minecraft.client.renderer.entity.EntityRenderer; -import net.minecraft.client.renderer.texture.AtlasTexture; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.entity.item.ItemEntity; -import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.handler.MiscellaneousIcons; import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.client.core.helper.RenderHelper; -import vazkii.botania.client.core.helper.ShaderHelper; -import vazkii.botania.client.core.proxy.ClientProxy; import vazkii.botania.common.block.tile.TileEnchanter; import javax.annotation.Nonnull; @@ -47,17 +38,19 @@ public class RenderTileEnchanter extends TileEntityRenderer { public void render(@Nonnull TileEnchanter enchanter, float f, MatrixStack ms, IRenderTypeBuffer buffers, int light, int overlay) { float alphaMod = 0F; - if(enchanter.stage == TileEnchanter.State.GATHER_MANA) + if (enchanter.stage == TileEnchanter.State.GATHER_MANA) { alphaMod = Math.min(20, enchanter.stageTicks) / 20F; - else if(enchanter.stage == TileEnchanter.State.RESET) + } else if (enchanter.stage == TileEnchanter.State.RESET) { alphaMod = (20 - enchanter.stageTicks) / 20F; - else if(enchanter.stage == TileEnchanter.State.DO_ENCHANT) + } else if (enchanter.stage == TileEnchanter.State.DO_ENCHANT) { alphaMod = 1F; + } ms.push(); - if(!enchanter.itemToEnchant.isEmpty()) { - if(item == null) + if (!enchanter.itemToEnchant.isEmpty()) { + if (item == null) { item = new ItemEntity(enchanter.getWorld(), enchanter.getPos().getX(), enchanter.getPos().getY() + 1, enchanter.getPos().getZ(), enchanter.itemToEnchant); + } item.age = ClientTickHandler.ticksInGame; item.setItem(enchanter.itemToEnchant); @@ -72,8 +65,8 @@ public class RenderTileEnchanter extends TileEntityRenderer { float alpha = (float) ((Math.sin((ClientTickHandler.ticksInGame + f) / 8D) + 1D) / 5D + 0.4D) * alphaMod; - if(alpha > 0) { - if(enchanter.stage == TileEnchanter.State.DO_ENCHANT || enchanter.stage == TileEnchanter.State.RESET) { + if (alpha > 0) { + if (enchanter.stage == TileEnchanter.State.DO_ENCHANT || enchanter.stage == TileEnchanter.State.RESET) { int ticks = enchanter.stageTicks + enchanter.stage3EndTicks; int angle = ticks * 2; float yTranslation = Math.min(20, ticks) / 20F * 1.15F; diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileFloatingFlower.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileFloatingFlower.java index 4df4857f7..5393ada95 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileFloatingFlower.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileFloatingFlower.java @@ -1,38 +1,33 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 8, 2014, 10:58:46 PM (GMT)] */ package vazkii.botania.client.render.tile; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; + import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.BlockModelRenderer; import net.minecraft.client.renderer.BlockRendererDispatcher; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.RenderTypeLookup; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Direction; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.ILightReader; import net.minecraftforge.client.model.data.IModelData; + import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.common.core.handler.ConfigHandler; import javax.annotation.Nonnull; + import java.util.Random; public class RenderTileFloatingFlower extends TileEntityRenderer { @@ -43,18 +38,21 @@ public class RenderTileFloatingFlower extends TileEntityRenderer { @Override public void render(@Nonnull TileEntity tile, float t, MatrixStack ms, IRenderTypeBuffer buffers, int light, int overlay) { - if (ConfigHandler.CLIENT.staticFloaters.get()) + if (ConfigHandler.CLIENT.staticFloaters.get()) { return; + } IModelData data = tile.getModelData(); - if (!data.hasProperty(BotaniaStateProps.FLOATING_DATA)) + if (!data.hasProperty(BotaniaStateProps.FLOATING_DATA)) { return; + } ms.push(); double worldTime = ClientTickHandler.ticksInGame + t; - if(tile.getWorld() != null) + if (tile.getWorld() != null) { worldTime += new Random(tile.getPos().hashCode()).nextInt(1000); + } ms.translate(0.5F, 0, 0.5F); ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-((float) worldTime * 0.5F))); diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileGaiaHead.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileGaiaHead.java index 8d1c44e8d..72d403985 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileGaiaHead.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileGaiaHead.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [? (GMT)] */ package vazkii.botania.client.render.tile; @@ -14,7 +12,7 @@ import com.mojang.authlib.GameProfile; import com.mojang.authlib.minecraft.MinecraftProfileTexture; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; -import net.minecraft.block.AbstractSkullBlock; + import net.minecraft.block.BlockState; import net.minecraft.block.SkullBlock; import net.minecraft.block.WallSkullBlock; @@ -23,9 +21,7 @@ import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.entity.model.GenericHeadModel; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer; import net.minecraft.client.renderer.tileentity.SkullTileEntityRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.resources.DefaultPlayerSkin; import net.minecraft.entity.Entity; @@ -40,13 +36,13 @@ import net.minecraft.tileentity.SkullTileEntity; import net.minecraft.util.Direction; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; + import vazkii.botania.client.core.helper.ShaderHelper; import vazkii.botania.client.core.helper.ShaderWrappedRenderLayer; import vazkii.botania.client.render.entity.RenderDoppleganger; -import vazkii.botania.common.block.BlockGaiaHead; -import javax.annotation.Nonnull; import javax.annotation.Nullable; + import java.util.Map; public class RenderTileGaiaHead extends SkullTileEntityRenderer { @@ -64,26 +60,27 @@ public class RenderTileGaiaHead extends SkullTileEntityRenderer { BlockState blockstate = skull == null ? null : skull.getBlockState(); boolean flag = blockstate != null && blockstate.getBlock() instanceof WallSkullBlock; Direction direction = flag ? blockstate.get(WallSkullBlock.FACING) : null; - float f1 = 22.5F * (float)(flag ? (2 + direction.getHorizontalIndex()) * 4 : blockstate == null ? 0 : blockstate.get(SkullBlock.ROTATION)); + float f1 = 22.5F * (float) (flag ? (2 + direction.getHorizontalIndex()) * 4 : blockstate == null ? 0 : blockstate.get(SkullBlock.ROTATION)); Entity view = Minecraft.getInstance().getRenderViewEntity(); SkullBlock.ISkullType type = SkullBlock.Types.PLAYER; GameProfile profile = null; - if(view instanceof PlayerEntity) { + if (view instanceof PlayerEntity) { profile = ((PlayerEntity) view).getGameProfile(); - } else if (view instanceof SkeletonEntity) + } else if (view instanceof SkeletonEntity) { type = SkullBlock.Types.SKELETON; - else if(view instanceof WitherSkeletonEntity) + } else if (view instanceof WitherSkeletonEntity) { type = SkullBlock.Types.WITHER_SKELETON; - else if(view instanceof WitherEntity) + } else if (view instanceof WitherEntity) { type = SkullBlock.Types.WITHER_SKELETON; - else if(view instanceof ZombieEntity) + } else if (view instanceof ZombieEntity) { type = SkullBlock.Types.ZOMBIE; - else if(view instanceof CreeperEntity) + } else if (view instanceof CreeperEntity) { type = SkullBlock.Types.CREEPER; - else if(view instanceof EnderDragonEntity) + } else if (view instanceof EnderDragonEntity) { type = SkullBlock.Types.DRAGON; + } gaiaRender(direction, f1, type, profile, f, ms, buffers, light); } @@ -95,19 +92,19 @@ public class RenderTileGaiaHead extends SkullTileEntityRenderer { if (facing == null) { ms.translate(0.5D, 0.0D, 0.5D); } else { - switch(facing) { - case NORTH: - ms.translate(0.5D, 0.25D, (double)0.74F); - break; - case SOUTH: - ms.translate(0.5D, 0.25D, (double)0.26F); - break; - case WEST: - ms.translate((double)0.74F, 0.25D, 0.5D); - break; - case EAST: - default: - ms.translate((double)0.26F, 0.25D, 0.5D); + switch (facing) { + case NORTH: + ms.translate(0.5D, 0.25D, (double) 0.74F); + break; + case SOUTH: + ms.translate(0.5D, 0.25D, (double) 0.26F); + break; + case WEST: + ms.translate((double) 0.74F, 0.25D, 0.5D); + break; + case EAST: + default: + ms.translate((double) 0.26F, 0.25D, 0.5D); } } @@ -132,4 +129,4 @@ public class RenderTileGaiaHead extends SkullTileEntityRenderer { return new ShaderWrappedRenderLayer(ShaderHelper.BotaniaShader.DOPPLEGANGER, RenderDoppleganger.defaultCallback, base); } -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileHourglass.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileHourglass.java index 518f44e22..003837b49 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileHourglass.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileHourglass.java @@ -1,32 +1,30 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 29, 2015, 8:19:32 PM (GMT)] */ package vazkii.botania.client.render.tile; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; -import net.minecraft.client.Minecraft; + import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.ModelHourglass; import vazkii.botania.common.block.tile.TileHourglass; import javax.annotation.Nullable; + import java.util.Random; public class RenderTileHourglass extends TileEntityRenderer { @@ -43,8 +41,9 @@ public class RenderTileHourglass extends TileEntityRenderer { ms.push(); boolean hasWorld = hourglass != null && hourglass.getWorld() != null; int wtime = !hasWorld ? 0 : ClientTickHandler.ticksInGame; - if(wtime != 0) + if (wtime != 0) { wtime += new Random(hourglass.getPos().hashCode()).nextInt(360); + } float time = wtime == 0 ? 0 : wtime + ticks; float x = 0.5F + (float) Math.cos(time * 0.05F) * 0.025F; @@ -58,8 +57,9 @@ public class RenderTileHourglass extends TileEntityRenderer { ms.translate(x, y, z); float rot = hasWorld && hourglass.flip ? 180F : 1F; - if(hasWorld && hourglass.flipTicks > 0) + if (hasWorld && hourglass.flipTicks > 0) { rot += (hourglass.flipTicks - ticks) * (180F / 4F); + } ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(rot)); ms.scale(1F, -1F, -1F); diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileIncensePlate.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileIncensePlate.java index a561a408a..bcd819f03 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileIncensePlate.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileIncensePlate.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 15, 2015, 4:27:27 PM (GMT)] */ package vazkii.botania.client.render.tile; import com.google.common.collect.ImmutableMap; import com.mojang.blaze3d.matrix.MatrixStack; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.Vector3f; @@ -21,9 +20,11 @@ import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.item.ItemStack; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.util.Direction; + import vazkii.botania.common.block.tile.TileIncensePlate; import javax.annotation.Nonnull; + import java.util.Map; public class RenderTileIncensePlate extends TileEntityRenderer { @@ -38,8 +39,9 @@ public class RenderTileIncensePlate extends TileEntityRenderer @Override public void render(@Nonnull TileIncensePlate plate, float ticks, MatrixStack ms, IRenderTypeBuffer buffers, int light, int overlay) { ItemStack stack = plate.getItemHandler().getStackInSlot(0); - if(stack.isEmpty()) + if (stack.isEmpty()) { return; + } Direction facing = plate.getBlockState().get(BlockStateProperties.HORIZONTAL_FACING); diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileLightRelay.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileLightRelay.java index 81b13e1e7..36b67a17c 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileLightRelay.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileLightRelay.java @@ -1,39 +1,34 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 16, 2015, 5:03:57 PM (GMT)] */ package vazkii.botania.client.render.tile; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.Matrix4f; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Vector3f; -import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import org.lwjgl.opengl.GL11; + import vazkii.botania.api.state.enums.LuminizerVariant; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.handler.MiscellaneousIcons; import vazkii.botania.client.core.helper.RenderHelper; -import vazkii.botania.client.core.helper.ShaderHelper; -import vazkii.botania.client.core.proxy.ClientProxy; import vazkii.botania.common.block.BlockLightRelay; import vazkii.botania.common.block.tile.TileLightRelay; import javax.annotation.Nonnull; + import java.util.EnumMap; import java.util.Map; @@ -48,11 +43,12 @@ public class RenderTileLightRelay extends TileEntityRenderer { @Override public void render(@Nonnull TileLightRelay tile, float pticks, MatrixStack ms, IRenderTypeBuffer buffers, int light, int overlay) { BlockState state = tile.getBlockState(); - if(!(state.getBlock() instanceof BlockLightRelay)) + if (!(state.getBlock() instanceof BlockLightRelay)) { return; + } Minecraft mc = Minecraft.getInstance(); - if(sprites.isEmpty()) { + if (sprites.isEmpty()) { sprites.put(LuminizerVariant.DEFAULT, MiscellaneousIcons.INSTANCE.lightRelayWorldIcon); sprites.put(LuminizerVariant.DETECTOR, MiscellaneousIcons.INSTANCE.lightRelayWorldIconRed); sprites.put(LuminizerVariant.FORK, MiscellaneousIcons.INSTANCE.lightRelayWorldIconGreen); diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTilePool.java b/src/main/java/vazkii/botania/client/render/tile/RenderTilePool.java index 7a6233886..f861438ee 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTilePool.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTilePool.java @@ -1,22 +1,20 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 26, 2014, 12:25:11 AM (GMT)] */ package vazkii.botania.client.render.tile; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.Matrix4f; import net.minecraft.client.renderer.RenderTypeLookup; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.model.IBakedModel; @@ -24,6 +22,7 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.util.math.MathHelper; + import vazkii.botania.api.mana.IPoolOverlayProvider; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.handler.MiscellaneousIcons; @@ -33,6 +32,7 @@ import vazkii.botania.common.block.mana.BlockPool; import vazkii.botania.common.block.tile.mana.TilePool; import javax.annotation.Nullable; + import java.util.Random; public class RenderTilePool extends TileEntityRenderer { @@ -46,9 +46,10 @@ public class RenderTilePool extends TileEntityRenderer { @Override public void render(@Nullable TilePool pool, float f, MatrixStack ms, IRenderTypeBuffer buffers, int light, int overlay) { - if(pool != null && (!pool.getWorld().isBlockLoaded(pool.getPos()) - || !(pool.getBlockState().getBlock() instanceof BlockPool))) + if (pool != null && (!pool.getWorld().isBlockLoaded(pool.getPos()) + || !(pool.getBlockState().getBlock() instanceof BlockPool))) { return; + } ms.push(); @@ -74,8 +75,9 @@ public class RenderTilePool extends TileEntityRenderer { int mana = pool == null ? cartMana : pool.getCurrentMana(); int cap = pool == null ? -1 : pool.manaCap; - if(cap == -1) + if (cap == -1) { cap = TilePool.MAX_MANA; + } float waterLevel = (float) mana / (float) cap * 0.4F; @@ -83,11 +85,11 @@ public class RenderTilePool extends TileEntityRenderer { float v = 1F / 8F; float w = -v * 3.5F; - if(pool != null) { + if (pool != null) { Block below = pool.getWorld().getBlockState(pool.getPos().down()).getBlock(); - if(below instanceof IPoolOverlayProvider) { + if (below instanceof IPoolOverlayProvider) { TextureAtlasSprite overlayIcon = ((IPoolOverlayProvider) below).getIcon(pool.getWorld(), pool.getPos()); - if(overlayIcon != null) { + if (overlayIcon != null) { ms.push(); float alpha = (float) ((Math.sin((ClientTickHandler.ticksInGame + f) / 20.0) + 1) * 0.3 + 0.2); ms.translate(-0.5F, -1F - 0.43F, -0.5F); @@ -102,7 +104,7 @@ public class RenderTilePool extends TileEntityRenderer { } } - if(waterLevel > 0) { + if (waterLevel > 0) { s = 1F / 256F * 14F; ms.push(); ms.translate(w, -1F - (0.43F - waterLevel), w); diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTilePrism.java b/src/main/java/vazkii/botania/client/render/tile/RenderTilePrism.java index 2889eaba3..6478f49bc 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTilePrism.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTilePrism.java @@ -1,17 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 17, 2015, 8:05:07 PM (GMT)] */ package vazkii.botania.client.render.tile; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.Vector3f; @@ -20,6 +18,7 @@ import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.item.ItemStack; + import vazkii.botania.api.mana.ILens; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.common.block.tile.mana.TilePrism; @@ -38,9 +37,9 @@ public class RenderTilePrism extends TileEntityRenderer { ItemStack stack = prism.getItemHandler().getStackInSlot(0); - if(!stack.isEmpty()) { + if (!stack.isEmpty()) { Minecraft.getInstance().textureManager.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE); - if(stack.getItem() instanceof ILens) { + if (stack.getItem() instanceof ILens) { ms.push(); ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(90)); ms.translate(0.5F, 0.5F, pos); diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTilePump.java b/src/main/java/vazkii/botania/client/render/tile/RenderTilePump.java index 73946e90c..887a756fa 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTilePump.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTilePump.java @@ -1,7 +1,16 @@ +/* + * This class is 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 + */ package vazkii.botania.client.render.tile; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.RenderType; @@ -10,39 +19,41 @@ import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.state.properties.BlockStateProperties; + import vazkii.botania.common.block.tile.mana.TilePump; public class RenderTilePump extends TileEntityRenderer { - public static IBakedModel headModel = null; + public static IBakedModel headModel = null; - public RenderTilePump(TileEntityRendererDispatcher manager) { - super(manager); - } + public RenderTilePump(TileEntityRendererDispatcher manager) { + super(manager); + } - @Override - public void render(TilePump pump, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int light, int overlay) { - ms.push(); - ms.translate(0.5, 0, 0.5); - float angle = 0; - switch (pump.getBlockState().get(BlockStateProperties.HORIZONTAL_FACING)) { - default: - case NORTH: break; - case SOUTH: - angle = 180; - break; - case EAST: - angle = -90; - break; - case WEST: - angle = 90; - break; - } - ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(angle)); - ms.translate(-0.5, 0, -0.5); - double diff = Math.max(0F, Math.min(8F, pump.innerRingPos + pump.moving * partialTicks)); - ms.translate(0, 0, diff / 14); - IVertexBuilder buffer = buffers.getBuffer(RenderType.getSolid()); - Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelRenderer().render(ms.peek(), buffer, null, headModel, 1, 1, 1, light, overlay); - ms.pop(); - } + @Override + public void render(TilePump pump, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int light, int overlay) { + ms.push(); + ms.translate(0.5, 0, 0.5); + float angle = 0; + switch (pump.getBlockState().get(BlockStateProperties.HORIZONTAL_FACING)) { + default: + case NORTH: + break; + case SOUTH: + angle = 180; + break; + case EAST: + angle = -90; + break; + case WEST: + angle = 90; + break; + } + ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(angle)); + ms.translate(-0.5, 0, -0.5); + double diff = Math.max(0F, Math.min(8F, pump.innerRingPos + pump.moving * partialTicks)); + ms.translate(0, 0, diff / 14); + IVertexBuilder buffer = buffers.getBuffer(RenderType.getSolid()); + Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelRenderer().render(ms.peek(), buffer, null, headModel, 1, 1, 1, light, overlay); + ms.pop(); + } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTilePylon.java b/src/main/java/vazkii/botania/client/render/tile/RenderTilePylon.java index 47ae958e9..1a7107bb7 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTilePylon.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTilePylon.java @@ -1,20 +1,17 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 18, 2014, 10:18:36 PM (GMT)] */ package vazkii.botania.client.render.tile; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.Vector3f; @@ -24,7 +21,7 @@ import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.item.ItemStack; import net.minecraft.util.LazyValue; import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.client.lib.LibResources; @@ -37,6 +34,7 @@ import vazkii.botania.common.block.tile.TilePylon; import javax.annotation.Nonnull; import javax.annotation.Nullable; + import java.util.Random; public class RenderTilePylon extends TileEntityRenderer { @@ -58,18 +56,19 @@ public class RenderTilePylon extends TileEntityRenderer { @Override public void render(@Nonnull TilePylon pylon, float pticks, MatrixStack ms, IRenderTypeBuffer buffers, int light, int overlay) { - if(!pylon.getWorld().isBlockLoaded(pylon.getPos()) || !(pylon.getBlockState().getBlock() instanceof BlockPylon)) + if (!pylon.getWorld().isBlockLoaded(pylon.getPos()) || !(pylon.getBlockState().getBlock() instanceof BlockPylon)) { return; + } renderPylon(pylon, pticks, ms, buffers, light, overlay); } - + private void renderPylon(@Nullable TilePylon pylon, float pticks, MatrixStack ms, IRenderTypeBuffer buffers, int light, int overlay) { BlockPylon.Variant type = pylon == null ? forceVariant : ((BlockPylon) pylon.getBlockState().getBlock()).variant; IPylonModel model; ResourceLocation texture; RenderType shaderLayer; - switch(type) { + switch (type) { default: case MANA: { model = manaModel; @@ -102,24 +101,28 @@ public class RenderTilePylon extends TileEntityRenderer { ms.push(); ms.translate(0.5F, 0F, -0.5F); - if(pylon != null) + if (pylon != null) { ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(worldTime * 1.5F)); + } RenderType layer = RenderType.getEntityTranslucent(texture); IVertexBuilder buffer = buffers.getBuffer(layer); model.renderRing(ms, buffer, light, overlay); - if(pylon != null) + if (pylon != null) { ms.translate(0D, Math.sin(worldTime / 20D) / 20 - 0.025, 0D); + } ms.pop(); ms.push(); - if(pylon != null) + if (pylon != null) { ms.translate(0D, Math.sin(worldTime / 20D) / 17.5, 0D); + } ms.translate(0.5F, 0F, -0.5F); - if(pylon != null) + if (pylon != null) { ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-worldTime)); + } buffer = buffers.getBuffer(shaderLayer); model.renderCrystal(ms, buffer, light, overlay); @@ -134,7 +137,7 @@ public class RenderTilePylon extends TileEntityRenderer { @Override public void render(ItemStack stack, MatrixStack ms, IRenderTypeBuffer buffers, int light, int overlay) { - if(Block.getBlockFromItem(stack.getItem()) instanceof BlockPylon) { + if (Block.getBlockFromItem(stack.getItem()) instanceof BlockPylon) { RenderTilePylon.forceVariant = ((BlockPylon) Block.getBlockFromItem(stack.getItem())).variant; TileEntityRenderer r = TileEntityRendererDispatcher.instance.getRenderer(DUMMY.getValue()); ((RenderTilePylon) r).renderPylon(null, 0, ms, buffers, light, overlay); diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileRedString.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileRedString.java index 96ff16107..00f15b3f4 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileRedString.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileRedString.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 14, 2014, 6:52:09 PM (GMT)] */ package vazkii.botania.client.render.tile; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; @@ -19,6 +18,7 @@ import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.common.block.tile.string.TileRedString; @@ -34,10 +34,11 @@ public class RenderTileRedString extends TileEntityRenderer { public static void tick() { PlayerEntity player = Minecraft.getInstance().player; boolean hasWand = player != null && PlayerHelper.hasHeldItem(player, ModItems.twigWand); - if(sizeAlpha > 0F && !hasWand) + if (sizeAlpha > 0F && !hasWand) { sizeAlpha -= 0.1F; - else if(sizeAlpha < 1F && hasWand) + } else if (sizeAlpha < 1F && hasWand) { sizeAlpha += 0.1F; + } } public RenderTileRedString(TileEntityRendererDispatcher manager) { @@ -55,7 +56,7 @@ public class RenderTileRedString extends TileEntityRenderer { Direction dir = tile.getOrientation(); BlockPos bind = tile.getBinding(); - if(bind != null) { + if (bind != null) { ms.push(); ms.translate(0.5, 0.5, 0.5); Vector3 vecOrig = new Vector3(bind.getX() - tile.getPos().getX(), bind.getY() - tile.getPos().getY(), bind.getZ() - tile.getPos().getZ()); @@ -69,7 +70,7 @@ public class RenderTileRedString extends TileEntityRenderer { double add = vecMag.mag(); double rand = Math.random() - 0.5; IVertexBuilder buffer = buffers.getBuffer(RenderHelper.LINE_1); - for(int i = 0; i < stages; i++) { + for (int i = 0; i < stages; i++) { addVertexAtWithTranslation(ms, buffer, color, dir, vecApply.x, vecApply.y, vecApply.z, rand, len); rand = Math.random() - 0.5; vecApply = vecApply.add(vecMag); @@ -97,4 +98,3 @@ public class RenderTileRedString extends TileEntityRenderer { } } - diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileRuneAltar.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileRuneAltar.java index 6559c948c..c36eabc8e 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileRuneAltar.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileRuneAltar.java @@ -1,18 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 2, 2014, 6:34:45 PM (GMT)] */ package vazkii.botania.client.render.tile; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.Vector3f; @@ -21,7 +19,7 @@ import net.minecraft.client.renderer.model.ModelRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.item.ItemStack; -import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.common.block.tile.TileRuneAltar; @@ -43,20 +41,24 @@ public class RenderTileRuneAltar extends TileEntityRenderer { ms.push(); int items = 0; - for(int i = 0; i < altar.getSizeInventory(); i++) - if(altar.getItemHandler().getStackInSlot(i).isEmpty()) + for (int i = 0; i < altar.getSizeInventory(); i++) { + if (altar.getItemHandler().getStackInSlot(i).isEmpty()) { break; - else items++; + } else { + items++; + } + } float[] angles = new float[altar.getSizeInventory()]; float anglePer = 360F / items; float totalAngle = 0F; - for(int i = 0; i < angles.length; i++) + for (int i = 0; i < angles.length; i++) { angles[i] = totalAngle += anglePer; + } double time = ClientTickHandler.ticksInGame + partticks; - for(int i = 0; i < altar.getSizeInventory(); i++) { + for (int i = 0; i < altar.getSizeInventory(); i++) { ms.push(); ms.translate(0.5F, 1.25F, 0.5F); ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(angles[i] + (float) time)); @@ -65,7 +67,7 @@ public class RenderTileRuneAltar extends TileEntityRenderer { ms.translate(0D, 0.075 * Math.sin((time + i * 10) / 5D), 0F); ItemStack stack = altar.getItemHandler().getStackInSlot(i); Minecraft mc = Minecraft.getInstance(); - if(!stack.isEmpty()) { + if (!stack.isEmpty()) { mc.getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.GROUND, light, overlay, ms, buffers); } ms.pop(); @@ -80,7 +82,7 @@ public class RenderTileRuneAltar extends TileEntityRenderer { ms.translate(0F, 0.2F, 0F); float scale = altar.getTargetMana() == 0 ? 0 : (float) altar.getCurrentMana() / (float) altar.getTargetMana() / 75F; - if(scale != 0) { + if (scale != 0) { int seed = altar.getPos().getX() ^ altar.getPos().getY() ^ altar.getPos().getZ(); ms.translate(0.5F, 0.7F, 0.5F); RenderHelper.renderStar(ms, buffers, 0x00E4D7, scale, scale, scale, seed); @@ -101,13 +103,13 @@ public class RenderTileRuneAltar extends TileEntityRenderer { ms.push(); ms.translate(-0.025F, 0.85F, -0.025F); - for(int i = 0; i < cubes; i++) { + for (int i = 0; i < cubes; i++) { float offset = offsetPerCube * i; float deg = (int) (ticks / rotationModifier % 360F + offset); float rad = deg * (float) Math.PI / 180F; float radiusX = (float) (radiusBase + radiusMod * Math.sin(ticks / modifier)); float radiusZ = (float) (radiusBase + radiusMod * Math.cos(ticks / modifier)); - float x = (float) (radiusX * Math.cos(rad)); + float x = (float) (radiusX * Math.cos(rad)); float z = (float) (radiusZ * Math.sin(rad)); float y = (float) Math.cos((ticks + 50 * i) / 5F) / 10F; @@ -119,7 +121,7 @@ public class RenderTileRuneAltar extends TileEntityRenderer { ms.multiply(new Vector3f(xRotate, yRotate, zRotate).getDegreesQuaternion(deg)); float alpha = 1; - if(curIter < iters) { + if (curIter < iters) { alpha = (float) curIter / (float) iters * 0.4F; } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileSparkChanger.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileSparkChanger.java index f76fe985e..7477123dc 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileSparkChanger.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileSparkChanger.java @@ -1,25 +1,23 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 28, 2015, 10:19:20 PM (GMT)] */ package vazkii.botania.client.render.tile; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.model.ItemCameraTransforms; -import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.item.ItemStack; + import vazkii.botania.common.block.tile.TileSparkChanger; import javax.annotation.Nonnull; @@ -36,7 +34,7 @@ public class RenderTileSparkChanger extends TileEntityRenderer ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(90)); ms.translate(1.0F, -0.125F, -0.25F); ItemStack stack = tileentity.getItemHandler().getStackInSlot(0); - if(!stack.isEmpty()) { + if (!stack.isEmpty()) { ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(180)); ms.translate(0.5F, 0.5F, 0); Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.GROUND, light, overlay, ms, buffers); diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileSpreader.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileSpreader.java index d5c1ab013..5471154f7 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileSpreader.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileSpreader.java @@ -1,20 +1,18 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 25, 2014, 9:42:31 PM (GMT)] */ package vazkii.botania.client.render.tile; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.Atlases; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.Quaternion; import net.minecraft.client.renderer.RenderTypeLookup; @@ -24,17 +22,16 @@ import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; + import vazkii.botania.api.ColorHelper; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.handler.MiscellaneousIcons; -import vazkii.botania.client.core.proxy.ClientProxy; -import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.block.mana.BlockSpreader; import vazkii.botania.common.block.tile.mana.TileSpreader; import javax.annotation.Nonnull; + import java.util.Random; public class RenderTileSpreader extends TileEntityRenderer { @@ -58,7 +55,7 @@ public class RenderTileSpreader extends TileEntityRenderer { double time = ClientTickHandler.ticksInGame + partialTicks; float r = 1, g = 1, b = 1; - if(spreader.getVariant() == BlockSpreader.Variant.GAIA) { + if (spreader.getVariant() == BlockSpreader.Variant.GAIA) { int color = MathHelper.hsvToRGB((float) ((time * 5 + new Random(spreader.getPos().hashCode()).nextInt(10000)) % 360) / 360F, 0.4F, 0.9F); r = (color >> 16 & 0xFF) / 255F; g = (color >> 8 & 0xFF) / 255F; @@ -85,7 +82,7 @@ public class RenderTileSpreader extends TileEntityRenderer { ms.translate(0.5, 1.5, 0.5); ItemStack stack = spreader.getItemHandler().getStackInSlot(0); - if(!stack.isEmpty()) { + if (!stack.isEmpty()) { ms.push(); ms.translate(0.0F, -1F, -0.4675F); ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(180)); @@ -95,7 +92,7 @@ public class RenderTileSpreader extends TileEntityRenderer { ms.pop(); } - if(spreader.paddingColor != null) { + if (spreader.paddingColor != null) { BlockState carpet = ColorHelper.CARPET_MAP.get(spreader.paddingColor).get().getDefaultState(); IBakedModel model = Minecraft.getInstance().getBlockRendererDispatcher().getModelForState(carpet); buffer = buffers.getBuffer(RenderTypeLookup.getEntityBlockLayer(carpet)); @@ -119,7 +116,7 @@ public class RenderTileSpreader extends TileEntityRenderer { // right ms.push(); ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(90)); - ms.translate(-1.5F, 0.5F , -0.5F - f); + ms.translate(-1.5F, 0.5F, -0.5F - f); Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelRenderer().render(ms.peek(), buffer, carpet, model, 1, 1, 1, light, overlay); ms.pop(); @@ -142,10 +139,15 @@ public class RenderTileSpreader extends TileEntityRenderer { private IBakedModel getInsideModel(TileSpreader tile) { switch (tile.getVariant()) { - case GAIA: return MiscellaneousIcons.INSTANCE.gaiaSpreaderInside; - case REDSTONE: return MiscellaneousIcons.INSTANCE.redstoneSpreaderInside; - case ELVEN: return MiscellaneousIcons.INSTANCE.elvenSpreaderInside; - default: case MANA: return MiscellaneousIcons.INSTANCE.manaSpreaderInside; + case GAIA: + return MiscellaneousIcons.INSTANCE.gaiaSpreaderInside; + case REDSTONE: + return MiscellaneousIcons.INSTANCE.redstoneSpreaderInside; + case ELVEN: + return MiscellaneousIcons.INSTANCE.elvenSpreaderInside; + default: + case MANA: + return MiscellaneousIcons.INSTANCE.manaSpreaderInside; } } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileStarfield.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileStarfield.java index d0b55ea79..505c56e4f 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileStarfield.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileStarfield.java @@ -1,37 +1,29 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 8, 2014, 2:38:15 PM (GMT)] */ package vazkii.botania.client.render.tile; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.GLAllocation; + import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.Matrix4f; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.tileentity.EndPortalTileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.util.Direction; -import net.minecraft.util.ResourceLocation; import net.minecraft.util.Util; import net.minecraft.util.math.MathHelper; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; + import vazkii.botania.common.block.tile.TileStarfield; -import java.nio.FloatBuffer; import java.util.List; import java.util.Random; @@ -54,8 +46,8 @@ public class RenderTileStarfield extends TileEntityRenderer { Matrix4f matrix4f = p_225616_3_.peek().getModel(); this.func_228883_a_(p_225616_1_, f, 0.15F, matrix4f, p_225616_4_.getBuffer(field_228881_e_.get(0))); - for(int j = 1; j < i; ++j) { - this.func_228883_a_(p_225616_1_, f, 2.0F / (float)(18 - j), matrix4f, p_225616_4_.getBuffer(field_228881_e_.get(j))); + for (int j = 1; j < i; ++j) { + this.func_228883_a_(p_225616_1_, f, 2.0F / (float) (18 - j), matrix4f, p_225616_4_.getBuffer(field_228881_e_.get(j))); } } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileTerraPlate.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileTerraPlate.java index 6286c2869..8a9bcddf6 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileTerraPlate.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileTerraPlate.java @@ -1,35 +1,25 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 8, 2014, 7:20:26 PM (GMT)] */ package vazkii.botania.client.render.tile; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GLX; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; -import net.minecraft.client.Minecraft; + import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.Matrix4f; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Vector3f; -import net.minecraft.client.renderer.texture.AtlasTexture; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.handler.MiscellaneousIcons; import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.client.core.helper.RenderHelper; -import vazkii.botania.client.core.helper.ShaderHelper; -import vazkii.botania.client.core.proxy.ClientProxy; import vazkii.botania.common.block.tile.TileTerraPlate; import javax.annotation.Nonnull; @@ -57,6 +47,4 @@ public class RenderTileTerraPlate extends TileEntityRenderer { ms.pop(); } - - } diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileTeruTeruBozu.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileTeruTeruBozu.java index c5b4dd0aa..7cfda9b67 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileTeruTeruBozu.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileTeruTeruBozu.java @@ -1,33 +1,30 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Oct 1, 2015, 9:02:30 PM (GMT)] */ package vazkii.botania.client.render.tile; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; -import net.minecraft.client.Minecraft; + import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.proxy.ClientProxy; import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.ModelTeruTeruBozu; import vazkii.botania.common.Botania; -import vazkii.botania.common.block.tile.TileAvatar; import vazkii.botania.common.block.tile.TileTeruTeruBozu; import javax.annotation.Nullable; + import java.util.Random; public class RenderTileTeruTeruBozu extends TileEntityRenderer { @@ -46,11 +43,12 @@ public class RenderTileTeruTeruBozu extends TileEntityRenderer ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(180)); double time = Botania.proxy.getWorldElapsedTicks() + partialTicks; boolean hasWorld = tileentity != null && tileentity.getWorld() != null; - if(hasWorld) + if (hasWorld) { time += new Random(tileentity.getPos().hashCode()).nextInt(1000); + } ms.translate(0.5F, -1.25F + (hasWorld ? (float) Math.sin(time * 0.01F) * 0.05F : 0F), -0.5F); - if(hasWorld) { + if (hasWorld) { ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion((float) (time * 0.3))); ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(4F * (float) Math.sin(time * 0.05F))); float s = 0.75F; diff --git a/src/main/java/vazkii/botania/client/render/tile/RenderTileTinyPotato.java b/src/main/java/vazkii/botania/client/render/tile/RenderTileTinyPotato.java index 606f13c48..84145c07e 100644 --- a/src/main/java/vazkii/botania/client/render/tile/RenderTileTinyPotato.java +++ b/src/main/java/vazkii/botania/client/render/tile/RenderTileTinyPotato.java @@ -1,18 +1,17 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 18, 2014, 10:48:46 PM (GMT)] */ package vazkii.botania.client.render.tile; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.mojang.datafixers.util.Pair; + import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.client.Minecraft; @@ -35,6 +34,7 @@ import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.common.MinecraftForge; + import vazkii.botania.api.item.TinyPotatoRenderEvent; import vazkii.botania.client.core.handler.ContributorFancinessHandler; import vazkii.botania.client.core.handler.MiscellaneousIcons; @@ -104,8 +104,9 @@ public class RenderTileTinyPotato extends TileEntityRenderer { @Override public void render(@Nonnull TileTinyPotato potato, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int light, int overlay) { - if(potato.getBlockState().getBlock() != ModBlocks.tinyPotato) + if (potato.getBlockState().getBlock() != ModBlocks.tinyPotato) { return; + } ms.push(); @@ -120,18 +121,26 @@ public class RenderTileTinyPotato extends TileEntityRenderer { Direction potatoFacing = potato.getBlockState().get(BlockStateProperties.HORIZONTAL_FACING); float rotY = 0; - switch(potatoFacing) { - default: - case SOUTH: break; - case NORTH: rotY = 180F; break; - case EAST: rotY = 270F; break; - case WEST: rotY = 90F; break; + switch (potatoFacing) { + default: + case SOUTH: + break; + case NORTH: + rotY = 180F; + break; + case EAST: + rotY = 270F; + break; + case WEST: + rotY = 90F; + break; } ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(rotY)); float jump = potato.jumpTicks; - if (jump > 0) + if (jump > 0) { jump -= partialTicks; + } float up = (float) -Math.abs(Math.sin(jump / 10 * Math.PI)) * 0.2F; float rotZ = (float) Math.sin(jump / 10 * Math.PI) * 2; @@ -160,8 +169,9 @@ public class RenderTileTinyPotato extends TileEntityRenderer { IVertexBuilder buffer = buffers.getBuffer(layer); boolean render = !(name.equals("mami") || name.equals("soaryn") || name.equals("eloraam") && jump != 0); - if (render) + if (render) { potatoModel.render(ms, buffer, light, overlay, r, g, b, 1); + } if (name.equals("kingdaddydmac")) { ms.translate(0.5F, 0F, 0F); potatoModel.render(ms, buffer, light, overlay, r, g, b, 1); @@ -196,7 +206,7 @@ public class RenderTileTinyPotato extends TileEntityRenderer { int halfWidth = mc.fontRenderer.getStringWidth(potato.name.getString()) / 2; float opacity = Minecraft.getInstance().gameSettings.func_216840_a(0.25F); - int opacityRGB = (int)(opacity * 255.0F) << 24; + int opacityRGB = (int) (opacity * 255.0F) << 24; mc.fontRenderer.draw(potato.name.getFormattedText(), -halfWidth, 0, 0x20FFFFFF, false, ms.peek().getModel(), buffers, true, opacityRGB, light); mc.fontRenderer.draw(potato.name.getFormattedText(), -halfWidth, 0, 0xFFFFFFFF, false, ms.peek().getModel(), buffers, false, 0, light); if (name.equals("pahimar") || name.equals("soaryn")) { @@ -219,14 +229,15 @@ public class RenderTileTinyPotato extends TileEntityRenderer { float s = 1F / 3.5F; ms.scale(s, s, s); - for(int i = 0; i < potato.getSizeInventory(); i++) { + for (int i = 0; i < potato.getSizeInventory(); i++) { ItemStack stack = potato.getItemHandler().getStackInSlot(i); - if(stack.isEmpty()) + if (stack.isEmpty()) { continue; + } ms.push(); Direction side = Direction.values()[i]; - if(side.getAxis() != Axis.Y) { + if (side.getAxis() != Axis.Y) { float sideAngle = side.getHorizontalAngle() - facing.getHorizontalAngle(); side = Direction.fromAngle(sideAngle); } @@ -234,59 +245,69 @@ public class RenderTileTinyPotato extends TileEntityRenderer { boolean block = stack.getItem() instanceof BlockItem; boolean mySon = stack.getItem() instanceof ItemBlockTinyPotato; - switch(side) { - case UP: - if(mySon) - ms.translate(0F, 0.6F, 0.5F); - else if(block) - ms.translate(0F, 0.3F, 0.5F); - ms.translate(0F, -0.5F, -0.4F); - break; - case DOWN: - ms.translate(0, -2.3F, -0.88F); - if(mySon) - ms.translate(0, .65F, 0.6F); - else if(block) - ms.translate(0, 1, 0.6F); - break; - case NORTH: - ms.translate(0, -1.9F, 0.02F); - if(mySon) - ms.translate(0, 1, 0.6F); - else if(block) - ms.translate(0, 1, 0.6F); - break; - case SOUTH: - ms.translate(0, -1.6F, -0.89F); - if(mySon) - ms.translate(0, 1.4F, 0.5F); - else if(block) - ms.translate(0, 1.0F, 0.5F); - break; - case EAST: - if(mySon) - ms.translate(-0.4F, 0.65F, 0F); - else if(block) - ms.translate(-0.4F, 0.8F, 0F); - else ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-90F)); - ms.translate(-0.3F, -1.9F, 0.04F); - break; - case WEST: - if(mySon) - ms.translate(1F, 0.65F, 1F); - else if(block) - ms.translate(1F, 0.8F, 1F); - else ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-90F)); - ms.translate(-0.3F, -1.9F, -0.92F); - break; + switch (side) { + case UP: + if (mySon) { + ms.translate(0F, 0.6F, 0.5F); + } else if (block) { + ms.translate(0F, 0.3F, 0.5F); + } + ms.translate(0F, -0.5F, -0.4F); + break; + case DOWN: + ms.translate(0, -2.3F, -0.88F); + if (mySon) { + ms.translate(0, .65F, 0.6F); + } else if (block) { + ms.translate(0, 1, 0.6F); + } + break; + case NORTH: + ms.translate(0, -1.9F, 0.02F); + if (mySon) { + ms.translate(0, 1, 0.6F); + } else if (block) { + ms.translate(0, 1, 0.6F); + } + break; + case SOUTH: + ms.translate(0, -1.6F, -0.89F); + if (mySon) { + ms.translate(0, 1.4F, 0.5F); + } else if (block) { + ms.translate(0, 1.0F, 0.5F); + } + break; + case EAST: + if (mySon) { + ms.translate(-0.4F, 0.65F, 0F); + } else if (block) { + ms.translate(-0.4F, 0.8F, 0F); + } else { + ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-90F)); + } + ms.translate(-0.3F, -1.9F, 0.04F); + break; + case WEST: + if (mySon) { + ms.translate(1F, 0.65F, 1F); + } else if (block) { + ms.translate(1F, 0.8F, 1F); + } else { + ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-90F)); + } + ms.translate(-0.3F, -1.9F, -0.92F); + break; } - if (mySon) + if (mySon) { ms.scale(1.1F, 1.1F, 1.1F); - else if(block) + } else if (block) { ms.scale(0.5F, 0.5F, 0.5F); - if(block && side != Direction.NORTH) + } + if (block && side != Direction.NORTH) { ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(180F)); + } renderItem(ms, buffers, light, overlay, stack); ms.pop(); } diff --git a/src/main/java/vazkii/botania/client/render/tile/TEISR.java b/src/main/java/vazkii/botania/client/render/tile/TEISR.java index 3677dacc4..13d859b0f 100644 --- a/src/main/java/vazkii/botania/client/render/tile/TEISR.java +++ b/src/main/java/vazkii/botania/client/render/tile/TEISR.java @@ -1,7 +1,16 @@ +/* + * This class is 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 + */ package vazkii.botania.client.render.tile; import com.google.common.base.Preconditions; import com.mojang.blaze3d.matrix.MatrixStack; + import net.minecraft.block.Block; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer; @@ -10,26 +19,25 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.LazyValue; -import net.minecraft.util.ResourceLocation; import net.minecraft.util.registry.Registry; public class TEISR extends ItemStackTileEntityRenderer { - private final Block block; - private final LazyValue dummy; + private final Block block; + private final LazyValue dummy; - public TEISR(Block block) { - this.block = Preconditions.checkNotNull(block); - this.dummy = new LazyValue<>(() -> { - TileEntityType type = Registry.BLOCK_ENTITY_TYPE.getValue(block.getRegistryName()).get(); - return type.create(); - }); - } + public TEISR(Block block) { + this.block = Preconditions.checkNotNull(block); + this.dummy = new LazyValue<>(() -> { + TileEntityType type = Registry.BLOCK_ENTITY_TYPE.getValue(block.getRegistryName()).get(); + return type.create(); + }); + } - @Override - public void render(ItemStack stack, MatrixStack ms, IRenderTypeBuffer buffers, int light, int overlay) { - if(stack.getItem() == block.asItem()) { - TileEntityRendererDispatcher.instance.getRenderer(dummy.getValue()) - .render(null, 0, ms, buffers, light, overlay); - } - } + @Override + public void render(ItemStack stack, MatrixStack ms, IRenderTypeBuffer buffers, int light, int overlay) { + if (stack.getItem() == block.asItem()) { + TileEntityRendererDispatcher.instance.getRenderer(dummy.getValue()) + .render(null, 0, ms, buffers, light, overlay); + } + } } diff --git a/src/main/java/vazkii/botania/client/render/world/SkyblockRenderEvents.java b/src/main/java/vazkii/botania/client/render/world/SkyblockRenderEvents.java index 66bccb0ba..9995d0cb7 100644 --- a/src/main/java/vazkii/botania/client/render/world/SkyblockRenderEvents.java +++ b/src/main/java/vazkii/botania/client/render/world/SkyblockRenderEvents.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [18/12/2015, 02:19:53 (GMT)] */ package vazkii.botania.client.render.world; @@ -17,6 +15,7 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.lib.LibMisc; import vazkii.botania.common.world.WorldTypeSkyblock; @@ -27,12 +26,13 @@ public final class SkyblockRenderEvents { @SubscribeEvent public static void onRender(RenderWorldLastEvent event) { World world = Minecraft.getInstance().world; - if(ConfigHandler.CLIENT.enableFancySkybox.get() - && world.getDimension().getType() == DimensionType.OVERWORLD - && (ConfigHandler.CLIENT.enableFancySkyboxInNormalWorlds.get() - || WorldTypeSkyblock.isWorldSkyblock(world))) { - if(!(world.getDimension().getSkyRenderer() instanceof SkyblockSkyRenderer)) + if (ConfigHandler.CLIENT.enableFancySkybox.get() + && world.getDimension().getType() == DimensionType.OVERWORLD + && (ConfigHandler.CLIENT.enableFancySkyboxInNormalWorlds.get() + || WorldTypeSkyblock.isWorldSkyblock(world))) { + if (!(world.getDimension().getSkyRenderer() instanceof SkyblockSkyRenderer)) { world.getDimension().setSkyRenderer(new SkyblockSkyRenderer()); + } } } diff --git a/src/main/java/vazkii/botania/client/render/world/SkyblockSkyRenderer.java b/src/main/java/vazkii/botania/client/render/world/SkyblockSkyRenderer.java index 4d50d6798..40c41cf76 100644 --- a/src/main/java/vazkii/botania/client/render/world/SkyblockSkyRenderer.java +++ b/src/main/java/vazkii/botania/client/render/world/SkyblockSkyRenderer.java @@ -1,32 +1,19 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [18/12/2015, 02:06:56 (GMT)] */ package vazkii.botania.client.render.world; -import com.mojang.blaze3d.platform.GLX; -import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.world.ClientWorld; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3d; import net.minecraftforge.client.IRenderHandler; -import org.lwjgl.opengl.GL11; -import vazkii.botania.client.core.handler.ClientTickHandler; -import vazkii.botania.client.lib.LibResources; -import java.util.Random; +import vazkii.botania.client.lib.LibResources; public class SkyblockSkyRenderer implements IRenderHandler { @@ -58,12 +45,12 @@ public class SkyblockSkyRenderer implements IRenderHandler { float effCelAng = celAng; if(celAng > 0.5) effCelAng = 0.5F - (celAng - 0.5F); - + // === Planets float scale = 20F; float lowA = Math.max(0F, effCelAng - 0.3F) * rain; float a = Math.max(0.1F, lowA); - + GlStateManager.blendFuncSeparate(770, 771, 1, 0); GlStateManager.pushMatrix(); GlStateManager.color4f(1F, 1F, 1F, a * 4 * (1F - insideVoid)); @@ -76,7 +63,7 @@ public class SkyblockSkyRenderer implements IRenderHandler { tessellator.getBuffer().pos(scale, 100.0D, scale).tex(1.0D, 1.0D).endVertex(); tessellator.getBuffer().pos(-scale, 100.0D, scale).tex(0.0D, 1.0D).endVertex(); tessellator.draw(); - + switch(p) { case 0: GlStateManager.rotatef(70F, 1F, 0F, 0F); @@ -101,10 +88,10 @@ public class SkyblockSkyRenderer implements IRenderHandler { } GlStateManager.color4f(1F, 1F, 1F, 1F); GlStateManager.popMatrix(); - + // === Rays Minecraft.getInstance().textureManager.bindTexture(textureSkybox); - + scale = 20F; a = lowA; GlStateManager.pushMatrix(); @@ -120,22 +107,22 @@ public class SkyblockSkyRenderer implements IRenderHandler { double fuzzPer = Math.PI * 10 / angles; float rotSpeed = 1F; float rotSpeedMod = 0.4F; - + for(int p = 0; p < 3; p++) { float baseAngle = rotSpeed * rotSpeedMod * (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks); GlStateManager.rotatef((ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.25F * rotSpeed * rotSpeedMod, 0F, 1F, 0F); - + tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); for(int i = 0; i < angles; i++) { int j = i; if(i % 2 == 0) j--; - + float ang = j * anglePer + baseAngle; double xp = Math.cos(ang * Math.PI / 180F) * scale; double zp = Math.sin(ang * Math.PI / 180F) * scale; double yo = Math.sin(fuzzPer * j) * 1; - + float ut = ang * uPer; if(i % 2 == 0) { tessellator.getBuffer().pos(xp, yo + y0 + y, zp).tex(ut, 1F).endVertex(); @@ -144,10 +131,10 @@ public class SkyblockSkyRenderer implements IRenderHandler { tessellator.getBuffer().pos(xp, yo + y0, zp).tex(ut, 0).endVertex(); tessellator.getBuffer().pos(xp, yo + y0 + y, zp).tex(ut, 1F).endVertex(); } - + } tessellator.draw(); - + switch(p) { case 0: GlStateManager.rotatef(20F, 1F, 0F, 0F); @@ -164,7 +151,7 @@ public class SkyblockSkyRenderer implements IRenderHandler { } } GlStateManager.popMatrix(); - + // === Rainbow GlStateManager.pushMatrix(); GlStateManager.blendFuncSeparate(770, 771, 1, 0); @@ -174,7 +161,7 @@ public class SkyblockSkyRenderer implements IRenderHandler { if(effCelAng1 > 0.25F) effCelAng1 = 1F - effCelAng1; effCelAng1 = 0.25F - Math.min(0.25F, effCelAng1); - + long time = world.getDayTime() + 1000; int day = (int) (time / 24000L); Random rand = new Random(day * 0xFF); @@ -183,18 +170,18 @@ public class SkyblockSkyRenderer implements IRenderHandler { GlStateManager.color4f(1F, 1F, 1F, effCelAng1 * (1F - insideVoid)); GlStateManager.rotatef(angle1, 0F, 1F, 0F); GlStateManager.rotatef(angle2, 0F, 0F, 1F); - + tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); for(int i = 0; i < angles; i++) { int j = i; if(i % 2 == 0) j--; - + float ang = j * anglePer; double xp = Math.cos(ang * Math.PI / 180F) * scale; double zp = Math.sin(ang * Math.PI / 180F) * scale; double yo = 0; - + float ut = ang * uPer; if(i % 2 == 0) { tessellator.getBuffer().pos(xp, yo + y0 + y, zp).tex(ut, 1F).endVertex(); @@ -203,60 +190,60 @@ public class SkyblockSkyRenderer implements IRenderHandler { tessellator.getBuffer().pos(xp, yo + y0, zp).tex(ut, 0).endVertex(); tessellator.getBuffer().pos(xp, yo + y0 + y, zp).tex(ut, 1F).endVertex(); } - + } tessellator.draw(); GlStateManager.popMatrix(); GlStateManager.color4f(1F, 1F, 1F, 1F - insideVoid); GlStateManager.blendFuncSeparate(770, 1, 1, 0); } - + private void renderStars(Minecraft mc, float alpha, float partialTicks) { int starGLCallList = mc.worldRenderer.starGLCallList; net.minecraft.client.renderer.vertex.VertexBuffer starVBO = mc.worldRenderer.starVBO; - + float t = (ClientTickHandler.ticksInGame + partialTicks + 2000) * 0.005F; GlStateManager.pushMatrix(); - + GlStateManager.pushMatrix(); GlStateManager.rotatef(t * 3, 0F, 1F, 0F); GlStateManager.color4f(1F, 1F, 1F, alpha); drawVboOrList(starVBO, starGLCallList); GlStateManager.popMatrix(); - + GlStateManager.pushMatrix(); GlStateManager.rotatef(t, 0F, 1F, 0F); GlStateManager.color4f(0.5F, 1F, 1F, alpha); drawVboOrList(starVBO, starGLCallList); GlStateManager.popMatrix(); - + GlStateManager.pushMatrix(); GlStateManager.rotatef(t * 2, 0F, 1F, 0F); GlStateManager.color4f(1F, 0.75F, 0.75F, alpha); drawVboOrList(starVBO, starGLCallList); GlStateManager.popMatrix(); - + GlStateManager.pushMatrix(); GlStateManager.rotatef(t * 3, 0F, 0F, 1F); GlStateManager.color4f(1F, 1F, 1F, 0.25F * alpha); drawVboOrList(starVBO, starGLCallList); GlStateManager.popMatrix(); - + GlStateManager.pushMatrix(); GlStateManager.rotatef(t, 0F, 0F, 1F); GlStateManager.color4f(0.5F, 1F, 1F, 0.25F * alpha); drawVboOrList(starVBO, starGLCallList); GlStateManager.popMatrix(); - + GlStateManager.pushMatrix(); GlStateManager.rotatef(t * 2, 0F, 0F, 1F); GlStateManager.color4f(1F, 0.75F, 0.75F, 0.25F * alpha); drawVboOrList(starVBO, starGLCallList); GlStateManager.popMatrix(); - + GlStateManager.popMatrix(); } - + // Excised from many occurences in WorldRenderer private void drawVboOrList(net.minecraft.client.renderer.vertex.VertexBuffer vbo, int displayList) { if (GLX.useVbo()) { diff --git a/src/main/java/vazkii/botania/common/Botania.java b/src/main/java/vazkii/botania/common/Botania.java index 019935cae..ccf15ef34 100644 --- a/src/main/java/vazkii/botania/common/Botania.java +++ b/src/main/java/vazkii/botania/common/Botania.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 13, 2014, 6:32:39 PM (GMT)] */ package vazkii.botania.common; @@ -30,20 +28,22 @@ import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent; import net.minecraftforge.fml.event.server.FMLServerStartingEvent; import net.minecraftforge.fml.event.server.FMLServerStoppingEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.ColorHelper; import vazkii.botania.api.capability.FloatingFlowerImpl; import vazkii.botania.api.item.IExoflameHeatable; import vazkii.botania.api.item.IFloatingFlower; import vazkii.botania.client.core.proxy.ClientProxy; -import vazkii.botania.common.advancements.AlfPortalTrigger; import vazkii.botania.common.advancements.AlfPortalBreadTrigger; +import vazkii.botania.common.advancements.AlfPortalTrigger; import vazkii.botania.common.advancements.CorporeaRequestTrigger; +import vazkii.botania.common.advancements.DopplegangerNoArmorTrigger; import vazkii.botania.common.advancements.LokiPlaceTrigger; import vazkii.botania.common.advancements.ManaGunTrigger; -import vazkii.botania.common.advancements.DopplegangerNoArmorTrigger; import vazkii.botania.common.advancements.RelicBindTrigger; import vazkii.botania.common.advancements.UseItemSuccessTrigger; import vazkii.botania.common.block.ModBanners; @@ -53,8 +53,8 @@ import vazkii.botania.common.block.tile.TileEnchanter; import vazkii.botania.common.block.tile.TileTerraPlate; import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex; import vazkii.botania.common.brew.ModBrews; -import vazkii.botania.common.capability.NoopExoflameHeatable; import vazkii.botania.common.capability.NoopCapStorage; +import vazkii.botania.common.capability.NoopExoflameHeatable; import vazkii.botania.common.core.command.CommandSkyblockSpread; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.core.handler.EquipmentHandler; @@ -128,8 +128,8 @@ public class Botania { PacketHandler.init(); ModBrews.init(); - if(Botania.thaumcraftLoaded) { - if(ConfigHandler.COMMON.enableThaumcraftAspects.get()) { + if (Botania.thaumcraftLoaded) { + if (ConfigHandler.COMMON.enableThaumcraftAspects.get()) { // todo 1.13 MinecraftForge.EVENT_BUS.register(TCAspects.class); } ModBrews.initTC(); @@ -141,12 +141,14 @@ public class Botania { EquipmentHandler.init(); - if(Botania.gardenOfGlassLoaded) + if (Botania.gardenOfGlassLoaded) { MinecraftForge.EVENT_BUS.register(SkyblockWorldEvents.class); + } DeferredWorkQueue.runLater(() -> { - if(Botania.gardenOfGlassLoaded) + if (Botania.gardenOfGlassLoaded) { new WorldTypeSkyblock(); + } ModBanners.init(); ColorHelper.init(); @@ -157,37 +159,37 @@ public class Botania { String[][] pat = new String[][] { { - "P_______P", - "_________", - "_________", - "_________", - "_________", - "_________", - "_________", - "_________", - "P_______P", + "P_______P", + "_________", + "_________", + "_________", + "_________", + "_________", + "_________", + "_________", + "P_______P", }, { - "_________", - "_________", - "_________", - "_________", - "____B____", - "_________", - "_________", - "_________", - "_________", + "_________", + "_________", + "_________", + "_________", + "____B____", + "_________", + "_________", + "_________", + "_________", }, { - "_________", - "_________", - "_________", - "___III___", - "___I0I___", - "___III___", - "_________", - "_________", - "_________", + "_________", + "_________", + "_________", + "___III___", + "___I0I___", + "___III___", + "_________", + "_________", + "_________", } }; IStateMatcher sm = StateMatcher.fromPredicate(Blocks.IRON_BLOCK, state -> { @@ -231,7 +233,7 @@ public class Botania { /* todo 1.13 public void init(FMLInitializationEvent event) { FMLInterModComms.sendMessage("projecte", "interdictionblacklist", EntityManaBurst.class.getCanonicalName()); - + for(Block b : new Block[]{ ModBlocks.manaGlass, ModBlocks.elfGlass, ModBlocks.bifrostPerm }) FMLInterModComms.sendMessage("chiselsandbits", "ignoreblocklogic", b.getRegistryName().toString()); } @@ -246,7 +248,7 @@ public class Botania { private void serverAboutToStart(FMLServerAboutToStartEvent event) { String clname = BotaniaAPI.internalHandler.getClass().getName(); String expect = "vazkii.botania.common.core.handler.InternalMethodHandler"; - if(!clname.equals(expect)) { + if (!clname.equals(expect)) { throw new IllegalAccessError("The Botania API internal method handler has been overriden. " + "This will cause crashes and compatibility issues, and that's why it's marked as" + " \"Do not Override\". Whoever had the brilliant idea of overriding it needs to go" @@ -256,8 +258,9 @@ public class Botania { } private void serverStarting(FMLServerStartingEvent event) { - if(Botania.gardenOfGlassLoaded) + if (Botania.gardenOfGlassLoaded) { CommandSkyblockSpread.register(event.getCommandDispatcher()); + } } private void serverStopping(FMLServerStoppingEvent event) { diff --git a/src/main/java/vazkii/botania/common/advancements/AlfPortalBreadTrigger.java b/src/main/java/vazkii/botania/common/advancements/AlfPortalBreadTrigger.java index 541a7cf52..5dc33c52e 100644 --- a/src/main/java/vazkii/botania/common/advancements/AlfPortalBreadTrigger.java +++ b/src/main/java/vazkii/botania/common/advancements/AlfPortalBreadTrigger.java @@ -1,7 +1,16 @@ +/* + * This class is 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 + */ package vazkii.botania.common.advancements; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; + import net.minecraft.advancements.ICriterionInstance; import net.minecraft.advancements.ICriterionTrigger; import net.minecraft.advancements.PlayerAdvancements; @@ -10,9 +19,11 @@ import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.server.ServerWorld; + import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -42,10 +53,10 @@ public class AlfPortalBreadTrigger implements ICriterionTrigger listener) { AlfPortalBreadTrigger.PlayerTracker tracker = this.playerTrackers.get(player); - if(tracker != null) { + if (tracker != null) { tracker.listeners.remove(listener); - if(tracker.listeners.isEmpty()) { + if (tracker.listeners.isEmpty()) { this.playerTrackers.remove(player); } } @@ -73,13 +84,13 @@ public class AlfPortalBreadTrigger implements ICriterionTrigger> list = new ArrayList<>(); - for(ICriterionTrigger.Listener listener : this.listeners) { - if(listener.getCriterionInstance().test(world, portal)) { + for (ICriterionTrigger.Listener listener : this.listeners) { + if (listener.getCriterionInstance().test(world, portal)) { list.add(listener); } } - for(ICriterionTrigger.Listener listener : list) { + for (ICriterionTrigger.Listener listener : list) { listener.grantCriterion(this.playerAdvancements); } } @@ -87,7 +98,7 @@ public class AlfPortalBreadTrigger implements ICriterionTrigger { - public static final ResourceLocation ID = new ResourceLocation(LibMisc.MOD_ID, "open_elf_portal"); - public static final AlfPortalTrigger INSTANCE = new AlfPortalTrigger(); - private final Map playerTrackers = new HashMap<>(); + public static final ResourceLocation ID = new ResourceLocation(LibMisc.MOD_ID, "open_elf_portal"); + public static final AlfPortalTrigger INSTANCE = new AlfPortalTrigger(); + private final Map playerTrackers = new HashMap<>(); - private AlfPortalTrigger() {} + private AlfPortalTrigger() {} - @Nonnull - @Override - public ResourceLocation getId() { - return ID; - } + @Nonnull + @Override + public ResourceLocation getId() { + return ID; + } - @Override - public void addListener(@Nonnull PlayerAdvancements player, @Nonnull ICriterionTrigger.Listener listener) { - this.playerTrackers.computeIfAbsent(player, PlayerTracker::new).listeners.add(listener); - } + @Override + public void addListener(@Nonnull PlayerAdvancements player, @Nonnull ICriterionTrigger.Listener listener) { + this.playerTrackers.computeIfAbsent(player, PlayerTracker::new).listeners.add(listener); + } - @Override - public void removeListener(@Nonnull PlayerAdvancements player, @Nonnull ICriterionTrigger.Listener listener) { - PlayerTracker tracker = this.playerTrackers.get(player); + @Override + public void removeListener(@Nonnull PlayerAdvancements player, @Nonnull ICriterionTrigger.Listener listener) { + PlayerTracker tracker = this.playerTrackers.get(player); - if(tracker != null) { - tracker.listeners.remove(listener); + if (tracker != null) { + tracker.listeners.remove(listener); - if(tracker.listeners.isEmpty()) { - this.playerTrackers.remove(player); - } - } - } + if (tracker.listeners.isEmpty()) { + this.playerTrackers.remove(player); + } + } + } - @Override - public void removeAllListeners(@Nonnull PlayerAdvancements player) { - playerTrackers.remove(player); - } + @Override + public void removeAllListeners(@Nonnull PlayerAdvancements player) { + playerTrackers.remove(player); + } - @Nonnull - @Override - public Instance deserializeInstance(@Nonnull JsonObject json, @Nonnull JsonDeserializationContext context) { - return new Instance(ItemPredicate.deserialize(json.get("wand")), LocationPredicate.deserialize(json.get("location"))); - } + @Nonnull + @Override + public Instance deserializeInstance(@Nonnull JsonObject json, @Nonnull JsonDeserializationContext context) { + return new Instance(ItemPredicate.deserialize(json.get("wand")), LocationPredicate.deserialize(json.get("location"))); + } - static class PlayerTracker { - private final PlayerAdvancements playerAdvancements; - final Set> listeners = new HashSet<>(); + static class PlayerTracker { + private final PlayerAdvancements playerAdvancements; + final Set> listeners = new HashSet<>(); - PlayerTracker(PlayerAdvancements playerAdvancementsIn) { - this.playerAdvancements = playerAdvancementsIn; - } + PlayerTracker(PlayerAdvancements playerAdvancementsIn) { + this.playerAdvancements = playerAdvancementsIn; + } - public void trigger(ServerWorld world, BlockPos pos, ItemStack wand) { - List> list = new ArrayList<>(); + public void trigger(ServerWorld world, BlockPos pos, ItemStack wand) { + List> list = new ArrayList<>(); - for(ICriterionTrigger.Listener listener : this.listeners) { - if(listener.getCriterionInstance().test(world, pos, wand)) { - list.add(listener); - } - } + for (ICriterionTrigger.Listener listener : this.listeners) { + if (listener.getCriterionInstance().test(world, pos, wand)) { + list.add(listener); + } + } - for(ICriterionTrigger.Listener listener : list) { - listener.grantCriterion(this.playerAdvancements); - } - } - } + for (ICriterionTrigger.Listener listener : list) { + listener.grantCriterion(this.playerAdvancements); + } + } + } - public void trigger(ServerPlayerEntity player, ServerWorld world, BlockPos pos, ItemStack wand) { - PlayerTracker tracker = playerTrackers.get(player.getAdvancements()); - if(tracker != null) { - tracker.trigger(world, pos, wand); - } - } + public void trigger(ServerPlayerEntity player, ServerWorld world, BlockPos pos, ItemStack wand) { + PlayerTracker tracker = playerTrackers.get(player.getAdvancements()); + if (tracker != null) { + tracker.trigger(world, pos, wand); + } + } - static class Instance implements ICriterionInstance { - private final ItemPredicate wand; - private final LocationPredicate pos; + static class Instance implements ICriterionInstance { + private final ItemPredicate wand; + private final LocationPredicate pos; - Instance(ItemPredicate predicate, LocationPredicate pos) { - this.wand = predicate; - this.pos = pos; - } + Instance(ItemPredicate predicate, LocationPredicate pos) { + this.wand = predicate; + this.pos = pos; + } - @Nonnull - @Override - public ResourceLocation getId() { - return ID; - } + @Nonnull + @Override + public ResourceLocation getId() { + return ID; + } - boolean test(ServerWorld world, BlockPos pos, ItemStack wand) { - return this.wand.test(wand) && this.pos.test(world, pos.getX(), pos.getY(), pos.getZ()); - } - } + boolean test(ServerWorld world, BlockPos pos, ItemStack wand) { + return this.wand.test(wand) && this.pos.test(world, pos.getX(), pos.getY(), pos.getZ()); + } + } } diff --git a/src/main/java/vazkii/botania/common/advancements/CorporeaRequestTrigger.java b/src/main/java/vazkii/botania/common/advancements/CorporeaRequestTrigger.java index 9b27bb305..d55970215 100644 --- a/src/main/java/vazkii/botania/common/advancements/CorporeaRequestTrigger.java +++ b/src/main/java/vazkii/botania/common/advancements/CorporeaRequestTrigger.java @@ -1,7 +1,16 @@ +/* + * This class is 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 + */ package vazkii.botania.common.advancements; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; + import net.minecraft.advancements.ICriterionInstance; import net.minecraft.advancements.ICriterionTrigger; import net.minecraft.advancements.PlayerAdvancements; @@ -11,9 +20,11 @@ import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.server.ServerWorld; + import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -22,95 +33,95 @@ import java.util.Map; import java.util.Set; public class CorporeaRequestTrigger implements ICriterionTrigger { - public static final ResourceLocation ID = new ResourceLocation(LibMisc.MOD_ID, "corporea_index_request"); - public static final CorporeaRequestTrigger INSTANCE = new CorporeaRequestTrigger(); - private final Map playerTrackers = new HashMap<>(); + public static final ResourceLocation ID = new ResourceLocation(LibMisc.MOD_ID, "corporea_index_request"); + public static final CorporeaRequestTrigger INSTANCE = new CorporeaRequestTrigger(); + private final Map playerTrackers = new HashMap<>(); - private CorporeaRequestTrigger() {} + private CorporeaRequestTrigger() {} - @Nonnull - @Override - public ResourceLocation getId() { - return ID; - } + @Nonnull + @Override + public ResourceLocation getId() { + return ID; + } - @Override - public void addListener(@Nonnull PlayerAdvancements player, @Nonnull ICriterionTrigger.Listener listener) { - this.playerTrackers.computeIfAbsent(player, PlayerTracker::new).listeners.add(listener); - } + @Override + public void addListener(@Nonnull PlayerAdvancements player, @Nonnull ICriterionTrigger.Listener listener) { + this.playerTrackers.computeIfAbsent(player, PlayerTracker::new).listeners.add(listener); + } - @Override - public void removeListener(@Nonnull PlayerAdvancements player, @Nonnull ICriterionTrigger.Listener listener) { - PlayerTracker tracker = this.playerTrackers.get(player); + @Override + public void removeListener(@Nonnull PlayerAdvancements player, @Nonnull ICriterionTrigger.Listener listener) { + PlayerTracker tracker = this.playerTrackers.get(player); - if(tracker != null) { - tracker.listeners.remove(listener); + if (tracker != null) { + tracker.listeners.remove(listener); - if(tracker.listeners.isEmpty()) { - this.playerTrackers.remove(player); - } - } - } + if (tracker.listeners.isEmpty()) { + this.playerTrackers.remove(player); + } + } + } - @Override - public void removeAllListeners(@Nonnull PlayerAdvancements player) { - playerTrackers.remove(player); - } + @Override + public void removeAllListeners(@Nonnull PlayerAdvancements player) { + playerTrackers.remove(player); + } - @Nonnull - @Override - public Instance deserializeInstance(@Nonnull JsonObject json, @Nonnull JsonDeserializationContext context) { - return new Instance(MinMaxBounds.IntBound.fromJson(json.get("extracted")), LocationPredicate.deserialize(json.get("location"))); - } + @Nonnull + @Override + public Instance deserializeInstance(@Nonnull JsonObject json, @Nonnull JsonDeserializationContext context) { + return new Instance(MinMaxBounds.IntBound.fromJson(json.get("extracted")), LocationPredicate.deserialize(json.get("location"))); + } - static class PlayerTracker { - private final PlayerAdvancements playerAdvancements; - final Set> listeners = new HashSet<>(); + static class PlayerTracker { + private final PlayerAdvancements playerAdvancements; + final Set> listeners = new HashSet<>(); - PlayerTracker(PlayerAdvancements playerAdvancementsIn) { - this.playerAdvancements = playerAdvancementsIn; - } + PlayerTracker(PlayerAdvancements playerAdvancementsIn) { + this.playerAdvancements = playerAdvancementsIn; + } - public void trigger(ServerWorld world, BlockPos pos, int count) { - List> list = new ArrayList<>(); + public void trigger(ServerWorld world, BlockPos pos, int count) { + List> list = new ArrayList<>(); - for(Listener listener : this.listeners) { - if(listener.getCriterionInstance().test(world, pos, count)) { - list.add(listener); - } - } + for (Listener listener : this.listeners) { + if (listener.getCriterionInstance().test(world, pos, count)) { + list.add(listener); + } + } - for(Listener listener : list) { - listener.grantCriterion(this.playerAdvancements); - } - } - } + for (Listener listener : list) { + listener.grantCriterion(this.playerAdvancements); + } + } + } - public void trigger(ServerPlayerEntity player, ServerWorld world, BlockPos pos, int count) { - PlayerTracker tracker = playerTrackers.get(player.getAdvancements()); - if(tracker != null) { - tracker.trigger(world, pos, count); - } - } + public void trigger(ServerPlayerEntity player, ServerWorld world, BlockPos pos, int count) { + PlayerTracker tracker = playerTrackers.get(player.getAdvancements()); + if (tracker != null) { + tracker.trigger(world, pos, count); + } + } - static class Instance implements ICriterionInstance { - private final MinMaxBounds.IntBound count; - private final LocationPredicate indexPos; + static class Instance implements ICriterionInstance { + private final MinMaxBounds.IntBound count; + private final LocationPredicate indexPos; - Instance(MinMaxBounds.IntBound count, LocationPredicate indexPos) { - this.count = count; - this.indexPos = indexPos; - } + Instance(MinMaxBounds.IntBound count, LocationPredicate indexPos) { + this.count = count; + this.indexPos = indexPos; + } - @Nonnull - @Override - public ResourceLocation getId() { - return ID; - } + @Nonnull + @Override + public ResourceLocation getId() { + return ID; + } - boolean test(ServerWorld world, BlockPos pos, int count) { - return this.count.test(count) && this.indexPos.test(world, pos.getX(), pos.getY(), pos.getZ()); - } - } + boolean test(ServerWorld world, BlockPos pos, int count) { + return this.count.test(count) && this.indexPos.test(world, pos.getX(), pos.getY(), pos.getZ()); + } + } } diff --git a/src/main/java/vazkii/botania/common/advancements/DopplegangerNoArmorTrigger.java b/src/main/java/vazkii/botania/common/advancements/DopplegangerNoArmorTrigger.java index b24d94c32..5f67aea6c 100644 --- a/src/main/java/vazkii/botania/common/advancements/DopplegangerNoArmorTrigger.java +++ b/src/main/java/vazkii/botania/common/advancements/DopplegangerNoArmorTrigger.java @@ -1,7 +1,16 @@ +/* + * This class is 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 + */ package vazkii.botania.common.advancements; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; + import net.minecraft.advancements.ICriterionInstance; import net.minecraft.advancements.ICriterionTrigger; import net.minecraft.advancements.PlayerAdvancements; @@ -10,10 +19,12 @@ import net.minecraft.advancements.criterion.EntityPredicate; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.util.DamageSource; import net.minecraft.util.ResourceLocation; + import vazkii.botania.common.entity.EntityDoppleganger; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -22,94 +33,94 @@ import java.util.Map; import java.util.Set; public class DopplegangerNoArmorTrigger implements ICriterionTrigger { - public static final ResourceLocation ID = new ResourceLocation(LibMisc.MOD_ID, "gaia_guardian_no_armor"); - public static final DopplegangerNoArmorTrigger INSTANCE = new DopplegangerNoArmorTrigger(); - private final Map playerTrackers = new HashMap<>(); + public static final ResourceLocation ID = new ResourceLocation(LibMisc.MOD_ID, "gaia_guardian_no_armor"); + public static final DopplegangerNoArmorTrigger INSTANCE = new DopplegangerNoArmorTrigger(); + private final Map playerTrackers = new HashMap<>(); - private DopplegangerNoArmorTrigger() {} + private DopplegangerNoArmorTrigger() {} - @Nonnull - @Override - public ResourceLocation getId() { - return ID; - } + @Nonnull + @Override + public ResourceLocation getId() { + return ID; + } - @Override - public void addListener(@Nonnull PlayerAdvancements player, @Nonnull ICriterionTrigger.Listener listener) { - this.playerTrackers.computeIfAbsent(player, DopplegangerNoArmorTrigger.PlayerTracker::new).listeners.add(listener); - } + @Override + public void addListener(@Nonnull PlayerAdvancements player, @Nonnull ICriterionTrigger.Listener listener) { + this.playerTrackers.computeIfAbsent(player, DopplegangerNoArmorTrigger.PlayerTracker::new).listeners.add(listener); + } - @Override - public void removeListener(@Nonnull PlayerAdvancements player, @Nonnull ICriterionTrigger.Listener listener) { - DopplegangerNoArmorTrigger.PlayerTracker tracker = this.playerTrackers.get(player); + @Override + public void removeListener(@Nonnull PlayerAdvancements player, @Nonnull ICriterionTrigger.Listener listener) { + DopplegangerNoArmorTrigger.PlayerTracker tracker = this.playerTrackers.get(player); - if(tracker != null) { - tracker.listeners.remove(listener); + if (tracker != null) { + tracker.listeners.remove(listener); - if(tracker.listeners.isEmpty()) { - this.playerTrackers.remove(player); - } - } - } + if (tracker.listeners.isEmpty()) { + this.playerTrackers.remove(player); + } + } + } - @Override - public void removeAllListeners(@Nonnull PlayerAdvancements player) { - playerTrackers.remove(player); - } + @Override + public void removeAllListeners(@Nonnull PlayerAdvancements player) { + playerTrackers.remove(player); + } - @Nonnull - @Override - public DopplegangerNoArmorTrigger.Instance deserializeInstance(@Nonnull JsonObject json, @Nonnull JsonDeserializationContext context) { - return new DopplegangerNoArmorTrigger.Instance(EntityPredicate.deserialize(json.get("guardian")), DamageSourcePredicate.deserialize(json.get("killing_blow"))); - } + @Nonnull + @Override + public DopplegangerNoArmorTrigger.Instance deserializeInstance(@Nonnull JsonObject json, @Nonnull JsonDeserializationContext context) { + return new DopplegangerNoArmorTrigger.Instance(EntityPredicate.deserialize(json.get("guardian")), DamageSourcePredicate.deserialize(json.get("killing_blow"))); + } - static class PlayerTracker { - private final PlayerAdvancements playerAdvancements; - final Set> listeners = new HashSet<>(); + static class PlayerTracker { + private final PlayerAdvancements playerAdvancements; + final Set> listeners = new HashSet<>(); - PlayerTracker(PlayerAdvancements playerAdvancementsIn) { - this.playerAdvancements = playerAdvancementsIn; - } + PlayerTracker(PlayerAdvancements playerAdvancementsIn) { + this.playerAdvancements = playerAdvancementsIn; + } - public void trigger(ServerPlayerEntity player, EntityDoppleganger guardian, DamageSource src) { - List> list = new ArrayList<>(); + public void trigger(ServerPlayerEntity player, EntityDoppleganger guardian, DamageSource src) { + List> list = new ArrayList<>(); - for(Listener listener : this.listeners) { - if(listener.getCriterionInstance().test(player, guardian, src)) { - list.add(listener); - } - } + for (Listener listener : this.listeners) { + if (listener.getCriterionInstance().test(player, guardian, src)) { + list.add(listener); + } + } - for(Listener listener : list) { - listener.grantCriterion(this.playerAdvancements); - } - } - } + for (Listener listener : list) { + listener.grantCriterion(this.playerAdvancements); + } + } + } - public void trigger(ServerPlayerEntity player, EntityDoppleganger guardian, DamageSource src) { - DopplegangerNoArmorTrigger.PlayerTracker tracker = playerTrackers.get(player.getAdvancements()); - if(tracker != null) { - tracker.trigger(player, guardian, src); - } - } + public void trigger(ServerPlayerEntity player, EntityDoppleganger guardian, DamageSource src) { + DopplegangerNoArmorTrigger.PlayerTracker tracker = playerTrackers.get(player.getAdvancements()); + if (tracker != null) { + tracker.trigger(player, guardian, src); + } + } - static class Instance implements ICriterionInstance { - private final EntityPredicate guardian; - private final DamageSourcePredicate killingBlow; + static class Instance implements ICriterionInstance { + private final EntityPredicate guardian; + private final DamageSourcePredicate killingBlow; - Instance(EntityPredicate count, DamageSourcePredicate indexPos) { - this.guardian = count; - this.killingBlow = indexPos; - } + Instance(EntityPredicate count, DamageSourcePredicate indexPos) { + this.guardian = count; + this.killingBlow = indexPos; + } - @Nonnull - @Override - public ResourceLocation getId() { - return ID; - } + @Nonnull + @Override + public ResourceLocation getId() { + return ID; + } - boolean test(ServerPlayerEntity player, EntityDoppleganger guardian, DamageSource src) { - return this.guardian.test(player, guardian) && this.killingBlow.test(player, src); - } - } + boolean test(ServerPlayerEntity player, EntityDoppleganger guardian, DamageSource src) { + return this.guardian.test(player, guardian) && this.killingBlow.test(player, src); + } + } } diff --git a/src/main/java/vazkii/botania/common/advancements/LokiPlaceTrigger.java b/src/main/java/vazkii/botania/common/advancements/LokiPlaceTrigger.java index 34ecd8623..8e8c7e15c 100644 --- a/src/main/java/vazkii/botania/common/advancements/LokiPlaceTrigger.java +++ b/src/main/java/vazkii/botania/common/advancements/LokiPlaceTrigger.java @@ -1,7 +1,16 @@ +/* + * This class is 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 + */ package vazkii.botania.common.advancements; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; + import net.minecraft.advancements.ICriterionInstance; import net.minecraft.advancements.ICriterionTrigger; import net.minecraft.advancements.PlayerAdvancements; @@ -11,9 +20,11 @@ import net.minecraft.advancements.criterion.MinMaxBounds; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; + import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -43,10 +54,10 @@ public class LokiPlaceTrigger implements ICriterionTrigger listener) { LokiPlaceTrigger.PlayerTracker tracker = this.playerTrackers.get(player); - if(tracker != null) { + if (tracker != null) { tracker.listeners.remove(listener); - if(tracker.listeners.isEmpty()) { + if (tracker.listeners.isEmpty()) { this.playerTrackers.remove(player); } } @@ -74,13 +85,13 @@ public class LokiPlaceTrigger implements ICriterionTrigger> list = new ArrayList<>(); - for(ICriterionTrigger.Listener listener : this.listeners) { - if(listener.getCriterionInstance().test(player, ring, blocksPlaced)) { + for (ICriterionTrigger.Listener listener : this.listeners) { + if (listener.getCriterionInstance().test(player, ring, blocksPlaced)) { list.add(listener); } } - for(ICriterionTrigger.Listener listener : list) { + for (ICriterionTrigger.Listener listener : list) { listener.grantCriterion(this.playerAdvancements); } } @@ -88,7 +99,7 @@ public class LokiPlaceTrigger implements ICriterionTrigger listener) { ManaGunTrigger.PlayerTracker tracker = this.playerTrackers.get(player); - if(tracker != null) { + if (tracker != null) { tracker.listeners.remove(listener); - if(tracker.listeners.isEmpty()) { + if (tracker.listeners.isEmpty()) { this.playerTrackers.remove(player); } } @@ -78,13 +89,13 @@ public class ManaGunTrigger implements ICriterionTrigger> list = new ArrayList<>(); - for(Listener listener : this.listeners) { - if(listener.getCriterionInstance().test(stack, player)) { + for (Listener listener : this.listeners) { + if (listener.getCriterionInstance().test(stack, player)) { list.add(listener); } } - for(Listener listener : list) { + for (Listener listener : list) { listener.grantCriterion(this.playerAdvancements); } } @@ -92,7 +103,7 @@ public class ManaGunTrigger implements ICriterionTrigger listener) { PlayerTracker tracker = this.playerTrackers.get(player); - if(tracker != null) { + if (tracker != null) { tracker.listeners.remove(listener); - if(tracker.listeners.isEmpty()) { + if (tracker.listeners.isEmpty()) { this.playerTrackers.remove(player); } } @@ -72,13 +83,13 @@ public class RelicBindTrigger implements ICriterionTrigger> list = new ArrayList<>(); - for(Listener listener : this.listeners) { - if(listener.getCriterionInstance().test(stack)) { + for (Listener listener : this.listeners) { + if (listener.getCriterionInstance().test(stack)) { list.add(listener); } } - for(Listener listener : list) { + for (Listener listener : list) { listener.grantCriterion(this.playerAdvancements); } } @@ -86,7 +97,7 @@ public class RelicBindTrigger implements ICriterionTrigger { - public static final ResourceLocation ID = new ResourceLocation(LibMisc.MOD_ID, "use_item_success"); - public static final UseItemSuccessTrigger INSTANCE = new UseItemSuccessTrigger(); - private final Map playerTrackers = new HashMap<>(); + public static final ResourceLocation ID = new ResourceLocation(LibMisc.MOD_ID, "use_item_success"); + public static final UseItemSuccessTrigger INSTANCE = new UseItemSuccessTrigger(); + private final Map playerTrackers = new HashMap<>(); - private UseItemSuccessTrigger() {} + private UseItemSuccessTrigger() {} - @Nonnull - @Override - public ResourceLocation getId() { - return ID; - } + @Nonnull + @Override + public ResourceLocation getId() { + return ID; + } - @Override - public void addListener(@Nonnull PlayerAdvancements player, @Nonnull ICriterionTrigger.Listener listener) { - this.playerTrackers.computeIfAbsent(player, UseItemSuccessTrigger.PlayerTracker::new).listeners.add(listener); - } + @Override + public void addListener(@Nonnull PlayerAdvancements player, @Nonnull ICriterionTrigger.Listener listener) { + this.playerTrackers.computeIfAbsent(player, UseItemSuccessTrigger.PlayerTracker::new).listeners.add(listener); + } - @Override - public void removeListener(@Nonnull PlayerAdvancements player, @Nonnull ICriterionTrigger.Listener listener) { - UseItemSuccessTrigger.PlayerTracker tracker = this.playerTrackers.get(player); + @Override + public void removeListener(@Nonnull PlayerAdvancements player, @Nonnull ICriterionTrigger.Listener listener) { + UseItemSuccessTrigger.PlayerTracker tracker = this.playerTrackers.get(player); - if(tracker != null) { - tracker.listeners.remove(listener); + if (tracker != null) { + tracker.listeners.remove(listener); - if(tracker.listeners.isEmpty()) { - this.playerTrackers.remove(player); - } - } - } + if (tracker.listeners.isEmpty()) { + this.playerTrackers.remove(player); + } + } + } - @Override - public void removeAllListeners(@Nonnull PlayerAdvancements player) { - playerTrackers.remove(player); - } + @Override + public void removeAllListeners(@Nonnull PlayerAdvancements player) { + playerTrackers.remove(player); + } - @Nonnull - @Override - public UseItemSuccessTrigger.Instance deserializeInstance(@Nonnull JsonObject json, @Nonnull JsonDeserializationContext context) { - return new UseItemSuccessTrigger.Instance(ItemPredicate.deserialize(json.get("item")), LocationPredicate.deserialize(json.get("location"))); - } + @Nonnull + @Override + public UseItemSuccessTrigger.Instance deserializeInstance(@Nonnull JsonObject json, @Nonnull JsonDeserializationContext context) { + return new UseItemSuccessTrigger.Instance(ItemPredicate.deserialize(json.get("item")), LocationPredicate.deserialize(json.get("location"))); + } - static class PlayerTracker { - private final PlayerAdvancements playerAdvancements; - final Set> listeners = new HashSet<>(); + static class PlayerTracker { + private final PlayerAdvancements playerAdvancements; + final Set> listeners = new HashSet<>(); - PlayerTracker(PlayerAdvancements playerAdvancementsIn) { - this.playerAdvancements = playerAdvancementsIn; - } + PlayerTracker(PlayerAdvancements playerAdvancementsIn) { + this.playerAdvancements = playerAdvancementsIn; + } - public void trigger(ServerPlayerEntity player, ItemStack stack, ServerWorld world, double x, double y, double z) { - List> list = new ArrayList<>(); + public void trigger(ServerPlayerEntity player, ItemStack stack, ServerWorld world, double x, double y, double z) { + List> list = new ArrayList<>(); - for(Listener listener : this.listeners) { - if(listener.getCriterionInstance().test(stack, world, x, y, z)) { - list.add(listener); - } - } + for (Listener listener : this.listeners) { + if (listener.getCriterionInstance().test(stack, world, x, y, z)) { + list.add(listener); + } + } - for(Listener listener : list) { - listener.grantCriterion(this.playerAdvancements); - } - } - } + for (Listener listener : list) { + listener.grantCriterion(this.playerAdvancements); + } + } + } - public void trigger(ServerPlayerEntity player, ItemStack stack, ServerWorld world, double x, double y, double z) { - UseItemSuccessTrigger.PlayerTracker tracker = playerTrackers.get(player.getAdvancements()); - if(tracker != null) { - tracker.trigger(player, stack, world, x, y, z); - } - } + public void trigger(ServerPlayerEntity player, ItemStack stack, ServerWorld world, double x, double y, double z) { + UseItemSuccessTrigger.PlayerTracker tracker = playerTrackers.get(player.getAdvancements()); + if (tracker != null) { + tracker.trigger(player, stack, world, x, y, z); + } + } - static class Instance implements ICriterionInstance { - private final ItemPredicate item; - private final LocationPredicate location; + static class Instance implements ICriterionInstance { + private final ItemPredicate item; + private final LocationPredicate location; - Instance(ItemPredicate count, LocationPredicate indexPos) { - this.item = count; - this.location = indexPos; - } + Instance(ItemPredicate count, LocationPredicate indexPos) { + this.item = count; + this.location = indexPos; + } - @Nonnull - @Override - public ResourceLocation getId() { - return ID; - } + @Nonnull + @Override + public ResourceLocation getId() { + return ID; + } - boolean test(ItemStack stack, ServerWorld world, double x, double y, double z) { - return this.item.test(stack) && this.location.test(world, x, y, z); - } - } + boolean test(ItemStack stack, ServerWorld world, double x, double y, double z) { + return this.item.test(stack) && this.location.test(world, x, y, z); + } + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockAlfPortal.java b/src/main/java/vazkii/botania/common/block/BlockAlfPortal.java index 34c521d7b..11592331c 100644 --- a/src/main/java/vazkii/botania/common/block/BlockAlfPortal.java +++ b/src/main/java/vazkii/botania/common/block/BlockAlfPortal.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 9, 2014, 7:17:46 PM (GMT)] */ package vazkii.botania.common.block; @@ -22,6 +20,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; + import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.api.state.enums.AlfPortalState; import vazkii.botania.api.wand.IWandable; @@ -56,7 +55,7 @@ public class BlockAlfPortal extends BlockMod implements IWandable { @Override public boolean onUsedByWand(PlayerEntity player, ItemStack stack, World world, BlockPos pos, Direction side) { boolean did = ((TileAlfPortal) world.getTileEntity(pos)).onWanded(); - if(!world.isRemote && did && player instanceof ServerPlayerEntity) { + if (!world.isRemote && did && player instanceof ServerPlayerEntity) { AlfPortalTrigger.INSTANCE.trigger((ServerPlayerEntity) player, (ServerWorld) world, pos, stack); } return did; diff --git a/src/main/java/vazkii/botania/common/block/BlockAltGrass.java b/src/main/java/vazkii/botania/common/block/BlockAltGrass.java index 56a933f3c..42f1dbacf 100644 --- a/src/main/java/vazkii/botania/common/block/BlockAltGrass.java +++ b/src/main/java/vazkii/botania/common/block/BlockAltGrass.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [17/11/2015, 18:33:30 (GMT)] */ package vazkii.botania.common.block; @@ -30,9 +28,11 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.PlantType; import net.minecraftforge.common.ToolType; + import vazkii.botania.client.fx.SparkleParticleData; import javax.annotation.Nonnull; + import java.util.Random; public class BlockAltGrass extends BlockMod { @@ -57,28 +57,29 @@ public class BlockAltGrass extends BlockMod { public boolean isToolEffective(BlockState state, ToolType tool) { return tool.equals(ToolType.SHOVEL); } - + @Override public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { ItemStack held = player.getHeldItem(hand); - if(held.getItem() instanceof HoeItem && world.isAirBlock(pos.up())) { + if (held.getItem() instanceof HoeItem && world.isAirBlock(pos.up())) { held.damageItem(1, player, e -> e.sendBreakAnimation(hand)); world.setBlockState(pos, Blocks.FARMLAND.getDefaultState()); return ActionResultType.SUCCESS; } - + return ActionResultType.PASS; } - + @Override public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random rand) { - if(!world.isRemote && state.getBlock() == this && world.getLight(pos.up()) >= 9) { - for(int l = 0; l < 4; ++l) { + if (!world.isRemote && state.getBlock() == this && world.getLight(pos.up()) >= 9) { + for (int l = 0; l < 4; ++l) { BlockPos pos1 = pos.add(rand.nextInt(3) - 1, rand.nextInt(5) - 3, rand.nextInt(3) - 1); BlockPos pos1up = pos1.up(); - if(world.getBlockState(pos1).getBlock() == Blocks.DIRT && world.getLight(pos1up) >= 4 && world.getBlockState(pos1up).getOpacity(world, pos1up) <= 2) + if (world.getBlockState(pos1).getBlock() == Blocks.DIRT && world.getLight(pos1up) >= 4 && world.getBlockState(pos1up).getOpacity(world, pos1up) <= 2) { world.setBlockState(pos1, getDefaultState()); + } } } } @@ -92,7 +93,7 @@ public class BlockAltGrass extends BlockMod { @OnlyIn(Dist.CLIENT) @Override public void animateTick(BlockState state, World world, BlockPos pos, Random r) { - switch(variant) { + switch (variant) { case DRY: break; case GOLDEN: @@ -100,25 +101,25 @@ public class BlockAltGrass extends BlockMod { case VIVID: break; case SCORCHED: - if(r.nextInt(80) == 0) + if (r.nextInt(80) == 0) { world.addParticle(ParticleTypes.FLAME, pos.getX() + r.nextFloat(), pos.getY() + 1.1, pos.getZ() + r.nextFloat(), 0, 0, 0); + } break; case INFUSED: - if(r.nextInt(100) == 0) { - SparkleParticleData data = SparkleParticleData.sparkle(r.nextFloat() * 0.2F + 1F, 0F, 1F, 1F, 5); - world.addParticle(data, pos.getX() + r.nextFloat(), pos.getY() + 1.05, pos.getZ() + r.nextFloat(), 0, 0, 0); - } + if (r.nextInt(100) == 0) { + SparkleParticleData data = SparkleParticleData.sparkle(r.nextFloat() * 0.2F + 1F, 0F, 1F, 1F, 5); + world.addParticle(data, pos.getX() + r.nextFloat(), pos.getY() + 1.05, pos.getZ() + r.nextFloat(), 0, 0, 0); + } break; case MUTATED: - if(r.nextInt(100) == 0) { - if(r.nextInt(100) > 25) { - SparkleParticleData data = SparkleParticleData.sparkle(r.nextFloat() * 0.2F + 1F, 1F, 0F, 1F, 5); - world.addParticle(data, pos.getX() + r.nextFloat(), pos.getY() + 1.05, pos.getZ() + r.nextFloat(), 0, 0, 0); - } - else { - SparkleParticleData data = SparkleParticleData.sparkle(r.nextFloat() * 0.2F + 1F, 1F, 1F, 0F, 5); - world.addParticle(data, pos.getX() + r.nextFloat(), pos.getY() + 1.05, pos.getZ() + r.nextFloat(), 0, 0, 0); - } + if (r.nextInt(100) == 0) { + if (r.nextInt(100) > 25) { + SparkleParticleData data = SparkleParticleData.sparkle(r.nextFloat() * 0.2F + 1F, 1F, 0F, 1F, 5); + world.addParticle(data, pos.getX() + r.nextFloat(), pos.getY() + 1.05, pos.getZ() + r.nextFloat(), 0, 0, 0); + } else { + SparkleParticleData data = SparkleParticleData.sparkle(r.nextFloat() * 0.2F + 1F, 1F, 1F, 0F, 5); + world.addParticle(data, pos.getX() + r.nextFloat(), pos.getY() + 1.05, pos.getZ() + r.nextFloat(), 0, 0, 0); + } } break; } diff --git a/src/main/java/vazkii/botania/common/block/BlockAltar.java b/src/main/java/vazkii/botania/common/block/BlockAltar.java index 4798f2f56..66a33259c 100644 --- a/src/main/java/vazkii/botania/common/block/BlockAltar.java +++ b/src/main/java/vazkii/botania/common/block/BlockAltar.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 21, 2014, 7:48:54 PM (GMT)] */ package vazkii.botania.common.block; @@ -29,15 +27,13 @@ import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.world.IBlockReader; -import net.minecraft.world.ILightReader; import net.minecraft.world.World; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fluids.FluidAttributes; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.items.ItemHandlerHelper; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.common.Botania; @@ -85,10 +81,11 @@ public class BlockAltar extends BlockMod { @Override public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) { - if(!world.isRemote && entity instanceof ItemEntity) { + if (!world.isRemote && entity instanceof ItemEntity) { TileAltar tile = (TileAltar) world.getTileEntity(pos); - if(tile.collideEntityItem((ItemEntity) entity)) + if (tile.collideEntityItem((ItemEntity) entity)) { VanillaPacketDispatcher.dispatchTEToNearbyPlayers(tile); + } } } @@ -106,21 +103,21 @@ public class BlockAltar extends BlockMod { public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { TileAltar tile = (TileAltar) world.getTileEntity(pos); ItemStack stack = player.getHeldItem(hand); - if(player.isSneaking()) { + if (player.isSneaking()) { InventoryHelper.withdrawFromInventory(tile, player); VanillaPacketDispatcher.dispatchTEToNearbyPlayers(tile); return ActionResultType.SUCCESS; - } else if(tile.isEmpty() && tile.getFluid() == Fluids.WATER && stack.isEmpty()) { + } else if (tile.isEmpty() && tile.getFluid() == Fluids.WATER && stack.isEmpty()) { tile.trySetLastRecipe(player); return ActionResultType.SUCCESS; - } - else { - if(!stack.isEmpty() && (isValidWaterContainer(stack) || stack.getItem() == ModItems.waterRod && ManaItemHandler.requestManaExact(stack, player, ItemWaterRod.COST, false))) { - if(tile.getFluid() == Fluids.EMPTY) { - if(stack.getItem() == ModItems.waterRod) + } else { + if (!stack.isEmpty() && (isValidWaterContainer(stack) || stack.getItem() == ModItems.waterRod && ManaItemHandler.requestManaExact(stack, player, ItemWaterRod.COST, false))) { + if (tile.getFluid() == Fluids.EMPTY) { + if (stack.getItem() == ModItems.waterRod) { ManaItemHandler.requestManaExact(stack, player, ItemWaterRod.COST, true); - else if(!player.abilities.isCreativeMode) + } else if (!player.abilities.isCreativeMode) { player.setHeldItem(hand, drain(Fluids.WATER, stack)); + } tile.setFluid(Fluids.WATER); world.updateComparatorOutputLevel(pos, this); @@ -128,20 +125,21 @@ public class BlockAltar extends BlockMod { } return ActionResultType.SUCCESS; - } else if(!stack.isEmpty() && stack.getItem() == Items.LAVA_BUCKET) { - if(!player.abilities.isCreativeMode) + } else if (!stack.isEmpty() && stack.getItem() == Items.LAVA_BUCKET) { + if (!player.abilities.isCreativeMode) { player.setHeldItem(hand, drain(Fluids.LAVA, stack)); + } tile.setFluid(Fluids.LAVA); world.updateComparatorOutputLevel(pos, this); world.getChunkProvider().getLightManager().checkBlock(pos); return ActionResultType.SUCCESS; - } else if(!stack.isEmpty() && stack.getItem() == Items.BUCKET && tile.getFluid() != Fluids.EMPTY && !Botania.gardenOfGlassLoaded) { + } else if (!stack.isEmpty() && stack.getItem() == Items.BUCKET && tile.getFluid() != Fluids.EMPTY && !Botania.gardenOfGlassLoaded) { ItemStack bucket = new ItemStack(tile.getFluid().getFilledBucket()); - if(stack.getCount() == 1) + if (stack.getCount() == 1) { player.setHeldItem(hand, bucket); - else { + } else { ItemHandlerHelper.giveItemToPlayer(player, bucket); stack.shrink(1); } @@ -159,20 +157,22 @@ public class BlockAltar extends BlockMod { @Override public void fillWithRain(World world, BlockPos pos) { - if(world.rand.nextInt(20) == 1) { + if (world.rand.nextInt(20) == 1) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileAltar) { + if (tile instanceof TileAltar) { TileAltar altar = (TileAltar) tile; - if(altar.getFluid() == Fluids.EMPTY) + if (altar.getFluid() == Fluids.EMPTY) { altar.setFluid(Fluids.WATER); + } world.updateComparatorOutputLevel(pos, this); } } } private boolean isValidWaterContainer(ItemStack stack) { - if(stack.isEmpty() || stack.getCount() != 1) + if (stack.isEmpty() || stack.getCount() != 1) { return false; + } return stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY).map(handler -> { FluidStack simulate = handler.drain(new FluidStack(Fluids.WATER, FluidAttributes.BUCKET_VOLUME), IFluidHandler.FluidAction.SIMULATE); diff --git a/src/main/java/vazkii/botania/common/block/BlockAnimatedTorch.java b/src/main/java/vazkii/botania/common/block/BlockAnimatedTorch.java index 5d0374658..8d1d3772c 100644 --- a/src/main/java/vazkii/botania/common/block/BlockAnimatedTorch.java +++ b/src/main/java/vazkii/botania/common/block/BlockAnimatedTorch.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [28/09/2016, 16:14:04 (GMT)] */ package vazkii.botania.common.block; @@ -29,6 +27,7 @@ import net.minecraft.world.IWorld; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.api.item.IHourglassTrigger; import vazkii.botania.api.mana.IManaTrigger; @@ -48,14 +47,14 @@ public class BlockAnimatedTorch extends BlockMod implements IWandable, IManaTrig @Override public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockRayTraceResult hit) { - if(hand == Hand.MAIN_HAND && playerIn.isSneaking() && playerIn.getHeldItem(hand).isEmpty()) { + if (hand == Hand.MAIN_HAND && playerIn.isSneaking() && playerIn.getHeldItem(hand).isEmpty()) { ((TileAnimatedTorch) worldIn.getTileEntity(pos)).handRotate(); return ActionResultType.SUCCESS; } return ActionResultType.PASS; } - + @Override public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, LivingEntity entity, ItemStack stack) { ((TileAnimatedTorch) world.getTileEntity(pos)).onPlace(entity); @@ -63,8 +62,9 @@ public class BlockAnimatedTorch extends BlockMod implements IWandable, IManaTrig @Override public void onBurstCollision(IManaBurst burst, World world, BlockPos pos) { - if(!burst.isFake()) + if (!burst.isFake()) { ((TileAnimatedTorch) world.getTileEntity(pos)).toggle(); + } } @Override @@ -98,11 +98,13 @@ public class BlockAnimatedTorch extends BlockMod implements IWandable, IManaTrig public int getWeakPower(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) { TileAnimatedTorch tile = (TileAnimatedTorch) blockAccess.getTileEntity(pos); - if(tile.rotating) + if (tile.rotating) { return 0; + } - if(TileAnimatedTorch.SIDES[tile.side] == side) + if (TileAnimatedTorch.SIDES[tile.side] == side) { return 15; + } return 0; } diff --git a/src/main/java/vazkii/botania/common/block/BlockAvatar.java b/src/main/java/vazkii/botania/common/block/BlockAvatar.java index 381be72ba..3296113f9 100644 --- a/src/main/java/vazkii/botania/common/block/BlockAvatar.java +++ b/src/main/java/vazkii/botania/common/block/BlockAvatar.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Oct 24, 2015, 3:15:11 PM (GMT)] */ package vazkii.botania.common.block; @@ -31,6 +29,7 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.items.ItemHandlerHelper; + import vazkii.botania.api.item.IAvatarWieldable; import vazkii.botania.common.block.tile.TileAvatar; import vazkii.botania.common.block.tile.TileSimpleInventory; @@ -52,9 +51,11 @@ public class BlockAvatar extends BlockMod { @Nonnull @Override public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext ctx) { - if(state.get(BlockStateProperties.HORIZONTAL_FACING).getAxis() == Direction.Axis.X) + if (state.get(BlockStateProperties.HORIZONTAL_FACING).getAxis() == Direction.Axis.X) { return X_AABB; - else return Z_AABB; + } else { + return Z_AABB; + } } @Override @@ -67,11 +68,11 @@ public class BlockAvatar extends BlockMod { TileAvatar avatar = (TileAvatar) world.getTileEntity(pos); ItemStack stackOnAvatar = avatar.getItemHandler().getStackInSlot(0); ItemStack stackOnPlayer = player.getHeldItem(hand); - if(!stackOnAvatar.isEmpty()) { + if (!stackOnAvatar.isEmpty()) { avatar.getItemHandler().setStackInSlot(0, ItemStack.EMPTY); ItemHandlerHelper.giveItemToPlayer(player, stackOnAvatar); return ActionResultType.SUCCESS; - } else if(!stackOnPlayer.isEmpty() && stackOnPlayer.getItem() instanceof IAvatarWieldable) { + } else if (!stackOnPlayer.isEmpty() && stackOnPlayer.getItem() instanceof IAvatarWieldable) { avatar.getItemHandler().setStackInSlot(0, stackOnPlayer.split(1)); return ActionResultType.SUCCESS; } @@ -81,7 +82,7 @@ public class BlockAvatar extends BlockMod { @Override public void onReplaced(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState newstate, boolean isMoving) { - if(state.getBlock() != newstate.getBlock()) { + if (state.getBlock() != newstate.getBlock()) { TileSimpleInventory inv = (TileSimpleInventory) world.getTileEntity(pos); InventoryHelper.dropInventory(inv, world, state, pos); super.onReplaced(state, world, pos, newstate, isMoving); diff --git a/src/main/java/vazkii/botania/common/block/BlockBifrost.java b/src/main/java/vazkii/botania/common/block/BlockBifrost.java index 9c84c0386..36ce5775e 100644 --- a/src/main/java/vazkii/botania/common/block/BlockBifrost.java +++ b/src/main/java/vazkii/botania/common/block/BlockBifrost.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 20, 2014, 8:23:17 PM (GMT)] */ package vazkii.botania.common.block; @@ -17,6 +15,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.IBlockReader; + import vazkii.botania.common.block.tile.TileBifrost; import vazkii.botania.common.item.ModItems; diff --git a/src/main/java/vazkii/botania/common/block/BlockBifrostPerm.java b/src/main/java/vazkii/botania/common/block/BlockBifrostPerm.java index f1fe02f36..5b8d0b12f 100644 --- a/src/main/java/vazkii/botania/common/block/BlockBifrostPerm.java +++ b/src/main/java/vazkii/botania/common/block/BlockBifrostPerm.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 28, 2015, 10:46:20 PM (GMT)] */ package vazkii.botania.common.block; @@ -16,6 +14,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.client.fx.SparkleParticleData; import java.util.Random; diff --git a/src/main/java/vazkii/botania/common/block/BlockCacophonium.java b/src/main/java/vazkii/botania/common/block/BlockCacophonium.java index a3b839e77..3d8e2aefb 100644 --- a/src/main/java/vazkii/botania/common/block/BlockCacophonium.java +++ b/src/main/java/vazkii/botania/common/block/BlockCacophonium.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 23, 2015, 7:23:26 PM (GMT)] */ package vazkii.botania.common.block; @@ -18,6 +16,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; + import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.common.block.tile.TileCacophonium; @@ -39,20 +38,22 @@ public class BlockCacophonium extends BlockMod { boolean power = world.getRedstonePowerFromNeighbors(pos) > 0 || world.getRedstonePowerFromNeighbors(pos.up()) > 0; boolean powered = state.get(BotaniaStateProps.POWERED); - if(power && !powered) { + if (power && !powered) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileCacophonium) + if (tile instanceof TileCacophonium) { ((TileCacophonium) tile).annoyDirewolf(); + } world.setBlockState(pos, state.with(BotaniaStateProps.POWERED, true), 4); - } else if(!power && powered) + } else if (!power && powered) { world.setBlockState(pos, state.with(BotaniaStateProps.POWERED, false), 4); + } } @Override public void onReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) { if (state.getBlock() != newState.getBlock()) { TileEntity te = world.getTileEntity(pos); - if(te instanceof TileCacophonium) { + if (te instanceof TileCacophonium) { InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), ((TileCacophonium) te).stack); } super.onReplaced(state, world, pos, newState, isMoving); diff --git a/src/main/java/vazkii/botania/common/block/BlockCell.java b/src/main/java/vazkii/botania/common/block/BlockCell.java index 4e182c796..040df980c 100644 --- a/src/main/java/vazkii/botania/common/block/BlockCell.java +++ b/src/main/java/vazkii/botania/common/block/BlockCell.java @@ -1,18 +1,17 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 6, 2015, 4:03:56 PM (GMT)] */ package vazkii.botania.common.block; import net.minecraft.block.BlockState; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockReader; + import vazkii.botania.common.block.tile.TileCell; import javax.annotation.Nonnull; diff --git a/src/main/java/vazkii/botania/common/block/BlockCocoon.java b/src/main/java/vazkii/botania/common/block/BlockCocoon.java index adb744ed1..8fa82b2f1 100644 --- a/src/main/java/vazkii/botania/common/block/BlockCocoon.java +++ b/src/main/java/vazkii/botania/common/block/BlockCocoon.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 8, 2015, 4:29:01 PM (GMT)] */ package vazkii.botania.common.block; @@ -29,6 +27,7 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; + import vazkii.botania.common.block.tile.TileCocoon; import javax.annotation.Nonnull; @@ -52,16 +51,17 @@ public class BlockCocoon extends BlockMod { public BlockRenderType getRenderType(BlockState state) { return BlockRenderType.ENTITYBLOCK_ANIMATED; } - + @Override public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity e) { - if(!world.isRemote && e instanceof ItemEntity) { + if (!world.isRemote && e instanceof ItemEntity) { ItemEntity item = (ItemEntity) e; ItemStack stack = item.getItem(); addStack(world, pos, stack, false); - - if(stack.isEmpty()) + + if (stack.isEmpty()) { item.remove(); + } } } @@ -70,21 +70,23 @@ public class BlockCocoon extends BlockMod { ItemStack stack = player.getHeldItem(hand); return addStack(world, pos, stack, player.abilities.isCreativeMode); } - + private ActionResultType addStack(World world, BlockPos pos, ItemStack stack, boolean creative) { TileCocoon cocoon = (TileCocoon) world.getTileEntity(pos); Item item = stack.getItem(); - - if(cocoon != null && (item == Items.EMERALD || item == Items.CHORUS_FRUIT)) { - if(!world.isRemote) { - if(item == Items.EMERALD && cocoon.emeraldsGiven < TileCocoon.MAX_EMERALDS) { - if(!creative) + + if (cocoon != null && (item == Items.EMERALD || item == Items.CHORUS_FRUIT)) { + if (!world.isRemote) { + if (item == Items.EMERALD && cocoon.emeraldsGiven < TileCocoon.MAX_EMERALDS) { + if (!creative) { stack.shrink(1); + } cocoon.emeraldsGiven++; ((ServerWorld) world).spawnParticle(ParticleTypes.HAPPY_VILLAGER, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 1, 0, 0, 0, 0.5); - } else if(item == Items.CHORUS_FRUIT && cocoon.chorusFruitGiven < TileCocoon.MAX_CHORUS_FRUITS) { - if(!creative) + } else if (item == Items.CHORUS_FRUIT && cocoon.chorusFruitGiven < TileCocoon.MAX_CHORUS_FRUITS) { + if (!creative) { stack.shrink(1); + } cocoon.chorusFruitGiven++; ((ServerWorld) world).spawnParticle(ParticleTypes.PORTAL, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, 32, 0, 0, 0, 0.5); } @@ -92,7 +94,7 @@ public class BlockCocoon extends BlockMod { return ActionResultType.SUCCESS; } - + return ActionResultType.PASS; } diff --git a/src/main/java/vazkii/botania/common/block/BlockCraftyCrate.java b/src/main/java/vazkii/botania/common/block/BlockCraftyCrate.java index f5ce32cba..0b97fdb3a 100644 --- a/src/main/java/vazkii/botania/common/block/BlockCraftyCrate.java +++ b/src/main/java/vazkii/botania/common/block/BlockCraftyCrate.java @@ -1,6 +1,13 @@ +/* + * This class is 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 + */ package vazkii.botania.common.block; -import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; @@ -13,6 +20,7 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.api.state.enums.CratePattern; import vazkii.botania.api.wand.IWandHUD; @@ -42,7 +50,7 @@ public class BlockCraftyCrate extends BlockOpenCrate implements IWandHUD { @Override public void renderHUD(Minecraft mc, World world, BlockPos pos) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileCraftCrate) { + if (tile instanceof TileCraftCrate) { TileCraftCrate craft = (TileCraftCrate) tile; int width = 52; @@ -53,21 +61,23 @@ public class BlockCraftyCrate extends BlockOpenCrate implements IWandHUD { AbstractGui.fill(xc - 6, yc - 6, xc + width + 6, yc + height + 6, 0x22000000); AbstractGui.fill(xc - 4, yc - 4, xc + width + 4, yc + height + 4, 0x22000000); - for(int i = 0; i < 3; i++) - for(int j = 0; j < 3; j++) { + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { int index = i * 3 + j; int xp = xc + j * 18; int yp = yc + i * 18; boolean enabled = true; - if(craft.getPattern() != CratePattern.NONE) + if (craft.getPattern() != CratePattern.NONE) { enabled = craft.getPattern().openSlots.get(index); + } AbstractGui.fill(xp, yp, xp + 16, yp + 16, enabled ? 0x22FFFFFF : 0x22FF0000); ItemStack item = craft.getItemHandler().getStackInSlot(index); mc.getItemRenderer().renderItemAndEffectIntoGUI(item, xp, yp); } + } } } } diff --git a/src/main/java/vazkii/botania/common/block/BlockEnchantedSoil.java b/src/main/java/vazkii/botania/common/block/BlockEnchantedSoil.java index f49dd83f4..3c9132212 100644 --- a/src/main/java/vazkii/botania/common/block/BlockEnchantedSoil.java +++ b/src/main/java/vazkii/botania/common/block/BlockEnchantedSoil.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 26, 2015, 6:08:29 PM (GMT)] */ package vazkii.botania.common.block; diff --git a/src/main/java/vazkii/botania/common/block/BlockEnderEye.java b/src/main/java/vazkii/botania/common/block/BlockEnderEye.java index a939e8311..9dba527ab 100644 --- a/src/main/java/vazkii/botania/common/block/BlockEnderEye.java +++ b/src/main/java/vazkii/botania/common/block/BlockEnderEye.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 30, 2014, 1:05:07 PM (GMT)] */ package vazkii.botania.common.block; @@ -19,10 +17,12 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; + import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.common.block.tile.TileEnderEye; import javax.annotation.Nonnull; + import java.util.Random; public class BlockEnderEye extends BlockMod { @@ -60,8 +60,8 @@ public class BlockEnderEye extends BlockMod { @Override public void animateTick(BlockState state, World world, BlockPos pos, Random rand) { - if(state.get(BotaniaStateProps.POWERED)) { - for(int i = 0; i < 20; i++) { + if (state.get(BotaniaStateProps.POWERED)) { + for (int i = 0; i < 20; i++) { double x = pos.getX() - 0.1 + Math.random() * 1.2; double y = pos.getY() - 0.1 + Math.random() * 1.2; double z = pos.getZ() - 0.1 + Math.random() * 1.2; diff --git a/src/main/java/vazkii/botania/common/block/BlockFakeAir.java b/src/main/java/vazkii/botania/common/block/BlockFakeAir.java index c238ca486..7ac6116d5 100644 --- a/src/main/java/vazkii/botania/common/block/BlockFakeAir.java +++ b/src/main/java/vazkii/botania/common/block/BlockFakeAir.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 10, 2015, 10:22:38 PM (GMT)] */ package vazkii.botania.common.block; @@ -15,15 +13,16 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; + import vazkii.botania.common.block.tile.TileFakeAir; import javax.annotation.Nonnull; + import java.util.Random; public class BlockFakeAir extends AirBlock { @@ -34,8 +33,9 @@ public class BlockFakeAir extends AirBlock { @Override public void neighborChanged(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean isMoving) { - if(shouldRemove(world, pos)) + if (shouldRemove(world, pos)) { world.getPendingBlockTicks().scheduleTick(pos, this, tickRate(world)); + } } private boolean shouldRemove(World world, BlockPos pos) { @@ -44,8 +44,9 @@ public class BlockFakeAir extends AirBlock { @Override public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random rand) { - if(shouldRemove(world, pos)) + if (shouldRemove(world, pos)) { world.setBlockState(pos, rand.nextInt(10) == 0 ? Blocks.WATER.getDefaultState() : Blocks.AIR.getDefaultState()); + } } @Override diff --git a/src/main/java/vazkii/botania/common/block/BlockFelPumpkin.java b/src/main/java/vazkii/botania/common/block/BlockFelPumpkin.java index dfc96f799..c5189f021 100644 --- a/src/main/java/vazkii/botania/common/block/BlockFelPumpkin.java +++ b/src/main/java/vazkii/botania/common/block/BlockFelPumpkin.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 7, 2015, 7:59:10 PM (GMT)] */ package vazkii.botania.common.block; @@ -24,6 +22,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.common.lib.LibMisc; @Mod.EventBusSubscriber(modid = LibMisc.MOD_ID) @@ -45,7 +44,7 @@ public class BlockFelPumpkin extends BlockMod { public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean isMoving) { super.onBlockAdded(state, world, pos, oldState, isMoving); - if(!world.isRemote && world.getBlockState(pos.down()).getBlock() == Blocks.IRON_BARS && world.getBlockState(pos.down(2)).getBlock() == Blocks.IRON_BARS) { + if (!world.isRemote && world.getBlockState(pos.down()).getBlock() == Blocks.IRON_BARS && world.getBlockState(pos.down(2)).getBlock() == Blocks.IRON_BARS) { world.setBlockState(pos, Blocks.AIR.getDefaultState()); world.setBlockState(pos.down(), Blocks.AIR.getDefaultState()); world.setBlockState(pos.down(2), Blocks.AIR.getDefaultState()); diff --git a/src/main/java/vazkii/botania/common/block/BlockFloatingSpecialFlower.java b/src/main/java/vazkii/botania/common/block/BlockFloatingSpecialFlower.java index de6eb2e85..0a8283418 100644 --- a/src/main/java/vazkii/botania/common/block/BlockFloatingSpecialFlower.java +++ b/src/main/java/vazkii/botania/common/block/BlockFloatingSpecialFlower.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 17, 2014, 5:31:53 PM (GMT)] */ package vazkii.botania.common.block; @@ -23,18 +21,19 @@ import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.IBlockReader; -import net.minecraft.world.ILightReader; import net.minecraft.world.World; import net.minecraft.world.storage.loot.LootContext; import net.minecraft.world.storage.loot.LootParameters; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.subtile.TileEntitySpecialFlower; import vazkii.botania.api.wand.IWandHUD; import vazkii.botania.api.wand.IWandable; import vazkii.botania.common.block.decor.BlockFloatingFlower; import javax.annotation.Nonnull; + import java.util.List; import java.util.Random; import java.util.function.Supplier; @@ -88,7 +87,7 @@ public class BlockFloatingSpecialFlower extends BlockFloatingFlower implements I List drops = super.getDrops(state, builder); TileEntity te = builder.get(LootParameters.BLOCK_ENTITY); - if(te instanceof TileEntitySpecialFlower) { + if (te instanceof TileEntitySpecialFlower) { return ((TileEntitySpecialFlower) te).getDrops(drops, builder); } else { return drops; @@ -108,9 +107,11 @@ public class BlockFloatingSpecialFlower extends BlockFloatingFlower implements I @Override public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { ActionResultType tileResult = ((TileEntitySpecialFlower) world.getTileEntity(pos)).onBlockActivated(world, pos, state, player, hand, hit); - if (tileResult.isAccepted()) + if (tileResult.isAccepted()) { return tileResult; - else return super.onUse(state, world, pos, player, hand, hit); + } else { + return super.onUse(state, world, pos, player, hand, hit); + } } @Override diff --git a/src/main/java/vazkii/botania/common/block/BlockForestEye.java b/src/main/java/vazkii/botania/common/block/BlockForestEye.java index 770c45bc3..1ba365efe 100644 --- a/src/main/java/vazkii/botania/common/block/BlockForestEye.java +++ b/src/main/java/vazkii/botania/common/block/BlockForestEye.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 9, 2014, 10:55:17 PM (GMT)] */ package vazkii.botania.common.block; @@ -17,6 +15,7 @@ import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; + import vazkii.botania.common.block.tile.TileForestEye; import javax.annotation.Nonnull; diff --git a/src/main/java/vazkii/botania/common/block/BlockGaiaHead.java b/src/main/java/vazkii/botania/common/block/BlockGaiaHead.java index 90f73d717..d21ef5977 100644 --- a/src/main/java/vazkii/botania/common/block/BlockGaiaHead.java +++ b/src/main/java/vazkii/botania/common/block/BlockGaiaHead.java @@ -1,18 +1,17 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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, 2015, 11:44:35 PM (GMT)] */ package vazkii.botania.common.block; import net.minecraft.block.SkullBlock; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockReader; + import vazkii.botania.common.block.tile.TileGaiaHead; import javax.annotation.Nonnull; diff --git a/src/main/java/vazkii/botania/common/block/BlockGaiaHeadWall.java b/src/main/java/vazkii/botania/common/block/BlockGaiaHeadWall.java index 105626f88..337c85e26 100644 --- a/src/main/java/vazkii/botania/common/block/BlockGaiaHeadWall.java +++ b/src/main/java/vazkii/botania/common/block/BlockGaiaHeadWall.java @@ -1,20 +1,29 @@ +/* + * This class is 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 + */ package vazkii.botania.common.block; import net.minecraft.block.WallSkullBlock; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockReader; + import vazkii.botania.common.block.tile.TileGaiaHead; import javax.annotation.Nonnull; public class BlockGaiaHeadWall extends WallSkullBlock { - public BlockGaiaHeadWall(Properties builder) { - super(BlockGaiaHead.GAIA_TYPE, builder); - } + public BlockGaiaHeadWall(Properties builder) { + super(BlockGaiaHead.GAIA_TYPE, builder); + } - @Nonnull - @Override - public TileEntity createNewTileEntity(IBlockReader world) { - return new TileGaiaHead(); - } + @Nonnull + @Override + public TileEntity createNewTileEntity(IBlockReader world) { + return new TileGaiaHead(); + } } diff --git a/src/main/java/vazkii/botania/common/block/BlockGhostRail.java b/src/main/java/vazkii/botania/common/block/BlockGhostRail.java index b43a350a3..ef53241bb 100644 --- a/src/main/java/vazkii/botania/common/block/BlockGhostRail.java +++ b/src/main/java/vazkii/botania/common/block/BlockGhostRail.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 9, 2015, 12:48:18 AM (GMT)] */ package vazkii.botania.common.block; import com.google.common.base.Preconditions; + import net.minecraft.block.AbstractRailBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -27,12 +26,13 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; @@ -64,7 +64,7 @@ public class BlockGhostRail extends AbstractRailBlock { BlockState state = cart.world.getBlockState(entPos); boolean air = state.isAir(cart.world, entPos); - if(state.getBlock() == ModBlocks.dreamwood + if (state.getBlock() == ModBlocks.dreamwood || (state.getBlock() != ModBlocks.ghostRail && state.isIn(BlockTags.RAILS))) { cart.world.playEvent(2003, entPos, 0); cart.getPersistentData().putInt(TAG_FLOAT_TICKS, 0); @@ -72,8 +72,9 @@ public class BlockGhostRail extends AbstractRailBlock { BlockPos down = entPos.down(); BlockState stateBelow = cart.world.getBlockState(down); boolean airBelow = stateBelow.isAir(cart.world, down); - if(air && airBelow || !air && !airBelow) + if (air && airBelow || !air && !airBelow) { cart.noClip = true; + } cart.setMotion(cart.getMotion().getX() * 1.4, 0.2, cart.getMotion().getZ() * 1.4); cart.getPersistentData().putInt(TAG_FLOAT_TICKS, floatTicks - 1); cart.world.playEvent(2000, entPos, 0); @@ -85,7 +86,7 @@ public class BlockGhostRail extends AbstractRailBlock { @Override public void onMinecartPass(BlockState state, World world, BlockPos pos, AbstractMinecartEntity cart) { super.onMinecartPass(state, world, pos, cart); - if(!world.isRemote) { + if (!world.isRemote) { cart.getPersistentData().putInt(TAG_FLOAT_TICKS, 20); addFloatingCart(cart); updateFloating(cart); @@ -102,17 +103,17 @@ public class BlockGhostRail extends AbstractRailBlock { } private void cartSpawn(EntityJoinWorldEvent evt) { - if(!evt.getWorld().isRemote && evt.getEntity() instanceof AbstractMinecartEntity) { + if (!evt.getWorld().isRemote && evt.getEntity() instanceof AbstractMinecartEntity) { addFloatingCart((AbstractMinecartEntity) evt.getEntity()); } } private void worldTick(TickEvent.WorldTickEvent evt) { - if(!evt.world.isRemote() && evt.phase == TickEvent.Phase.END) { + if (!evt.world.isRemote() && evt.phase == TickEvent.Phase.END) { evt.world.getProfiler().startSection("cartFloatingIter"); Iterator iter = floatingCarts.getOrDefault(evt.world.getDimension().getType(), Collections.emptySet()).iterator(); while (iter.hasNext()) { - AbstractMinecartEntity c = iter.next(); + AbstractMinecartEntity c = iter.next(); BlockPos entPos = new BlockPos(c); if (!c.isAlive() || !c.isAddedToWorld() || !c.world.isBlockLoaded(entPos)) { diff --git a/src/main/java/vazkii/botania/common/block/BlockHourglass.java b/src/main/java/vazkii/botania/common/block/BlockHourglass.java index 3601d98d1..5900b13be 100644 --- a/src/main/java/vazkii/botania/common/block/BlockHourglass.java +++ b/src/main/java/vazkii/botania/common/block/BlockHourglass.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 29, 2015, 8:17:08 PM (GMT)] */ package vazkii.botania.common.block; @@ -33,6 +31,7 @@ import net.minecraft.world.server.ServerWorld; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.items.ItemHandlerHelper; + import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.mana.IManaTrigger; @@ -45,6 +44,7 @@ import vazkii.botania.common.core.helper.InventoryHelper; import vazkii.botania.common.item.ModItems; import javax.annotation.Nonnull; + import java.util.Random; public class BlockHourglass extends BlockMod implements IManaTrigger, IWandable, IWandHUD { @@ -72,21 +72,23 @@ public class BlockHourglass extends BlockMod implements IManaTrigger, IWandable, TileHourglass hourglass = (TileHourglass) world.getTileEntity(pos); ItemStack hgStack = hourglass.getItemHandler().getStackInSlot(0); ItemStack stack = player.getHeldItem(hand); - if(!stack.isEmpty() && stack.getItem() == ModItems.twigWand) + if (!stack.isEmpty() && stack.getItem() == ModItems.twigWand) { return ActionResultType.PASS; + } - if(hourglass.lock) { - if(!player.world.isRemote) + if (hourglass.lock) { + if (!player.world.isRemote) { player.sendMessage(new TranslationTextComponent("botaniamisc.hourglassLock")); + } return ActionResultType.FAIL; } - if(hgStack.isEmpty() && TileHourglass.getStackItemTime(stack) > 0) { + if (hgStack.isEmpty() && TileHourglass.getStackItemTime(stack) > 0) { hourglass.getItemHandler().setStackInSlot(0, stack.copy()); hourglass.markDirty(); stack.setCount(0); return ActionResultType.SUCCESS; - } else if(!hgStack.isEmpty()) { + } else if (!hgStack.isEmpty()) { ItemHandlerHelper.giveItemToPlayer(player, hgStack); hourglass.getItemHandler().setStackInSlot(0, ItemStack.EMPTY); hourglass.markDirty(); @@ -113,8 +115,9 @@ public class BlockHourglass extends BlockMod implements IManaTrigger, IWandable, @Override public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random rand) { - if(state.get(BotaniaStateProps.POWERED)) + if (state.get(BotaniaStateProps.POWERED)) { world.setBlockState(pos, state.with(BotaniaStateProps.POWERED, false)); + } } @Override @@ -145,7 +148,7 @@ public class BlockHourglass extends BlockMod implements IManaTrigger, IWandable, @Override public void onBurstCollision(IManaBurst burst, World world, BlockPos pos) { - if(!burst.isFake()) { + if (!burst.isFake()) { TileHourglass tile = (TileHourglass) world.getTileEntity(pos); tile.onManaCollide(); } @@ -155,8 +158,9 @@ public class BlockHourglass extends BlockMod implements IManaTrigger, IWandable, public boolean onUsedByWand(PlayerEntity player, ItemStack stack, World world, BlockPos pos, Direction side) { TileHourglass tile = (TileHourglass) world.getTileEntity(pos); tile.lock = !tile.lock; - if(!world.isRemote) + if (!world.isRemote) { VanillaPacketDispatcher.dispatchTEToNearbyPlayers(tile); + } return true; } diff --git a/src/main/java/vazkii/botania/common/block/BlockIncensePlate.java b/src/main/java/vazkii/botania/common/block/BlockIncensePlate.java index 688d3f945..716263ec6 100644 --- a/src/main/java/vazkii/botania/common/block/BlockIncensePlate.java +++ b/src/main/java/vazkii/botania/common/block/BlockIncensePlate.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 15, 2015, 4:07:09 PM (GMT)] */ package vazkii.botania.common.block; @@ -29,6 +27,7 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.items.ItemHandlerHelper; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.common.block.tile.TileIncensePlate; @@ -56,15 +55,16 @@ public class BlockIncensePlate extends BlockMod { ItemStack stack = player.getHeldItem(hand); boolean did = false; - if(world.isRemote) + if (world.isRemote) { return ActionResultType.SUCCESS; + } - if(plateStack.isEmpty() && plate.acceptsItem(stack)) { + if (plateStack.isEmpty() && plate.acceptsItem(stack)) { plate.getItemHandler().setStackInSlot(0, stack.copy()); stack.shrink(1); did = true; - } else if(!plateStack.isEmpty() && !plate.burning) { - if(!stack.isEmpty() && stack.getItem() == Items.FLINT_AND_STEEL) { + } else if (!plateStack.isEmpty() && !plate.burning) { + if (!stack.isEmpty() && stack.getItem() == Items.FLINT_AND_STEEL) { plate.ignite(); stack.damageItem(1, player, e -> e.sendBreakAnimation(hand)); did = true; @@ -76,8 +76,9 @@ public class BlockIncensePlate extends BlockMod { } } - if(did) + if (did) { VanillaPacketDispatcher.dispatchTEToNearbyPlayers(plate); + } return did ? ActionResultType.SUCCESS : ActionResultType.PASS; } @@ -100,7 +101,7 @@ public class BlockIncensePlate extends BlockMod { @Nonnull @Override public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext ctx) { - if(state.get(BlockStateProperties.HORIZONTAL_FACING).getAxis() == Direction.Axis.X) { + if (state.get(BlockStateProperties.HORIZONTAL_FACING).getAxis() == Direction.Axis.X) { return X_SHAPE; } else { return Z_SHAPE; @@ -118,5 +119,4 @@ public class BlockIncensePlate extends BlockMod { return new TileIncensePlate(); } - } diff --git a/src/main/java/vazkii/botania/common/block/BlockLightLauncher.java b/src/main/java/vazkii/botania/common/block/BlockLightLauncher.java index 1ef119acb..7df670b8f 100644 --- a/src/main/java/vazkii/botania/common/block/BlockLightLauncher.java +++ b/src/main/java/vazkii/botania/common/block/BlockLightLauncher.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 17, 2015, 4:08:58 PM (GMT)] */ package vazkii.botania.common.block; @@ -24,10 +22,12 @@ import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; + import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.common.block.tile.TileLightRelay; import javax.annotation.Nonnull; + import java.util.ArrayList; import java.util.List; @@ -53,34 +53,36 @@ public class BlockLightLauncher extends BlockMod { @Override public void neighborChanged(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean isMoving) { - boolean power = world.getRedstonePowerFromNeighbors(pos) > 0|| world.getRedstonePowerFromNeighbors(pos.up()) > 0; + boolean power = world.getRedstonePowerFromNeighbors(pos) > 0 || world.getRedstonePowerFromNeighbors(pos.up()) > 0; boolean powered = state.get(BotaniaStateProps.POWERED); - if(power && !powered) { + if (power && !powered) { pickUpEntities(world, pos); world.setBlockState(pos, state.with(BotaniaStateProps.POWERED, true), 4); - } else if(!power && powered) + } else if (!power && powered) { world.setBlockState(pos, state.with(BotaniaStateProps.POWERED, false), 4); + } } private void pickUpEntities(World world, BlockPos pos) { List relays = new ArrayList<>(); - for(Direction dir : Direction.values()) { + for (Direction dir : Direction.values()) { TileEntity tile = world.getTileEntity(pos.offset(dir)); - if(tile instanceof TileLightRelay) { + if (tile instanceof TileLightRelay) { TileLightRelay relay = (TileLightRelay) tile; - if(relay.getNextDestination() != null) + if (relay.getNextDestination() != null) { relays.add(relay); + } } } - if(!relays.isEmpty()) { + if (!relays.isEmpty()) { AxisAlignedBB aabb = new AxisAlignedBB(pos, pos.add(1, 1, 1)); List entities = world.getEntitiesWithinAABB(LivingEntity.class, aabb); entities.addAll(world.getEntitiesWithinAABB(ItemEntity.class, aabb)); - if(!entities.isEmpty()) { - for(Entity entity : entities) { + if (!entities.isEmpty()) { + for (Entity entity : entities) { TileLightRelay relay = relays.get(world.rand.nextInt(relays.size())); relay.mountEntity(entity); } diff --git a/src/main/java/vazkii/botania/common/block/BlockLightRelay.java b/src/main/java/vazkii/botania/common/block/BlockLightRelay.java index 107136d8a..d8c0b22db 100644 --- a/src/main/java/vazkii/botania/common/block/BlockLightRelay.java +++ b/src/main/java/vazkii/botania/common/block/BlockLightRelay.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 15, 2015, 8:31:13 PM (GMT)] */ package vazkii.botania.common.block; @@ -28,12 +26,14 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; + import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.api.state.enums.LuminizerVariant; import vazkii.botania.api.wand.IWandable; import vazkii.botania.common.block.tile.TileLightRelay; import javax.annotation.Nonnull; + import java.util.Random; public class BlockLightRelay extends BlockMod implements IWandable { @@ -71,11 +71,12 @@ public class BlockLightRelay extends BlockMod implements IWandable { @Override public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { - if(!worldIn.isRemote && variant == LuminizerVariant.TOGGLE) { - if(state.get(BotaniaStateProps.POWERED) && !worldIn.isBlockPowered(pos)) + if (!worldIn.isRemote && variant == LuminizerVariant.TOGGLE) { + if (state.get(BotaniaStateProps.POWERED) && !worldIn.isBlockPowered(pos)) { worldIn.setBlockState(pos, state.with(BotaniaStateProps.POWERED, false)); - else if(!state.get(BotaniaStateProps.POWERED) && worldIn.isBlockPowered(pos)) + } else if (!state.get(BotaniaStateProps.POWERED) && worldIn.isBlockPowered(pos)) { worldIn.setBlockState(pos, state.with(BotaniaStateProps.POWERED, true)); + } } } diff --git a/src/main/java/vazkii/botania/common/block/BlockManaBomb.java b/src/main/java/vazkii/botania/common/block/BlockManaBomb.java index e51ea0b3c..7d3f796e7 100644 --- a/src/main/java/vazkii/botania/common/block/BlockManaBomb.java +++ b/src/main/java/vazkii/botania/common/block/BlockManaBomb.java @@ -1,18 +1,17 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 25, 2015, 12:24:10 AM (GMT)] */ package vazkii.botania.common.block; import net.minecraft.block.Block; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.api.mana.IManaTrigger; import vazkii.botania.common.entity.EntityManaStorm; @@ -25,7 +24,7 @@ public class BlockManaBomb extends BlockMod implements IManaTrigger { @Override public void onBurstCollision(IManaBurst burst, World world, BlockPos pos) { - if(!burst.isFake() && !world.isRemote) { + if (!burst.isFake() && !world.isRemote) { world.playEvent(2001, pos, Block.getStateId(getDefaultState())); world.removeBlock(pos, false); EntityManaStorm storm = new EntityManaStorm(world); diff --git a/src/main/java/vazkii/botania/common/block/BlockMod.java b/src/main/java/vazkii/botania/common/block/BlockMod.java index fe80e1942..8049105c5 100644 --- a/src/main/java/vazkii/botania/common/block/BlockMod.java +++ b/src/main/java/vazkii/botania/common/block/BlockMod.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 14, 2014, 5:31:15 PM (GMT)] */ package vazkii.botania.common.block; diff --git a/src/main/java/vazkii/botania/common/block/BlockModDoubleFlower.java b/src/main/java/vazkii/botania/common/block/BlockModDoubleFlower.java index 54dbfa776..52a307218 100644 --- a/src/main/java/vazkii/botania/common/block/BlockModDoubleFlower.java +++ b/src/main/java/vazkii/botania/common/block/BlockModDoubleFlower.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 22, 2015, 7:46:55 PM (GMT)] */ package vazkii.botania.common.block; @@ -18,10 +16,12 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.client.fx.SparkleParticleData; import vazkii.botania.common.core.handler.ConfigHandler; import javax.annotation.Nonnull; + import java.util.Random; public class BlockModDoubleFlower extends TallFlowerBlock { @@ -45,10 +45,10 @@ public class BlockModDoubleFlower extends TallFlowerBlock { int g = (hex & 0xFF00) >> 8; int b = hex & 0xFF; - if(rand.nextDouble() < ConfigHandler.CLIENT.flowerParticleFrequency.get()) { - SparkleParticleData data = SparkleParticleData.sparkle(rand.nextFloat(), r / 255F, g / 255F, b / 255F, 5); - world.addParticle(data, pos.getX() + 0.3 + rand.nextFloat() * 0.5, pos.getY() + 0.5 + rand.nextFloat() * 0.5, pos.getZ() + 0.3 + rand.nextFloat() * 0.5, 0, 0, 0); - } + if (rand.nextDouble() < ConfigHandler.CLIENT.flowerParticleFrequency.get()) { + SparkleParticleData data = SparkleParticleData.sparkle(rand.nextFloat(), r / 255F, g / 255F, b / 255F, 5); + world.addParticle(data, pos.getX() + 0.3 + rand.nextFloat() * 0.5, pos.getY() + 0.5 + rand.nextFloat() * 0.5, pos.getZ() + 0.3 + rand.nextFloat() * 0.5, 0, 0, 0); + } } } diff --git a/src/main/java/vazkii/botania/common/block/BlockModFlower.java b/src/main/java/vazkii/botania/common/block/BlockModFlower.java index b651f1af8..60389a50c 100644 --- a/src/main/java/vazkii/botania/common/block/BlockModFlower.java +++ b/src/main/java/vazkii/botania/common/block/BlockModFlower.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 16, 2014, 5:50:31 PM (GMT)] */ package vazkii.botania.common.block; @@ -25,14 +23,17 @@ import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.client.fx.SparkleParticleData; import vazkii.botania.common.core.handler.ConfigHandler; import javax.annotation.Nonnull; + import java.util.Random; public class BlockModFlower extends FlowerBlock implements IGrowable { public final DyeColor color; + protected BlockModFlower(DyeColor color, Properties builder) { super(effectForFlower(color), 4, builder); this.color = color; @@ -40,22 +41,38 @@ public class BlockModFlower extends FlowerBlock implements IGrowable { private static Effect effectForFlower(DyeColor color) { switch (color) { - case WHITE: return Effects.SPEED; - case ORANGE: return Effects.FIRE_RESISTANCE; - case MAGENTA: return Effects.MINING_FATIGUE; - case LIGHT_BLUE: return Effects.JUMP_BOOST; - case YELLOW: return Effects.ABSORPTION; - case LIME: return Effects.POISON; - case PINK: return Effects.REGENERATION; - case GRAY: return Effects.RESISTANCE; - case LIGHT_GRAY: return Effects.WEAKNESS; - case CYAN: return Effects.WATER_BREATHING; - case PURPLE: return Effects.NAUSEA; - case BLUE: return Effects.NIGHT_VISION; - case BROWN: return Effects.WITHER; - case GREEN: return Effects.HUNGER; - case RED: return Effects.STRENGTH; - case BLACK: return Effects.BLINDNESS; + case WHITE: + return Effects.SPEED; + case ORANGE: + return Effects.FIRE_RESISTANCE; + case MAGENTA: + return Effects.MINING_FATIGUE; + case LIGHT_BLUE: + return Effects.JUMP_BOOST; + case YELLOW: + return Effects.ABSORPTION; + case LIME: + return Effects.POISON; + case PINK: + return Effects.REGENERATION; + case GRAY: + return Effects.RESISTANCE; + case LIGHT_GRAY: + return Effects.WEAKNESS; + case CYAN: + return Effects.WATER_BREATHING; + case PURPLE: + return Effects.NAUSEA; + case BLUE: + return Effects.NIGHT_VISION; + case BROWN: + return Effects.WITHER; + case GREEN: + return Effects.HUNGER; + case RED: + return Effects.STRENGTH; + case BLACK: + return Effects.BLINDNESS; } return Effects.REGENERATION; } @@ -72,10 +89,10 @@ public class BlockModFlower extends FlowerBlock implements IGrowable { double y = pos.getY() + offset.y; double z = pos.getZ() + offset.z; - if(rand.nextDouble() < ConfigHandler.CLIENT.flowerParticleFrequency.get()) { - SparkleParticleData data = SparkleParticleData.sparkle(rand.nextFloat(), r / 255F, g / 255F, b / 255F, 5); - world.addParticle(data, x + 0.3 + rand.nextFloat() * 0.5, y + 0.5 + rand.nextFloat() * 0.5, z + 0.3 + rand.nextFloat() * 0.5, 0, 0, 0); - } + if (rand.nextDouble() < ConfigHandler.CLIENT.flowerParticleFrequency.get()) { + SparkleParticleData data = SparkleParticleData.sparkle(rand.nextFloat(), r / 255F, g / 255F, b / 255F, 5); + world.addParticle(data, x + 0.3 + rand.nextFloat() * 0.5, y + 0.5 + rand.nextFloat() * 0.5, z + 0.3 + rand.nextFloat() * 0.5, 0, 0, 0); + } } @Override @@ -91,7 +108,7 @@ public class BlockModFlower extends FlowerBlock implements IGrowable { @Override public void grow(@Nonnull ServerWorld world, @Nonnull Random rand, @Nonnull BlockPos pos, @Nonnull BlockState state) { Block block = ModBlocks.getDoubleFlower(color); - if(block instanceof DoublePlantBlock) { + if (block instanceof DoublePlantBlock) { ((DoublePlantBlock) block).placeAt(world, pos, 3); } } diff --git a/src/main/java/vazkii/botania/common/block/BlockOpenCrate.java b/src/main/java/vazkii/botania/common/block/BlockOpenCrate.java index 2fb66a880..b2da9e2ab 100644 --- a/src/main/java/vazkii/botania/common/block/BlockOpenCrate.java +++ b/src/main/java/vazkii/botania/common/block/BlockOpenCrate.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 4, 2014, 12:29:56 PM (GMT)] */ package vazkii.botania.common.block; @@ -18,6 +16,7 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; + import vazkii.botania.api.wand.IWandable; import vazkii.botania.common.block.tile.TileOpenCrate; import vazkii.botania.common.block.tile.TileSimpleInventory; @@ -44,7 +43,7 @@ public class BlockOpenCrate extends BlockMod implements IWandable { @Override public void onReplaced(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState newState, boolean isMoving) { - if(newState.getBlock() != state.getBlock()) { + if (newState.getBlock() != state.getBlock()) { TileSimpleInventory inv = (TileSimpleInventory) world.getTileEntity(pos); InventoryHelper.dropInventory(inv, world, state, pos); super.onReplaced(state, world, pos, newState, isMoving); diff --git a/src/main/java/vazkii/botania/common/block/BlockPistonRelay.java b/src/main/java/vazkii/botania/common/block/BlockPistonRelay.java index f32330a5d..7a70891ef 100644 --- a/src/main/java/vazkii/botania/common/block/BlockPistonRelay.java +++ b/src/main/java/vazkii/botania/common/block/BlockPistonRelay.java @@ -1,17 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 20, 2014, 4:57:36 PM (GMT)] */ package vazkii.botania.common.block; import com.mojang.datafixers.Dynamic; -import net.minecraft.block.Block; + import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.MovingPistonBlock; @@ -41,9 +39,9 @@ import net.minecraft.world.storage.WorldSavedData; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.Constants; import net.minecraftforge.event.TickEvent; -import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.server.ServerLifecycleHooks; + import vazkii.botania.api.wand.IWandable; import vazkii.botania.common.core.handler.ModSounds; import vazkii.botania.common.item.ItemTwigWand; @@ -51,6 +49,7 @@ import vazkii.botania.common.network.PacketBotaniaEffect; import vazkii.botania.common.network.PacketHandler; import javax.annotation.Nonnull; + import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -78,7 +77,7 @@ public class BlockPistonRelay extends BlockMod implements IWandable { @Override public void onReplaced(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState newState, boolean isMoving) { - if(!world.isRemote) { + if (!world.isRemote) { mapCoords(world.getDimension().getType(), pos, 2); } } @@ -90,9 +89,11 @@ public class BlockPistonRelay extends BlockMod implements IWandable { private void decrCoords(GlobalPos key) { int time = getTimeInCoords(key); - if(time <= 0) + if (time <= 0) { removeQueue.add(key); - else coordsToCheck.merge(key, -1, Integer::sum); + } else { + coordsToCheck.merge(key, -1, Integer::sum); + } } private int getTimeInCoords(GlobalPos key) { @@ -101,29 +102,32 @@ public class BlockPistonRelay extends BlockMod implements IWandable { private TileEntity getTeAt(GlobalPos key) { MinecraftServer server = ServerLifecycleHooks.getCurrentServer(); - if(server == null) + if (server == null) { return null; + } return server.getWorld(key.getDimension()).getTileEntity(key.getPos()); } private BlockState getStateAt(GlobalPos key) { MinecraftServer server = ServerLifecycleHooks.getCurrentServer(); - if(server == null) + if (server == null) { return Blocks.AIR.getDefaultState(); + } return server.getWorld(key.getDimension()).getBlockState(key.getPos()); } @Override public boolean onUsedByWand(PlayerEntity player, ItemStack stack, World world, BlockPos pos, Direction side) { - if(world.isRemote) + if (world.isRemote) { return false; + } - if(player == null || player.isSneaking()) { + if (player == null || player.isSneaking()) { spawnAsEntity(world, pos, new ItemStack(this)); world.destroyBlock(pos, false); - } else { + } else { GlobalPos clicked = GlobalPos.of(world.getDimension().getType(), pos.toImmutable()); - if(ItemTwigWand.getBindMode(stack)) { + if (ItemTwigWand.getBindMode(stack)) { activeBindingAttempts.put(player.getUniqueID(), clicked); world.playSound(null, pos, ModSounds.ding, SoundCategory.BLOCKS, 0.5F, 1F); } else { @@ -189,29 +193,30 @@ public class BlockPistonRelay extends BlockMod implements IWandable { @SubscribeEvent public void tickEnd(TickEvent.ServerTickEvent event) { - if(event.type == TickEvent.Type.SERVER && event.phase == TickEvent.Phase.END) { + if (event.type == TickEvent.Type.SERVER && event.phase == TickEvent.Phase.END) { MinecraftServer server = ServerLifecycleHooks.getCurrentServer(); - for(GlobalPos s : coordsToCheck.keySet()) { + for (GlobalPos s : coordsToCheck.keySet()) { ServerWorld world = server.getWorld(s.getDimension()); WorldData data = WorldData.get(world); decrCoords(s); - if(checkedCoords.contains(s)) + if (checkedCoords.contains(s)) { continue; + } BlockState state = getStateAt(s); - if(state.getBlock() == Blocks.MOVING_PISTON) { + if (state.getBlock() == Blocks.MOVING_PISTON) { boolean sticky = PistonType.STICKY == state.get(MovingPistonBlock.TYPE); Direction dir = ((PistonTileEntity) getTeAt(s)).getMotionDirection(); - if(getTimeInCoords(s) == 0) { + if (getTimeInCoords(s) == 0) { BlockPos newPos; // Put the relay back, or drop it { int x = s.getPos().getX(), y = s.getPos().getY(), z = s.getPos().getZ(); BlockPos pos = s.getPos(); - if(world.isAirBlock(pos.offset(dir))) { + if (world.isAirBlock(pos.offset(dir))) { world.setBlockState(pos.offset(dir), ModBlocks.pistonRelay.getDefaultState()); } else { ItemStack stack = new ItemStack(ModBlocks.pistonRelay); @@ -222,15 +227,15 @@ public class BlockPistonRelay extends BlockMod implements IWandable { } // Move the linked block and update the mapping - if(data.mapping.containsKey(s.getPos())) { + if (data.mapping.containsKey(s.getPos())) { BlockPos destPos = data.mapping.get(s.getPos()); BlockState srcState = world.getBlockState(destPos); TileEntity tile = world.getTileEntity(destPos); - if(!sticky && tile == null && srcState.getPushReaction() == PushReaction.NORMAL && srcState.getBlockHardness(world, destPos) != -1 && !srcState.isAir(world, destPos)) { + if (!sticky && tile == null && srcState.getPushReaction() == PushReaction.NORMAL && srcState.getBlockHardness(world, destPos) != -1 && !srcState.isAir(world, destPos)) { Material destMat = world.getBlockState(destPos.offset(dir)).getMaterial(); - if(world.isAirBlock(destPos.offset(dir)) || destMat.isReplaceable()) { + if (world.isAirBlock(destPos.offset(dir)) || destMat.isReplaceable()) { world.setBlockState(destPos, Blocks.AIR.getDefaultState()); world.setBlockState(destPos.offset(dir), srcState); data.mapping.put(s.getPos(), destPos.offset(dir)); diff --git a/src/main/java/vazkii/botania/common/block/BlockPlatform.java b/src/main/java/vazkii/botania/common/block/BlockPlatform.java index 53cf8371a..f91096836 100644 --- a/src/main/java/vazkii/botania/common/block/BlockPlatform.java +++ b/src/main/java/vazkii/botania/common/block/BlockPlatform.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 7, 2014, 2:25:22 PM (GMT)] */ package vazkii.botania.common.block; @@ -30,6 +28,7 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; + import vazkii.botania.api.mana.IManaCollisionGhost; import vazkii.botania.api.wand.IWandable; import vazkii.botania.common.block.tile.TilePlatform; @@ -56,11 +55,11 @@ public class BlockPlatform extends BlockMod implements IWandable, IManaCollision @Override public VoxelShape getCollisionShape(@Nonnull BlockState state, @Nonnull IBlockReader world, @Nonnull BlockPos pos, ISelectionContext context) { Entity e = context.getEntity(); - if(variant == Variant.INFRANGIBLE + if (variant == Variant.INFRANGIBLE || variant == Variant.ABSTRUSE - && e != null - && e.getY() > pos.getY() + 0.9 - && !context.isDescending()) { + && e != null + && e.getY() > pos.getY() + 0.9 + && !context.isDescending()) { return super.getCollisionShape(state, world, pos, context); } else { return VoxelShapes.empty(); @@ -103,14 +102,14 @@ public class BlockPlatform extends BlockMod implements IWandable, IManaCollision public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { TileEntity tile = world.getTileEntity(pos); ItemStack currentStack = player.getHeldItem(hand); - if(!currentStack.isEmpty() + if (!currentStack.isEmpty() && Block.getBlockFromItem(currentStack.getItem()) != Blocks.AIR && tile instanceof TilePlatform) { TilePlatform camo = (TilePlatform) tile; BlockItemUseContext ctx = new BlockItemUseContext(world, player, hand, currentStack, hit); BlockState changeState = Block.getBlockFromItem(currentStack.getItem()).getStateForPlacement(ctx); - if(changeState != null && isValidBlock(changeState, world, pos) + if (changeState != null && isValidBlock(changeState, world, pos) && !(changeState.getBlock() instanceof BlockPlatform) && changeState.getMaterial() != Material.AIR) { if (!world.isRemote) { @@ -125,5 +124,4 @@ public class BlockPlatform extends BlockMod implements IWandable, IManaCollision return ActionResultType.PASS; } - -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/common/block/BlockPylon.java b/src/main/java/vazkii/botania/common/block/BlockPylon.java index f2eab7643..fda275d58 100644 --- a/src/main/java/vazkii/botania/common/block/BlockPylon.java +++ b/src/main/java/vazkii/botania/common/block/BlockPylon.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 18, 2014, 10:13:02 PM (GMT)] */ package vazkii.botania.common.block; @@ -19,6 +17,7 @@ import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; + import vazkii.botania.common.block.tile.TilePylon; import javax.annotation.Nonnull; @@ -33,6 +32,7 @@ public class BlockPylon extends BlockMod { } public final Variant variant; + public BlockPylon(Variant v, Properties builder) { super(builder); this.variant = v; diff --git a/src/main/java/vazkii/botania/common/block/BlockRoot.java b/src/main/java/vazkii/botania/common/block/BlockRoot.java index dc3b86273..9f6b7fd4e 100644 --- a/src/main/java/vazkii/botania/common/block/BlockRoot.java +++ b/src/main/java/vazkii/botania/common/block/BlockRoot.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 7, 2015, 4:27:47 PM (GMT)] */ package vazkii.botania.common.block; diff --git a/src/main/java/vazkii/botania/common/block/BlockSolidVines.java b/src/main/java/vazkii/botania/common/block/BlockSolidVines.java index da5dd06a0..a2aca5ba0 100644 --- a/src/main/java/vazkii/botania/common/block/BlockSolidVines.java +++ b/src/main/java/vazkii/botania/common/block/BlockSolidVines.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 26, 2014, 11:31:51 PM (GMT)] */ package vazkii.botania.common.block; @@ -23,6 +21,7 @@ import net.minecraft.world.IWorldReader; import net.minecraft.world.server.ServerWorld; import javax.annotation.Nonnull; + import java.util.Random; public class BlockSolidVines extends VineBlock { diff --git a/src/main/java/vazkii/botania/common/block/BlockSparkChanger.java b/src/main/java/vazkii/botania/common/block/BlockSparkChanger.java index e3fe2fa59..016644001 100644 --- a/src/main/java/vazkii/botania/common/block/BlockSparkChanger.java +++ b/src/main/java/vazkii/botania/common/block/BlockSparkChanger.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 28, 2015, 10:01:01 PM (GMT)] */ package vazkii.botania.common.block; @@ -25,6 +23,7 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.items.ItemHandlerHelper; + import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.common.block.tile.TileSimpleInventory; import vazkii.botania.common.block.tile.TileSparkChanger; @@ -58,11 +57,12 @@ public class BlockSparkChanger extends BlockMod { boolean power = world.getRedstonePowerFromNeighbors(pos) > 0 || world.getRedstonePowerFromNeighbors(pos.up()) > 0; boolean powered = state.get(BotaniaStateProps.POWERED); - if(power && !powered) { + if (power && !powered) { ((TileSparkChanger) world.getTileEntity(pos)).doSwap(); world.setBlockState(pos, state.with(BotaniaStateProps.POWERED, true), 4); - } else if(!power && powered) + } else if (!power && powered) { world.setBlockState(pos, state.with(BotaniaStateProps.POWERED, false), 4); + } } @Override @@ -70,13 +70,13 @@ public class BlockSparkChanger extends BlockMod { TileSparkChanger changer = (TileSparkChanger) world.getTileEntity(pos); ItemStack pstack = player.getHeldItem(hand); ItemStack cstack = changer.getItemHandler().getStackInSlot(0); - if(!cstack.isEmpty()) { + if (!cstack.isEmpty()) { changer.getItemHandler().setStackInSlot(0, ItemStack.EMPTY); world.updateComparatorOutputLevel(pos, this); changer.markDirty(); ItemHandlerHelper.giveItemToPlayer(player, cstack); return ActionResultType.SUCCESS; - } else if(!pstack.isEmpty() && pstack.getItem() instanceof ItemSparkUpgrade) { + } else if (!pstack.isEmpty() && pstack.getItem() instanceof ItemSparkUpgrade) { changer.getItemHandler().setStackInSlot(0, pstack.split(1)); world.updateComparatorOutputLevel(pos, this); changer.markDirty(); @@ -105,8 +105,9 @@ public class BlockSparkChanger extends BlockMod { public int getComparatorInputOverride(BlockState state, World world, BlockPos pos) { TileSparkChanger changer = (TileSparkChanger) world.getTileEntity(pos); ItemStack stack = changer.getItemHandler().getStackInSlot(0); - if(!stack.isEmpty() && stack.getItem() instanceof ItemSparkUpgrade) + if (!stack.isEmpty() && stack.getItem() instanceof ItemSparkUpgrade) { return ((ItemSparkUpgrade) stack.getItem()).type.ordinal() + 1; + } return 0; } diff --git a/src/main/java/vazkii/botania/common/block/BlockSpecialFlower.java b/src/main/java/vazkii/botania/common/block/BlockSpecialFlower.java index ee5e4f508..2d4630f74 100644 --- a/src/main/java/vazkii/botania/common/block/BlockSpecialFlower.java +++ b/src/main/java/vazkii/botania/common/block/BlockSpecialFlower.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 22, 2014, 7:06:38 PM (GMT)] */ package vazkii.botania.common.block; @@ -16,7 +14,6 @@ import net.minecraft.block.FlowerBlock; import net.minecraft.client.Minecraft; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.DyeColor; import net.minecraft.item.ItemStack; import net.minecraft.potion.Effects; import net.minecraft.tileentity.TileEntity; @@ -29,19 +26,18 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; -import net.minecraft.world.ILightReader; import net.minecraft.world.World; import net.minecraft.world.storage.loot.LootContext; import net.minecraft.world.storage.loot.LootParameters; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import vazkii.botania.api.state.BotaniaStateProps; + import vazkii.botania.api.subtile.TileEntitySpecialFlower; import vazkii.botania.api.wand.IWandHUD; import vazkii.botania.api.wand.IWandable; -import vazkii.botania.common.item.material.ItemDye; import javax.annotation.Nonnull; + import java.util.List; import java.util.function.Supplier; @@ -104,7 +100,7 @@ public class BlockSpecialFlower extends FlowerBlock implements IWandable, IWandH public List getDrops(@Nonnull BlockState state, @Nonnull LootContext.Builder builder) { List drops = super.getDrops(state, builder); TileEntity te = builder.get(LootParameters.BLOCK_ENTITY); - if(te instanceof TileEntitySpecialFlower) { + if (te instanceof TileEntitySpecialFlower) { return ((TileEntitySpecialFlower) te).getDrops(drops, builder); } else { return drops; diff --git a/src/main/java/vazkii/botania/common/block/BlockStorage.java b/src/main/java/vazkii/botania/common/block/BlockStorage.java index dd61cea6c..39897d702 100644 --- a/src/main/java/vazkii/botania/common/block/BlockStorage.java +++ b/src/main/java/vazkii/botania/common/block/BlockStorage.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 14, 2014, 8:37:26 PM (GMT)] */ package vazkii.botania.common.block; @@ -14,6 +12,7 @@ import net.minecraft.block.BlockState; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorldReader; + import vazkii.botania.api.recipe.IElvenItem; public class BlockStorage extends BlockMod implements IElvenItem { diff --git a/src/main/java/vazkii/botania/common/block/BlockTeruTeruBozu.java b/src/main/java/vazkii/botania/common/block/BlockTeruTeruBozu.java index 7df19df12..8ae3ac041 100644 --- a/src/main/java/vazkii/botania/common/block/BlockTeruTeruBozu.java +++ b/src/main/java/vazkii/botania/common/block/BlockTeruTeruBozu.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Oct 1, 2015, 1:11:26 PM (GMT)] */ package vazkii.botania.common.block; @@ -26,6 +24,7 @@ import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; + import vazkii.botania.common.block.tile.TileTeruTeruBozu; import javax.annotation.Nonnull; @@ -46,10 +45,10 @@ public class BlockTeruTeruBozu extends BlockMod { @Override public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity e) { - if(!world.isRemote && e instanceof ItemEntity) { + if (!world.isRemote && e instanceof ItemEntity) { ItemEntity item = (ItemEntity) e; ItemStack stack = item.getItem(); - if(isSunflower(stack) && removeRain(world) || isBlueOrchid(stack) && startRain(world)) { + if (isSunflower(stack) && removeRain(world) || isBlueOrchid(stack) && startRain(world)) { stack.shrink(1); } } @@ -58,9 +57,10 @@ public class BlockTeruTeruBozu extends BlockMod { @Override public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { ItemStack stack = player.getHeldItem(hand); - if(!stack.isEmpty() && (isSunflower(stack) && removeRain(world) || isBlueOrchid(stack) && startRain(world))) { - if(!player.abilities.isCreativeMode) + if (!stack.isEmpty() && (isSunflower(stack) && removeRain(world) || isBlueOrchid(stack) && startRain(world))) { + if (!player.abilities.isCreativeMode) { stack.shrink(1); + } return ActionResultType.SUCCESS; } return ActionResultType.PASS; @@ -75,7 +75,7 @@ public class BlockTeruTeruBozu extends BlockMod { } private boolean removeRain(World world) { - if(world.isRaining()) { + if (world.isRaining()) { world.getWorldInfo().setRaining(false); TileTeruTeruBozu.resetRainTime(world); return true; @@ -84,8 +84,8 @@ public class BlockTeruTeruBozu extends BlockMod { } private boolean startRain(World world) { - if(!world.isRaining()) { - if(world.rand.nextInt(10) == 0) { + if (!world.isRaining()) { + if (world.rand.nextInt(10) == 0) { world.getWorldInfo().setRaining(true); TileTeruTeruBozu.resetRainTime(world); } diff --git a/src/main/java/vazkii/botania/common/block/BlockTinyPlanet.java b/src/main/java/vazkii/botania/common/block/BlockTinyPlanet.java index e53569a4a..40e12690d 100644 --- a/src/main/java/vazkii/botania/common/block/BlockTinyPlanet.java +++ b/src/main/java/vazkii/botania/common/block/BlockTinyPlanet.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 1, 2014, 3:49:12 PM (GMT)] */ package vazkii.botania.common.block; @@ -17,6 +15,7 @@ import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; + import vazkii.botania.api.mana.IManaCollisionGhost; import vazkii.botania.common.block.tile.TileTinyPlanet; diff --git a/src/main/java/vazkii/botania/common/block/ModBanners.java b/src/main/java/vazkii/botania/common/block/ModBanners.java index c4f6fc3e1..18baf0d92 100644 --- a/src/main/java/vazkii/botania/common/block/ModBanners.java +++ b/src/main/java/vazkii/botania/common/block/ModBanners.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 25, 2015, 7:11:35 PM (GMT)] */ package vazkii.botania.common.block; @@ -16,6 +14,7 @@ import net.minecraft.item.Items; import net.minecraft.tileentity.BannerPattern; import net.minecraft.util.IItemProvider; import net.minecraftforge.registries.IRegistryDelegate; + import vazkii.botania.common.item.ModItems; import java.util.LinkedHashMap; diff --git a/src/main/java/vazkii/botania/common/block/ModBlocks.java b/src/main/java/vazkii/botania/common/block/ModBlocks.java index 1150d0c69..1229e9952 100644 --- a/src/main/java/vazkii/botania/common/block/ModBlocks.java +++ b/src/main/java/vazkii/botania/common/block/ModBlocks.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 14, 2014, 5:17:55 PM (GMT)] */ package vazkii.botania.common.block; @@ -31,6 +29,7 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.IForgeRegistryEntry; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.state.enums.LuminizerVariant; import vazkii.botania.client.render.tile.RenderTilePylon; import vazkii.botania.client.render.tile.TEISR; @@ -376,12 +375,12 @@ public final class ModBlocks { IForgeRegistry r = evt.getRegistry(); Block.Properties builder = Block.Properties.create(Material.PLANTS).doesNotBlockMovement().hardnessAndResistance(0).sound(SoundType.PLANT); - for(DyeColor color : DyeColor.values()) { + for (DyeColor color : DyeColor.values()) { register(r, new BlockModFlower(color, builder), color.getName() + LibBlockNames.MYSTICAL_FLOWER_SUFFIX); } builder = Block.Properties.create(Material.ROCK).hardnessAndResistance(3.5F).sound(SoundType.STONE); - for(BlockAltar.Variant v : BlockAltar.Variant.values()) { + for (BlockAltar.Variant v : BlockAltar.Variant.values()) { r.register(new BlockAltar(v, builder) .setRegistryName(LibMisc.MOD_ID, LibBlockNames.APOTHECARY_PREFIX + v.name().toLowerCase(Locale.ROOT))); } @@ -438,11 +437,11 @@ public final class ModBlocks { register(r, new BlockTurntable(Block.Properties.create(Material.WOOD).hardnessAndResistance(2).sound(SoundType.WOOD)), LibBlockNames.TURNTABLE); register(r, new BlockTinyPlanet(Block.Properties.create(Material.ROCK).hardnessAndResistance(20, 100).sound(SoundType.STONE)), LibBlockNames.TINY_PLANET); register(r, new BlockAlchemyCatalyst(Block.Properties.create(Material.ROCK).hardnessAndResistance(2, 10).sound(SoundType.STONE)), LibBlockNames.ALCHEMY_CATALYST); - + builder = Block.Properties.create(Material.WOOD).hardnessAndResistance(2).sound(SoundType.WOOD); register(r, new BlockOpenCrate(builder), LibBlockNames.OPEN_CRATE); register(r, new BlockCraftyCrate(builder), LibBlockNames.CRAFT_CRATE); - + register(r, new BlockForestEye(Block.Properties.create(Material.IRON).hardnessAndResistance(5, 10).sound(SoundType.METAL)), LibBlockNames.FOREST_EYE); builder = Block.Properties.create(Material.IRON).hardnessAndResistance(3, 10).sound(SoundType.METAL); @@ -456,12 +455,12 @@ public final class ModBlocks { register(r, new BlockForestDrum(BlockForestDrum.Variant.WILD, builder), LibBlockNames.DRUM_WILD); register(r, new BlockForestDrum(BlockForestDrum.Variant.CANOPY, builder), LibBlockNames.DRUM_CANOPY); register(r, new BlockForestDrum(BlockForestDrum.Variant.GATHERING, builder), LibBlockNames.DRUM_GATHERING); - + builder = Block.Properties.create(Material.PLANTS).doesNotBlockMovement().hardnessAndResistance(0).sound(SoundType.PLANT).lightValue(15); for (DyeColor color : DyeColor.values()) { register(r, new BlockShinyFlower(color, builder), color.getName() + LibBlockNames.SHINY_FLOWER_SUFFIX); } - + builder = Block.Properties.create(Material.WOOD).hardnessAndResistance(2, 5).sound(SoundType.WOOD); register(r, new BlockPlatform(BlockPlatform.Variant.ABSTRUSE, builder), LibBlockNames.PLATFORM_ABSTRUSE); register(r, new BlockPlatform(BlockPlatform.Variant.SPECTRAL, builder), LibBlockNames.PLATFORM_SPECTRAL); @@ -480,14 +479,14 @@ 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).nonOpaque()), LibBlockNames.BIFROST); register(r, new BlockSolidVines(Block.Properties.create(Material.TALL_PLANTS).hardnessAndResistance(0.2F).sound(SoundType.PLANT).nonOpaque()), LibBlockNames.SOLID_VINE); - + builder = Block.Properties.create(Material.PLANTS).doesNotBlockMovement().hardnessAndResistance(0).sound(SoundType.PLANT).lightValue(4); - for(DyeColor color : DyeColor.values()) { + for (DyeColor color : DyeColor.values()) { register(r, new BlockBuriedPetals(color, builder), color.getName() + LibBlockNames.BURIED_PETALS_SUFFIX); } builder = Block.Properties.create(Material.EARTH).hardnessAndResistance(0.5F).sound(SoundType.GROUND).lightValue(15); - for(DyeColor color : DyeColor.values()) { + for (DyeColor color : DyeColor.values()) { register(r, new BlockFloatingFlower(color, builder), color.getName() + LibBlockNames.FLOATING_FLOWER_SUFFIX); } @@ -519,22 +518,22 @@ public final class ModBlocks { 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()) { + for (DyeColor color : DyeColor.values()) { register(r, new BlockPetalBlock(color, builder), color.getName() + LibBlockNames.PETAL_BLOCK_SUFFIX); } register(r, new BlockCorporeaIndex(Block.Properties.create(Material.IRON).hardnessAndResistance(5.5F).sound(SoundType.METAL).nonOpaque()), LibBlockNames.CORPOREA_INDEX); register(r, new BlockCorporeaFunnel(Block.Properties.create(Material.IRON).hardnessAndResistance(5.5F).sound(SoundType.METAL)), LibBlockNames.CORPOREA_FUNNEL); - + builder = Block.Properties.create(Material.PLANTS).doesNotBlockMovement().hardnessAndResistance(0).sound(SoundType.PLANT).lightValue(3); - for(DyeColor color : DyeColor.values()) { + for (DyeColor color : DyeColor.values()) { register(r, new BlockModMushroom(color, builder), color.getName() + LibBlockNames.MUSHROOM_SUFFIX); } - + register(r, new BlockPump(Block.Properties.create(Material.ROCK).hardnessAndResistance(2, 10).sound(SoundType.STONE)), LibBlockNames.PUMP); builder = Block.Properties.create(Material.TALL_PLANTS).doesNotBlockMovement().hardnessAndResistance(0).sound(SoundType.PLANT); - for(DyeColor color : DyeColor.values()) { + for (DyeColor color : DyeColor.values()) { register(r, new BlockModDoubleFlower(color, builder), color.getName() + LibBlockNames.DOUBLE_FLOWER_SUFFIX); } @@ -571,7 +570,7 @@ public final class ModBlocks { register(r, new BlockAvatar(Block.Properties.create(Material.WOOD).hardnessAndResistance(2).sound(SoundType.WOOD)), LibBlockNames.AVATAR); builder = Block.Properties.create(Material.ORGANIC).hardnessAndResistance(0.6F).tickRandomly().sound(SoundType.PLANT); - for(BlockAltGrass.Variant v : BlockAltGrass.Variant.values()) { + for (BlockAltGrass.Variant v : BlockAltGrass.Variant.values()) { register(r, new BlockAltGrass(v, builder), v.name().toLowerCase(Locale.ROOT) + LibBlockNames.ALT_GRASS_SUFFIX); } @@ -582,7 +581,7 @@ public final class ModBlocks { public static void registerItemBlocks(RegistryEvent.Register evt) { IForgeRegistry r = evt.getRegistry(); Item.Properties props = ModItems.defaultBuilder(); - + register(r, new BlockItem(whiteFlower, props), whiteFlower.getRegistryName()); register(r, new BlockItem(orangeFlower, props), orangeFlower.getRegistryName()); register(r, new BlockItem(magentaFlower, props), magentaFlower.getRegistryName()); @@ -847,7 +846,7 @@ public final class ModBlocks { public static > void register(IForgeRegistry reg, IForgeRegistryEntry thing, ResourceLocation name) { reg.register(thing.setRegistryName(name)); } - + public static > void register(IForgeRegistry reg, IForgeRegistryEntry thing, String name) { register(reg, thing, new ResourceLocation(LibMisc.MOD_ID, name)); } @@ -859,7 +858,7 @@ public final class ModBlocks { SeedBehaviours.init(); } - + @SubscribeEvent public static void initTileEntities(RegistryEvent.Register> evt) { IForgeRegistry> r = evt.getRegistry(); @@ -922,154 +921,267 @@ public final class ModBlocks { public static Block getFlower(DyeColor color) { switch (color) { - default: - case WHITE: return whiteFlower; - case ORANGE: return orangeFlower; - case MAGENTA: return magentaFlower; - case LIGHT_BLUE: return lightBlueFlower; - case YELLOW: return yellowFlower; - case LIME: return limeFlower; - case PINK: return pinkFlower; - case GRAY: return grayFlower; - case LIGHT_GRAY: return lightGrayFlower; - case CYAN: return cyanFlower; - case PURPLE: return purpleFlower; - case BLUE: return blueFlower; - case BROWN: return brownFlower; - case GREEN: return greenFlower; - case RED: return redFlower; - case BLACK: return blackFlower; + default: + case WHITE: + return whiteFlower; + case ORANGE: + return orangeFlower; + case MAGENTA: + return magentaFlower; + case LIGHT_BLUE: + return lightBlueFlower; + case YELLOW: + return yellowFlower; + case LIME: + return limeFlower; + case PINK: + return pinkFlower; + case GRAY: + return grayFlower; + case LIGHT_GRAY: + return lightGrayFlower; + case CYAN: + return cyanFlower; + case PURPLE: + return purpleFlower; + case BLUE: + return blueFlower; + case BROWN: + return brownFlower; + case GREEN: + return greenFlower; + case RED: + return redFlower; + case BLACK: + return blackFlower; } } - + public static Block getMushroom(DyeColor color) { switch (color) { - default: - case WHITE: return whiteMushroom; - case ORANGE: return orangeMushroom; - case MAGENTA: return magentaMushroom; - case LIGHT_BLUE: return lightBlueMushroom; - case YELLOW: return yellowMushroom; - case LIME: return limeMushroom; - case PINK: return pinkMushroom; - case GRAY: return grayMushroom; - case LIGHT_GRAY: return lightGrayMushroom; - case CYAN: return cyanMushroom; - case PURPLE: return purpleMushroom; - case BLUE: return blueMushroom; - case BROWN: return brownMushroom; - case GREEN: return greenMushroom; - case RED: return redMushroom; - case BLACK: return blackMushroom; + default: + case WHITE: + return whiteMushroom; + case ORANGE: + return orangeMushroom; + case MAGENTA: + return magentaMushroom; + case LIGHT_BLUE: + return lightBlueMushroom; + case YELLOW: + return yellowMushroom; + case LIME: + return limeMushroom; + case PINK: + return pinkMushroom; + case GRAY: + return grayMushroom; + case LIGHT_GRAY: + return lightGrayMushroom; + case CYAN: + return cyanMushroom; + case PURPLE: + return purpleMushroom; + case BLUE: + return blueMushroom; + case BROWN: + return brownMushroom; + case GREEN: + return greenMushroom; + case RED: + return redMushroom; + case BLACK: + return blackMushroom; } } public static Block getBuriedPetal(DyeColor color) { switch (color) { - default: - case WHITE: return whiteBuriedPetals; - case ORANGE: return orangeBuriedPetals; - case MAGENTA: return magentaBuriedPetals; - case LIGHT_BLUE: return lightBlueBuriedPetals; - case YELLOW: return yellowBuriedPetals; - case LIME: return limeBuriedPetals; - case PINK: return pinkBuriedPetals; - case GRAY: return grayBuriedPetals; - case LIGHT_GRAY: return lightGrayBuriedPetals; - case CYAN: return cyanBuriedPetals; - case PURPLE: return purpleBuriedPetals; - case BLUE: return blueBuriedPetals; - case BROWN: return brownBuriedPetals; - case GREEN: return greenBuriedPetals; - case RED: return redBuriedPetals; - case BLACK: return blackBuriedPetals; + default: + case WHITE: + return whiteBuriedPetals; + case ORANGE: + return orangeBuriedPetals; + case MAGENTA: + return magentaBuriedPetals; + case LIGHT_BLUE: + return lightBlueBuriedPetals; + case YELLOW: + return yellowBuriedPetals; + case LIME: + return limeBuriedPetals; + case PINK: + return pinkBuriedPetals; + case GRAY: + return grayBuriedPetals; + case LIGHT_GRAY: + return lightGrayBuriedPetals; + case CYAN: + return cyanBuriedPetals; + case PURPLE: + return purpleBuriedPetals; + case BLUE: + return blueBuriedPetals; + case BROWN: + return brownBuriedPetals; + case GREEN: + return greenBuriedPetals; + case RED: + return redBuriedPetals; + case BLACK: + return blackBuriedPetals; } } - + public static Block getShinyFlower(DyeColor color) { switch (color) { - default: - case WHITE: return whiteShinyFlower; - case ORANGE: return orangeShinyFlower; - case MAGENTA: return magentaShinyFlower; - case LIGHT_BLUE: return lightBlueShinyFlower; - case YELLOW: return yellowShinyFlower; - case LIME: return limeShinyFlower; - case PINK: return pinkShinyFlower; - case GRAY: return grayShinyFlower; - case LIGHT_GRAY: return lightGrayShinyFlower; - case CYAN: return cyanShinyFlower; - case PURPLE: return purpleShinyFlower; - case BLUE: return blueShinyFlower; - case BROWN: return brownShinyFlower; - case GREEN: return greenShinyFlower; - case RED: return redShinyFlower; - case BLACK: return blackShinyFlower; + default: + case WHITE: + return whiteShinyFlower; + case ORANGE: + return orangeShinyFlower; + case MAGENTA: + return magentaShinyFlower; + case LIGHT_BLUE: + return lightBlueShinyFlower; + case YELLOW: + return yellowShinyFlower; + case LIME: + return limeShinyFlower; + case PINK: + return pinkShinyFlower; + case GRAY: + return grayShinyFlower; + case LIGHT_GRAY: + return lightGrayShinyFlower; + case CYAN: + return cyanShinyFlower; + case PURPLE: + return purpleShinyFlower; + case BLUE: + return blueShinyFlower; + case BROWN: + return brownShinyFlower; + case GREEN: + return greenShinyFlower; + case RED: + return redShinyFlower; + case BLACK: + return blackShinyFlower; } } public static Block getFloatingFlower(DyeColor color) { switch (color) { - default: - case WHITE: return whiteFloatingFlower; - case ORANGE: return orangeFloatingFlower; - case MAGENTA: return magentaFloatingFlower; - case LIGHT_BLUE: return lightBlueFloatingFlower; - case YELLOW: return yellowFloatingFlower; - case LIME: return limeFloatingFlower; - case PINK: return pinkFloatingFlower; - case GRAY: return grayFloatingFlower; - case LIGHT_GRAY: return lightGrayFloatingFlower; - case CYAN: return cyanFloatingFlower; - case PURPLE: return purpleFloatingFlower; - case BLUE: return blueFloatingFlower; - case BROWN: return brownFloatingFlower; - case GREEN: return greenFloatingFlower; - case RED: return redFloatingFlower; - case BLACK: return blackFloatingFlower; + default: + case WHITE: + return whiteFloatingFlower; + case ORANGE: + return orangeFloatingFlower; + case MAGENTA: + return magentaFloatingFlower; + case LIGHT_BLUE: + return lightBlueFloatingFlower; + case YELLOW: + return yellowFloatingFlower; + case LIME: + return limeFloatingFlower; + case PINK: + return pinkFloatingFlower; + case GRAY: + return grayFloatingFlower; + case LIGHT_GRAY: + return lightGrayFloatingFlower; + case CYAN: + return cyanFloatingFlower; + case PURPLE: + return purpleFloatingFlower; + case BLUE: + return blueFloatingFlower; + case BROWN: + return brownFloatingFlower; + case GREEN: + return greenFloatingFlower; + case RED: + return redFloatingFlower; + case BLACK: + return blackFloatingFlower; } } - + public static Block getDoubleFlower(DyeColor color) { switch (color) { - default: - case WHITE: return doubleFlowerWhite; - case ORANGE: return doubleFlowerOrange; - case MAGENTA: return doubleFlowerMagenta; - case LIGHT_BLUE: return doubleFlowerLightBlue; - case YELLOW: return doubleFlowerYellow; - case LIME: return doubleFlowerLime; - case PINK: return doubleFlowerPink; - case GRAY: return doubleFlowerGray; - case LIGHT_GRAY: return doubleFlowerLightGray; - case CYAN: return doubleFlowerCyan; - case PURPLE: return doubleFlowerPurple; - case BLUE: return doubleFlowerBlue; - case BROWN: return doubleFlowerBrown; - case GREEN: return doubleFlowerGreen; - case RED: return doubleFlowerRed; - case BLACK: return doubleFlowerBlack; + default: + case WHITE: + return doubleFlowerWhite; + case ORANGE: + return doubleFlowerOrange; + case MAGENTA: + return doubleFlowerMagenta; + case LIGHT_BLUE: + return doubleFlowerLightBlue; + case YELLOW: + return doubleFlowerYellow; + case LIME: + return doubleFlowerLime; + case PINK: + return doubleFlowerPink; + case GRAY: + return doubleFlowerGray; + case LIGHT_GRAY: + return doubleFlowerLightGray; + case CYAN: + return doubleFlowerCyan; + case PURPLE: + return doubleFlowerPurple; + case BLUE: + return doubleFlowerBlue; + case BROWN: + return doubleFlowerBrown; + case GREEN: + return doubleFlowerGreen; + case RED: + return doubleFlowerRed; + case BLACK: + return doubleFlowerBlack; } } + public static Block getPetalBlock(DyeColor color) { switch (color) { - default: - case WHITE: return petalBlockWhite; - case ORANGE: return petalBlockOrange; - case MAGENTA: return petalBlockMagenta; - case LIGHT_BLUE: return petalBlockLightBlue; - case YELLOW: return petalBlockYellow; - case LIME: return petalBlockLime; - case PINK: return petalBlockPink; - case GRAY: return petalBlockGray; - case LIGHT_GRAY: return petalBlockSilver; - case CYAN: return petalBlockCyan; - case PURPLE: return petalBlockPurple; - case BLUE: return petalBlockBlue; - case BROWN: return petalBlockBrown; - case GREEN: return petalBlockGreen; - case RED: return petalBlockRed; - case BLACK: return petalBlockBlack; + default: + case WHITE: + return petalBlockWhite; + case ORANGE: + return petalBlockOrange; + case MAGENTA: + return petalBlockMagenta; + case LIGHT_BLUE: + return petalBlockLightBlue; + case YELLOW: + return petalBlockYellow; + case LIME: + return petalBlockLime; + case PINK: + return petalBlockPink; + case GRAY: + return petalBlockGray; + case LIGHT_GRAY: + return petalBlockSilver; + case CYAN: + return petalBlockCyan; + case PURPLE: + return petalBlockPurple; + case BLUE: + return petalBlockBlue; + case BROWN: + return petalBlockBrown; + case GREEN: + return petalBlockGreen; + case RED: + return petalBlockRed; + case BLACK: + return petalBlockBlack; } } } diff --git a/src/main/java/vazkii/botania/common/block/ModFluffBlocks.java b/src/main/java/vazkii/botania/common/block/ModFluffBlocks.java index d2b91a7a2..a25c9b836 100644 --- a/src/main/java/vazkii/botania/common/block/ModFluffBlocks.java +++ b/src/main/java/vazkii/botania/common/block/ModFluffBlocks.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 24, 2015, 2:35:08 PM (GMT)] */ package vazkii.botania.common.block; @@ -27,6 +25,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.common.block.decor.panes.BlockModPane; import vazkii.botania.common.block.decor.stairs.BlockModStairs; import vazkii.botania.common.item.ModItems; @@ -34,11 +33,11 @@ import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; import static vazkii.botania.common.block.ModBlocks.register; +import static vazkii.botania.common.lib.LibBlockNames.FENCE_GATE_SUFFIX; +import static vazkii.botania.common.lib.LibBlockNames.FENCE_SUFFIX; import static vazkii.botania.common.lib.LibBlockNames.SLAB_SUFFIX; import static vazkii.botania.common.lib.LibBlockNames.STAIR_SUFFIX; import static vazkii.botania.common.lib.LibBlockNames.WALL_SUFFIX; -import static vazkii.botania.common.lib.LibBlockNames.FENCE_SUFFIX; -import static vazkii.botania.common.lib.LibBlockNames.FENCE_GATE_SUFFIX; import static vazkii.botania.common.lib.ResourceLocationHelper.prefix; @Mod.EventBusSubscriber(modid = LibMisc.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) @@ -202,7 +201,7 @@ public final class ModFluffBlocks { @ObjectHolder(LibBlockNames.METAMORPHIC_PREFIX + "mesa_bricks" + SLAB_SUFFIX) public static Block biomeBrickMesaSlab; @ObjectHolder(LibBlockNames.METAMORPHIC_PREFIX + "mesa_bricks" + STAIR_SUFFIX) public static Block biomeBrickMesaStairs; @ObjectHolder("chiseled_" + LibBlockNames.METAMORPHIC_PREFIX + "mesa_bricks") public static Block biomeChiseledBrickMesa; - + @ObjectHolder("white" + LibBlockNames.PAVEMENT_SUFFIX) public static Block whitePavement; @ObjectHolder("black" + LibBlockNames.PAVEMENT_SUFFIX) public static Block blackPavement; @ObjectHolder("blue" + LibBlockNames.PAVEMENT_SUFFIX) public static Block bluePavement; @@ -252,7 +251,7 @@ public final class ModFluffBlocks { register(r, new BlockModStairs(base.getDefaultState(), Block.Properties.from(base)), LibBlockNames.LIVING_ROCK + STAIR_SUFFIX); register(r, new SlabBlock(Block.Properties.from(base)), LibBlockNames.LIVING_ROCK + SLAB_SUFFIX); register(r, new WallBlock(Block.Properties.from(base)), LibBlockNames.LIVING_ROCK + WALL_SUFFIX); - + base = r.getValue(prefix(LibBlockNames.LIVING_ROCK_BRICK)); register(r, new BlockModStairs(base.getDefaultState(), Block.Properties.from(base)), LibBlockNames.LIVING_ROCK_BRICK + STAIR_SUFFIX); register(r, new SlabBlock(Block.Properties.from(base)), LibBlockNames.LIVING_ROCK_BRICK + SLAB_SUFFIX); @@ -267,7 +266,7 @@ public final class ModFluffBlocks { base = r.getValue(prefix(LibBlockNames.DREAM_WOOD_PLANKS)); register(r, new BlockModStairs(base.getDefaultState(), Block.Properties.from(base)), LibBlockNames.DREAM_WOOD_PLANKS + STAIR_SUFFIX); register(r, new SlabBlock(Block.Properties.from(base)), LibBlockNames.DREAM_WOOD_PLANKS + SLAB_SUFFIX); - + Block.Properties props = Block.Properties.from(Blocks.QUARTZ_BLOCK); for (String variant : LibBlockNames.QUARTZ_VARIANTS) { @@ -306,7 +305,7 @@ public final class ModFluffBlocks { register(r, new SlabBlock(props), base.getRegistryName().getPath() + SLAB_SUFFIX); register(r, new BlockMod(props), "chiseled_" + LibBlockNames.METAMORPHIC_PREFIX + variant + "_bricks"); } - + base = r.getValue(prefix(LibBlockNames.SHIMMERROCK)); register(r, new SlabBlock(Block.Properties.from(base)), LibBlockNames.SHIMMERROCK + SLAB_SUFFIX); register(r, new BlockModStairs(base.getDefaultState(), Block.Properties.from(base)), LibBlockNames.SHIMMERROCK + STAIR_SUFFIX); @@ -324,37 +323,37 @@ public final class ModFluffBlocks { base = r.getValue(prefix(LibBlockNames.BIFROST_PERM)); register(r, new BlockModPane(Block.Properties.from(base)), LibBlockNames.BIFROST + "_pane"); } - + @SubscribeEvent public static void registerItemBlocks(RegistryEvent.Register evt) { IForgeRegistry r = evt.getRegistry(); Item.Properties props = ModItems.defaultBuilder(); - + r.register(new BlockItem(livingwoodStairs, props).setRegistryName(livingwoodStairs.getRegistryName())); r.register(new BlockItem(livingwoodSlab, props).setRegistryName(livingwoodSlab.getRegistryName())); r.register(new BlockItem(livingwoodWall, props).setRegistryName(livingwoodWall.getRegistryName())); r.register(new BlockItem(livingwoodFence, props).setRegistryName(livingwoodFence.getRegistryName())); r.register(new BlockItem(livingwoodFenceGate, props).setRegistryName(livingwoodFenceGate.getRegistryName())); - + r.register(new BlockItem(livingwoodPlankStairs, props).setRegistryName(livingwoodPlankStairs.getRegistryName())); r.register(new BlockItem(livingwoodPlankSlab, props).setRegistryName(livingwoodPlankSlab.getRegistryName())); - + r.register(new BlockItem(livingrockStairs, props).setRegistryName(livingrockStairs.getRegistryName())); r.register(new BlockItem(livingrockSlab, props).setRegistryName(livingrockSlab.getRegistryName())); r.register(new BlockItem(livingrockWall, props).setRegistryName(livingrockWall.getRegistryName())); - + r.register(new BlockItem(livingrockBrickStairs, props).setRegistryName(livingrockBrickStairs.getRegistryName())); r.register(new BlockItem(livingrockBrickSlab, props).setRegistryName(livingrockBrickSlab.getRegistryName())); - + r.register(new BlockItem(dreamwoodStairs, props).setRegistryName(dreamwoodStairs.getRegistryName())); r.register(new BlockItem(dreamwoodSlab, props).setRegistryName(dreamwoodSlab.getRegistryName())); r.register(new BlockItem(dreamwoodWall, props).setRegistryName(dreamwoodWall.getRegistryName())); r.register(new BlockItem(dreamwoodFence, props).setRegistryName(dreamwoodFence.getRegistryName())); r.register(new BlockItem(dreamwoodFenceGate, props).setRegistryName(dreamwoodFenceGate.getRegistryName())); - + r.register(new BlockItem(dreamwoodPlankStairs, props).setRegistryName(dreamwoodPlankStairs.getRegistryName())); r.register(new BlockItem(dreamwoodPlankSlab, props).setRegistryName(dreamwoodPlankSlab.getRegistryName())); - + r.register(new BlockItem(darkQuartz, props).setRegistryName(darkQuartz.getRegistryName())); r.register(new BlockItem(darkQuartzPillar, props).setRegistryName(darkQuartzPillar.getRegistryName())); r.register(new BlockItem(darkQuartzChiseled, props).setRegistryName(darkQuartzChiseled.getRegistryName())); @@ -366,37 +365,37 @@ public final class ModFluffBlocks { r.register(new BlockItem(manaQuartzChiseled, props).setRegistryName(manaQuartzChiseled.getRegistryName())); r.register(new BlockItem(manaQuartzSlab, props).setRegistryName(manaQuartzSlab.getRegistryName())); r.register(new BlockItem(manaQuartzStairs, props).setRegistryName(manaQuartzStairs.getRegistryName())); - + r.register(new BlockItem(blazeQuartz, props).setRegistryName(blazeQuartz.getRegistryName())); r.register(new BlockItem(blazeQuartzPillar, props).setRegistryName(blazeQuartzPillar.getRegistryName())); r.register(new BlockItem(blazeQuartzChiseled, props).setRegistryName(blazeQuartzChiseled.getRegistryName())); r.register(new BlockItem(blazeQuartzSlab, props).setRegistryName(blazeQuartzSlab.getRegistryName())); r.register(new BlockItem(blazeQuartzStairs, props).setRegistryName(blazeQuartzStairs.getRegistryName())); - + r.register(new BlockItem(lavenderQuartz, props).setRegistryName(lavenderQuartz.getRegistryName())); r.register(new BlockItem(lavenderQuartzPillar, props).setRegistryName(lavenderQuartzPillar.getRegistryName())); r.register(new BlockItem(lavenderQuartzChiseled, props).setRegistryName(lavenderQuartzChiseled.getRegistryName())); r.register(new BlockItem(lavenderQuartzSlab, props).setRegistryName(lavenderQuartzSlab.getRegistryName())); r.register(new BlockItem(lavenderQuartzStairs, props).setRegistryName(lavenderQuartzStairs.getRegistryName())); - + r.register(new BlockItem(redQuartz, props).setRegistryName(redQuartz.getRegistryName())); r.register(new BlockItem(redQuartzPillar, props).setRegistryName(redQuartzPillar.getRegistryName())); r.register(new BlockItem(redQuartzChiseled, props).setRegistryName(redQuartzChiseled.getRegistryName())); r.register(new BlockItem(redQuartzSlab, props).setRegistryName(redQuartzSlab.getRegistryName())); r.register(new BlockItem(redQuartzStairs, props).setRegistryName(redQuartzStairs.getRegistryName())); - + r.register(new BlockItem(elfQuartz, props).setRegistryName(elfQuartz.getRegistryName())); r.register(new BlockItem(elfQuartzPillar, props).setRegistryName(elfQuartzPillar.getRegistryName())); r.register(new BlockItem(elfQuartzChiseled, props).setRegistryName(elfQuartzChiseled.getRegistryName())); r.register(new BlockItem(elfQuartzSlab, props).setRegistryName(elfQuartzSlab.getRegistryName())); r.register(new BlockItem(elfQuartzStairs, props).setRegistryName(elfQuartzStairs.getRegistryName())); - + r.register(new BlockItem(sunnyQuartz, props).setRegistryName(sunnyQuartz.getRegistryName())); r.register(new BlockItem(sunnyQuartzPillar, props).setRegistryName(sunnyQuartzPillar.getRegistryName())); r.register(new BlockItem(sunnyQuartzChiseled, props).setRegistryName(sunnyQuartzChiseled.getRegistryName())); r.register(new BlockItem(sunnyQuartzSlab, props).setRegistryName(sunnyQuartzSlab.getRegistryName())); r.register(new BlockItem(sunnyQuartzStairs, props).setRegistryName(sunnyQuartzStairs.getRegistryName())); - + r.register(new BlockItem(biomeStoneForest, props).setRegistryName(biomeStoneForest.getRegistryName())); r.register(new BlockItem(biomeStoneForestSlab, props).setRegistryName(biomeStoneForestSlab.getRegistryName())); r.register(new BlockItem(biomeStoneForestStairs, props).setRegistryName(biomeStoneForestStairs.getRegistryName())); @@ -492,7 +491,7 @@ public final class ModFluffBlocks { r.register(new BlockItem(biomeCobblestoneMesaStairs, props).setRegistryName(biomeCobblestoneMesaStairs.getRegistryName())); r.register(new BlockItem(biomeWallMesa, props).setRegistryName(biomeWallMesa.getRegistryName())); r.register(new BlockItem(biomeChiseledBrickMesa, props).setRegistryName(biomeChiseledBrickMesa.getRegistryName())); - + r.register(new BlockItem(whitePavement, props).setRegistryName(whitePavement.getRegistryName())); r.register(new BlockItem(blackPavement, props).setRegistryName(blackPavement.getRegistryName())); r.register(new BlockItem(bluePavement, props).setRegistryName(bluePavement.getRegistryName())); @@ -513,13 +512,13 @@ public final class ModFluffBlocks { r.register(new BlockItem(yellowPavementStair, props).setRegistryName(yellowPavementStair.getRegistryName())); r.register(new BlockItem(redPavementStair, props).setRegistryName(redPavementStair.getRegistryName())); r.register(new BlockItem(greenPavementStair, props).setRegistryName(greenPavementStair.getRegistryName())); - + r.register(new BlockItem(shimmerrockSlab, props).setRegistryName(shimmerrockSlab.getRegistryName())); r.register(new BlockItem(shimmerrockStairs, props).setRegistryName(shimmerrockStairs.getRegistryName())); - + r.register(new BlockItem(shimmerwoodPlankSlab, props).setRegistryName(shimmerwoodPlankSlab.getRegistryName())); r.register(new BlockItem(shimmerwoodPlankStairs, props).setRegistryName(shimmerwoodPlankStairs.getRegistryName())); - + r.register(new BlockItem(managlassPane, props).setRegistryName(managlassPane.getRegistryName())); r.register(new BlockItem(alfglassPane, props).setRegistryName(alfglassPane.getRegistryName())); r.register(new BlockItem(bifrostPane, props).setRegistryName(bifrostPane.getRegistryName())); diff --git a/src/main/java/vazkii/botania/common/block/ModSubtiles.java b/src/main/java/vazkii/botania/common/block/ModSubtiles.java index a6ec8f560..07a485193 100644 --- a/src/main/java/vazkii/botania/common/block/ModSubtiles.java +++ b/src/main/java/vazkii/botania/common/block/ModSubtiles.java @@ -1,7 +1,16 @@ +/* + * This class is 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 + */ package vazkii.botania.common.block; import com.google.common.collect.ImmutableList; import com.mojang.datafixers.util.Pair; + import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.block.SoundType; @@ -15,6 +24,7 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.TileEntitySpecialFlower; import vazkii.botania.common.block.subtile.SubTileManastar; import vazkii.botania.common.block.subtile.SubTilePureDaisy; @@ -94,7 +104,7 @@ public class ModSubtiles { @ObjectHolder("solegnolia") public static Block solegnolia; @ObjectHolder("solegnolia_chibi") public static Block solegnoliaChibi; @ObjectHolder("orechid_ignem") public static Block orechidIgnem; - + @ObjectHolder("floating_pure_daisy") public static Block pureDaisyFloating; @ObjectHolder("floating_manastar") public static Block manastarFloating; @ObjectHolder("floating_hydroangeas") public static Block hydroangeasFloating; @@ -144,7 +154,7 @@ public class ModSubtiles { @ObjectHolder("floating_solegnolia") public static Block solegnoliaFloating; @ObjectHolder("floating_solegnolia_chibi") public static Block solegnoliaChibiFloating; @ObjectHolder("floating_orechid_ignem") public static Block orechidIgnemFloating; - + private static ResourceLocation floating(ResourceLocation orig) { return new ResourceLocation(orig.getNamespace(), "floating_" + orig.getPath()); } diff --git a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaBase.java b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaBase.java index 730a7bd40..59651604d 100644 --- a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaBase.java +++ b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaBase.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 15, 2015, 12:23:33 AM (GMT)] */ package vazkii.botania.common.block.corporea; @@ -14,6 +12,7 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import vazkii.botania.common.block.BlockMod; import vazkii.botania.common.block.tile.TileSimpleInventory; import vazkii.botania.common.core.helper.InventoryHelper; diff --git a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaCrystalCube.java b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaCrystalCube.java index fa42fe128..a6da83b39 100644 --- a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaCrystalCube.java +++ b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaCrystalCube.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 30, 2015, 3:56:19 PM (GMT)] */ package vazkii.botania.common.block.corporea; @@ -24,6 +22,7 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.wand.IWandable; import vazkii.botania.common.block.tile.corporea.TileCorporeaBase; @@ -42,7 +41,7 @@ public class BlockCorporeaCrystalCube extends BlockCorporeaBase implements IWand @Override public void onBlockClicked(BlockState state, World world, BlockPos pos, PlayerEntity player) { - if(!world.isRemote) { + if (!world.isRemote) { TileCorporeaCrystalCube cube = (TileCorporeaCrystalCube) world.getTileEntity(pos); cube.doRequest(player.isSneaking()); } @@ -57,15 +56,18 @@ public class BlockCorporeaCrystalCube extends BlockCorporeaBase implements IWand @Override public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { ItemStack stack = player.getHeldItem(hand); - if(!stack.isEmpty()) { - if(stack.getItem() == ModItems.twigWand && player.isSneaking()) + if (!stack.isEmpty()) { + if (stack.getItem() == ModItems.twigWand && player.isSneaking()) { return ActionResultType.PASS; + } TileCorporeaCrystalCube cube = (TileCorporeaCrystalCube) world.getTileEntity(pos); - if(cube.locked) { - if(!world.isRemote) + if (cube.locked) { + if (!world.isRemote) { player.sendStatusMessage(new TranslationTextComponent("botaniamisc.crystalCubeLocked"), false); - } else + } + } else { cube.setRequestTarget(stack); + } return ActionResultType.SUCCESS; } return ActionResultType.PASS; @@ -73,11 +75,12 @@ public class BlockCorporeaCrystalCube extends BlockCorporeaBase implements IWand @Override public boolean onUsedByWand(PlayerEntity player, ItemStack stack, World world, BlockPos pos, Direction side) { - if(player == null || player.isSneaking()) { + if (player == null || player.isSneaking()) { TileCorporeaCrystalCube cube = (TileCorporeaCrystalCube) world.getTileEntity(pos); cube.locked = !cube.locked; - if(!world.isRemote) + if (!world.isRemote) { VanillaPacketDispatcher.dispatchTEToNearbyPlayers(cube); + } return true; } return false; diff --git a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaFunnel.java b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaFunnel.java index 2218f6f1f..0707ce9a9 100644 --- a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaFunnel.java +++ b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaFunnel.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 16, 2015, 2:17:05 PM (GMT)] */ package vazkii.botania.common.block.corporea; @@ -16,6 +14,7 @@ import net.minecraft.state.StateContainer; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; + import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.common.block.tile.corporea.TileCorporeaBase; import vazkii.botania.common.block.tile.corporea.TileCorporeaFunnel; @@ -39,11 +38,12 @@ public class BlockCorporeaFunnel extends BlockCorporeaBase { boolean power = world.getRedstonePowerFromNeighbors(pos) > 0 || world.getRedstonePowerFromNeighbors(pos.up()) > 0; boolean powered = state.get(BotaniaStateProps.POWERED); - if(power && !powered) { + if (power && !powered) { ((TileCorporeaFunnel) world.getTileEntity(pos)).doRequest(); world.setBlockState(pos, state.with(BotaniaStateProps.POWERED, true), 4); - } else if(!power && powered) + } else if (!power && powered) { world.setBlockState(pos, state.with(BotaniaStateProps.POWERED, false), 4); + } } @Nonnull diff --git a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaIndex.java b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaIndex.java index 1daff41c0..1f78f6007 100644 --- a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaIndex.java +++ b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaIndex.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 15, 2015, 12:49:58 AM (GMT)] */ package vazkii.botania.common.block.corporea; @@ -14,6 +12,7 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockRenderType; import net.minecraft.block.BlockState; import net.minecraft.world.IBlockReader; + import vazkii.botania.common.block.tile.corporea.TileCorporeaBase; import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex; diff --git a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaInterceptor.java b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaInterceptor.java index b6a4593e7..b04f8b773 100644 --- a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaInterceptor.java +++ b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaInterceptor.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 19, 2015, 6:18:03 PM (GMT)] */ package vazkii.botania.common.block.corporea; @@ -17,13 +15,14 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; + import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.common.block.tile.corporea.TileCorporeaBase; import vazkii.botania.common.block.tile.corporea.TileCorporeaInterceptor; import javax.annotation.Nonnull; + import java.util.Random; public class BlockCorporeaInterceptor extends BlockCorporeaBase { diff --git a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaRetainer.java b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaRetainer.java index d55e7c050..3d7ac8e8f 100644 --- a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaRetainer.java +++ b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaRetainer.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 28, 2015, 11:53:13 AM (GMT)] */ package vazkii.botania.common.block.corporea; @@ -17,6 +15,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; + import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.common.block.BlockMod; import vazkii.botania.common.block.tile.corporea.TileCorporeaRetainer; @@ -40,11 +39,12 @@ public class BlockCorporeaRetainer extends BlockMod { boolean power = world.getRedstonePowerFromNeighbors(pos) > 0 || world.getRedstonePowerFromNeighbors(pos.up()) > 0; boolean powered = state.get(BotaniaStateProps.POWERED); - if(power && !powered) { + if (power && !powered) { ((TileCorporeaRetainer) world.getTileEntity(pos)).fulfilRequest(); world.setBlockState(pos, state.with(BotaniaStateProps.POWERED, true)); - } else if(!power && powered) + } else if (!power && powered) { world.setBlockState(pos, state.with(BotaniaStateProps.POWERED, false)); + } } @Override diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockBuriedPetals.java b/src/main/java/vazkii/botania/common/block/decor/BlockBuriedPetals.java index a5088eb94..08c872048 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockBuriedPetals.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockBuriedPetals.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 28, 2014, 6:43:33 PM (GMT)] */ package vazkii.botania.common.block.decor; @@ -21,10 +19,12 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.client.fx.SparkleParticleData; import vazkii.botania.common.block.BlockModFlower; import javax.annotation.Nonnull; + import java.util.Random; public class BlockBuriedPetals extends BlockModFlower { diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockElfGlass.java b/src/main/java/vazkii/botania/common/block/decor/BlockElfGlass.java index d8af853b2..79252b142 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockElfGlass.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockElfGlass.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 8, 2014, 6:40:17 PM (GMT)] */ package vazkii.botania.common.block.decor; import net.minecraft.block.AbstractGlassBlock; import net.minecraft.item.ItemStack; + import vazkii.botania.api.recipe.IElvenItem; public class BlockElfGlass extends AbstractGlassBlock implements IElvenItem { diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockFloatingFlower.java b/src/main/java/vazkii/botania/common/block/decor/BlockFloatingFlower.java index 6370f43f6..0ea52cbe3 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockFloatingFlower.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockFloatingFlower.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 8, 2014, 10:16:53 PM (GMT)] */ package vazkii.botania.common.block.decor; @@ -27,6 +25,7 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.item.IFloatingFlower; @@ -38,6 +37,7 @@ import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.item.IFloatingFlowerVariant; import javax.annotation.Nonnull; + import java.util.Random; public class BlockFloatingFlower extends BlockMod { @@ -70,35 +70,37 @@ public class BlockFloatingFlower extends BlockMod { int g = (hex & 0xFF00) >> 8; int b = hex & 0xFF; - if(rand.nextDouble() < ConfigHandler.CLIENT.flowerParticleFrequency.get()) { - SparkleParticleData data = SparkleParticleData.sparkle(rand.nextFloat(), r / 255F, g / 255F, b / 255F, 5); - world.addParticle(data, pos.getX() + 0.3 + rand.nextFloat() * 0.5, pos.getY() + 0.5 + rand.nextFloat() * 0.5, pos.getZ() + 0.3 + rand.nextFloat() * 0.5, 0, 0, 0); - } + if (rand.nextDouble() < ConfigHandler.CLIENT.flowerParticleFrequency.get()) { + SparkleParticleData data = SparkleParticleData.sparkle(rand.nextFloat(), r / 255F, g / 255F, b / 255F, 5); + world.addParticle(data, pos.getX() + 0.3 + rand.nextFloat() * 0.5, pos.getY() + 0.5 + rand.nextFloat() * 0.5, pos.getZ() + 0.3 + rand.nextFloat() * 0.5, 0, 0, 0); + } } @Override public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { ItemStack stack = player.getHeldItem(hand); TileEntity te = world.getTileEntity(pos); - if(!stack.isEmpty() && te != null && te.getCapability(BotaniaAPI.FLOATING_FLOWER_CAP).isPresent()) { + if (!stack.isEmpty() && te != null && te.getCapability(BotaniaAPI.FLOATING_FLOWER_CAP).isPresent()) { IFloatingFlower flower = te.getCapability(BotaniaAPI.FLOATING_FLOWER_CAP).orElseThrow(IllegalStateException::new); IslandType type = null; - if(stack.getItem() == Items.SNOWBALL) + if (stack.getItem() == Items.SNOWBALL) { type = IslandType.SNOW; - else if(stack.getItem() instanceof IFloatingFlowerVariant) { + } else if (stack.getItem() instanceof IFloatingFlowerVariant) { IslandType newType = ((IFloatingFlowerVariant) stack.getItem()).getIslandType(stack); - if(newType != null) + if (newType != null) { type = newType; + } } - if(type != null && type != flower.getIslandType()) { - if(!world.isRemote) { + if (type != null && type != flower.getIslandType()) { + if (!world.isRemote) { flower.setIslandType(type); VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos); } - if(!player.abilities.isCreativeMode) + if (!player.abilities.isCreativeMode) { stack.shrink(1); + } return ActionResultType.SUCCESS; } } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockManaFlame.java b/src/main/java/vazkii/botania/common/block/decor/BlockManaFlame.java index 315837a77..e90543e6c 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockManaFlame.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockManaFlame.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Dec 21, 2014, 12:28:06 AM (GMT)] */ package vazkii.botania.common.block.decor; @@ -25,6 +23,7 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.items.ItemHandlerHelper; + import vazkii.botania.common.Botania; import vazkii.botania.common.block.BlockMod; import vazkii.botania.common.block.tile.TileManaFlame; @@ -54,10 +53,10 @@ public class BlockManaFlame extends BlockMod { @Override public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { - if(Botania.gardenOfGlassLoaded) { + if (Botania.gardenOfGlassLoaded) { ItemStack stack = player.getHeldItem(hand); - if(!stack.isEmpty() && ItemTags.SAPLINGS.contains(stack.getItem()) && !player.inventory.hasItemStack(new ItemStack(ModItems.lexicon))) { - if(!world.isRemote) { + if (!stack.isEmpty() && ItemTags.SAPLINGS.contains(stack.getItem()) && !player.inventory.hasItemStack(new ItemStack(ModItems.lexicon))) { + if (!world.isRemote) { stack.shrink(1); ItemHandlerHelper.giveItemToPlayer(player, new ItemStack(ModItems.lexicon)); } diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockModMushroom.java b/src/main/java/vazkii/botania/common/block/decor/BlockModMushroom.java index e079c468d..b326011fa 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockModMushroom.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockModMushroom.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 23, 2015, 4:24:08 PM (GMT)] */ package vazkii.botania.common.block.decor; @@ -26,12 +24,14 @@ import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.item.IHornHarvestable; import vazkii.botania.api.recipe.ICustomApothecaryColor; import vazkii.botania.client.fx.SparkleParticleData; import vazkii.botania.common.core.handler.ConfigHandler; import javax.annotation.Nonnull; + import java.util.Random; public class BlockModMushroom extends MushroomBlock implements IHornHarvestable, ICustomApothecaryColor { @@ -74,10 +74,10 @@ public class BlockModMushroom extends MushroomBlock implements IHornHarvestable, int g = (hex & 0xFF00) >> 8; int b = hex & 0xFF; - if(rand.nextDouble() < ConfigHandler.CLIENT.flowerParticleFrequency.get() * 0.25F) { - SparkleParticleData data = SparkleParticleData.sparkle(rand.nextFloat(), r / 255F, g / 255F, b / 255F, 5); - world.addParticle(data, pos.getX() + 0.3 + rand.nextFloat() * 0.5, pos.getY() + 0.5 + rand.nextFloat() * 0.5, pos.getZ() + 0.3 + rand.nextFloat() * 0.5, 0, 0, 0); - } + if (rand.nextDouble() < ConfigHandler.CLIENT.flowerParticleFrequency.get() * 0.25F) { + SparkleParticleData data = SparkleParticleData.sparkle(rand.nextFloat(), r / 255F, g / 255F, b / 255F, 5); + world.addParticle(data, pos.getX() + 0.3 + rand.nextFloat() * 0.5, pos.getY() + 0.5 + rand.nextFloat() * 0.5, pos.getZ() + 0.3 + rand.nextFloat() * 0.5, 0, 0, 0); + } } @Override diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockPetalBlock.java b/src/main/java/vazkii/botania/common/block/decor/BlockPetalBlock.java index 33132ae56..19b7774d4 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockPetalBlock.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockPetalBlock.java @@ -1,21 +1,21 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 9, 2015, 5:17:17 PM (GMT)] */ package vazkii.botania.common.block.decor; import net.minecraft.item.DyeColor; + import vazkii.botania.common.block.BlockMod; public class BlockPetalBlock extends BlockMod { public final DyeColor color; + public BlockPetalBlock(DyeColor color, Properties builder) { super(builder); this.color = color; diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockShinyFlower.java b/src/main/java/vazkii/botania/common/block/decor/BlockShinyFlower.java index 047b7a860..6198c9171 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockShinyFlower.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockShinyFlower.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 2, 2014, 8:15:49 PM (GMT)] */ package vazkii.botania.common.block.decor; @@ -16,6 +14,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; + import vazkii.botania.api.item.IHornHarvestable; import vazkii.botania.common.block.BlockModFlower; diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockStarfield.java b/src/main/java/vazkii/botania/common/block/decor/BlockStarfield.java index 40f4f4f8e..b36d82624 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockStarfield.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockStarfield.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 7, 2014, 6:36:37 PM (GMT)] */ package vazkii.botania.common.block.decor; @@ -16,8 +14,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.common.block.BlockMod; import vazkii.botania.common.block.tile.TileStarfield; diff --git a/src/main/java/vazkii/botania/common/block/decor/BlockTinyPotato.java b/src/main/java/vazkii/botania/common/block/decor/BlockTinyPotato.java index b459b74cf..4c5adc04a 100644 --- a/src/main/java/vazkii/botania/common/block/decor/BlockTinyPotato.java +++ b/src/main/java/vazkii/botania/common/block/decor/BlockTinyPotato.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 18, 2014, 7:58:08 PM (GMT)] */ package vazkii.botania.common.block.decor; @@ -32,6 +30,7 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; + import vazkii.botania.common.block.BlockMod; import vazkii.botania.common.block.tile.TileSimpleInventory; import vazkii.botania.common.block.tile.TileTinyPotato; @@ -72,11 +71,11 @@ public class BlockTinyPotato extends BlockMod { @Override public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileTinyPotato) { + if (tile instanceof TileTinyPotato) { ((TileTinyPotato) tile).interact(player, hand, player.getHeldItem(hand), hit.getFace()); - if(!world.isRemote) { + if (!world.isRemote) { AxisAlignedBB box = SHAPE.getBoundingBox(); - ((ServerWorld) world).spawnParticle(ParticleTypes.HEART, pos.getX() + box.minX + Math.random() * (box.maxX - box.minX), pos.getY() + box.maxY, pos.getZ() + box.minZ + Math.random() * (box.maxZ - box.minZ), 1, 0 ,0, 0, 0); + ((ServerWorld) world).spawnParticle(ParticleTypes.HEART, pos.getX() + box.minX + Math.random() * (box.maxX - box.minX), pos.getY() + box.maxY, pos.getZ() + box.minZ + Math.random() * (box.maxZ - box.minZ), 1, 0, 0, 0, 0); } } return ActionResultType.SUCCESS; @@ -89,8 +88,9 @@ public class BlockTinyPotato extends BlockMod { @Override public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, LivingEntity entity, ItemStack stack) { - if (stack.hasDisplayName()) + if (stack.hasDisplayName()) { ((TileTinyPotato) world.getTileEntity(pos)).name = stack.getDisplayName(); + } } @Nonnull diff --git a/src/main/java/vazkii/botania/common/block/decor/ItemBlockBlaze.java b/src/main/java/vazkii/botania/common/block/decor/ItemBlockBlaze.java index 7fd032c7a..4700c070d 100644 --- a/src/main/java/vazkii/botania/common/block/decor/ItemBlockBlaze.java +++ b/src/main/java/vazkii/botania/common/block/decor/ItemBlockBlaze.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.common.block.decor; import net.minecraft.block.Block; @@ -5,16 +13,17 @@ import net.minecraft.item.BlockItem; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraftforge.common.ForgeHooks; + import vazkii.botania.common.Botania; public class ItemBlockBlaze extends BlockItem { - public ItemBlockBlaze(Block block, Properties props) { - super(block, props); - } + public ItemBlockBlaze(Block block, Properties props) { + super(block, props); + } - @Override - public int getBurnTime(ItemStack stack) { - int blazeTime = ForgeHooks.getBurnTime(new ItemStack(Items.BLAZE_ROD)); - return blazeTime * (Botania.gardenOfGlassLoaded ? 5 : 10); - } + @Override + public int getBurnTime(ItemStack stack) { + int blazeTime = ForgeHooks.getBurnTime(new ItemStack(Items.BLAZE_ROD)); + return blazeTime * (Botania.gardenOfGlassLoaded ? 5 : 10); + } } diff --git a/src/main/java/vazkii/botania/common/block/decor/panes/BlockModPane.java b/src/main/java/vazkii/botania/common/block/decor/panes/BlockModPane.java index db0224531..6efc9cc9d 100644 --- a/src/main/java/vazkii/botania/common/block/decor/panes/BlockModPane.java +++ b/src/main/java/vazkii/botania/common/block/decor/panes/BlockModPane.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 30, 2015, 10:01:17 PM (GMT)] */ package vazkii.botania.common.block.decor.panes; @@ -16,11 +14,8 @@ import net.minecraft.block.PaneBlock; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import vazkii.botania.common.block.ModBlocks; -import javax.annotation.Nonnull; +import vazkii.botania.common.block.ModBlocks; public class BlockModPane extends PaneBlock { diff --git a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockModStairs.java b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockModStairs.java index bac865052..d3eb96062 100644 --- a/src/main/java/vazkii/botania/common/block/decor/stairs/BlockModStairs.java +++ b/src/main/java/vazkii/botania/common/block/decor/stairs/BlockModStairs.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.common.block.decor.stairs; import net.minecraft.block.Block; diff --git a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourCocoaBeans.java b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourCocoaBeans.java index ff40c6a03..3fee77b02 100644 --- a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourCocoaBeans.java +++ b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourCocoaBeans.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [21/09/2016, 21:08:41 (GMT)] */ package vazkii.botania.common.block.dispenser; @@ -35,7 +33,7 @@ public class BehaviourCocoaBeans extends DefaultDispenseItemBehavior { World world = source.getWorld(); BlockItemUseContext ctx = new DirectionalPlaceContext(source.getWorld(), source.getBlockPos().offset(facing), facing, new ItemStack(block), facing.getOpposite()); BlockState cocoa = block.getStateForPlacement(ctx); - if(cocoa != null && world.isAirBlock(pos)) { + if (cocoa != null && world.isAirBlock(pos)) { world.setBlockState(pos, cocoa); stack.shrink(1); return stack; diff --git a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourFelPumpkin.java b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourFelPumpkin.java index 5172d75ac..19c8f7bbf 100644 --- a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourFelPumpkin.java +++ b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourFelPumpkin.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.common.block.dispenser; import net.minecraft.block.Block; @@ -8,6 +16,7 @@ import net.minecraft.dispenser.OptionalDispenseBehavior; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import vazkii.botania.common.block.ModBlocks; import javax.annotation.Nonnull; diff --git a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourPoolMinecart.java b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourPoolMinecart.java index 7a543b02b..52b2c9d9a 100644 --- a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourPoolMinecart.java +++ b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourPoolMinecart.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 18, 2015, 12:22:58 AM (GMT)] */ package vazkii.botania.common.block.dispenser; @@ -22,6 +20,7 @@ import net.minecraft.tags.BlockTags; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import vazkii.botania.common.entity.EntityPoolMinecart; import javax.annotation.Nonnull; @@ -35,12 +34,12 @@ public class BehaviourPoolMinecart extends DefaultDispenseItemBehavior { public ItemStack dispenseStack(IBlockSource source, ItemStack stack) { Direction enumfacing = source.getBlockState().get(DispenserBlock.FACING); World world = source.getWorld(); - double d0 = source.getX() + (double)enumfacing.getXOffset() * 1.125D; - double d1 = Math.floor(source.getY()) + (double)enumfacing.getYOffset(); - double d2 = source.getZ() + (double)enumfacing.getZOffset() * 1.125D; + double d0 = source.getX() + (double) enumfacing.getXOffset() * 1.125D; + double d1 = Math.floor(source.getY()) + (double) enumfacing.getYOffset(); + double d2 = source.getZ() + (double) enumfacing.getZOffset() * 1.125D; BlockPos blockpos = source.getBlockPos().offset(enumfacing); BlockState iblockstate = world.getBlockState(blockpos); - RailShape railshape = iblockstate.getBlock() instanceof AbstractRailBlock ? ((AbstractRailBlock)iblockstate.getBlock()).getRailDirection(iblockstate, world, blockpos, null) : RailShape.NORTH_SOUTH; + RailShape railshape = iblockstate.getBlock() instanceof AbstractRailBlock ? ((AbstractRailBlock) iblockstate.getBlock()).getRailDirection(iblockstate, world, blockpos, null) : RailShape.NORTH_SOUTH; double d3; if (iblockstate.isIn(BlockTags.RAILS)) { if (railshape.isAscending()) { @@ -54,7 +53,7 @@ public class BehaviourPoolMinecart extends DefaultDispenseItemBehavior { } BlockState iblockstate1 = world.getBlockState(blockpos.down()); - RailShape railshape1 = iblockstate1.getBlock() instanceof AbstractRailBlock ? ((AbstractRailBlock)iblockstate1.getBlock()).getRailDirection(iblockstate1, world, blockpos, null) : RailShape.NORTH_SOUTH; + RailShape railshape1 = iblockstate1.getBlock() instanceof AbstractRailBlock ? ((AbstractRailBlock) iblockstate1.getBlock()).getRailDirection(iblockstate1, world, blockpos, null) : RailShape.NORTH_SOUTH; if (enumfacing != Direction.DOWN && railshape1.isAscending()) { d3 = -0.4D; } else { diff --git a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourSeeds.java b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourSeeds.java index 8ff874733..66ba26d4f 100644 --- a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourSeeds.java +++ b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourSeeds.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [21/09/2016, 21:08:33 (GMT)] */ package vazkii.botania.common.block.dispenser; @@ -35,7 +33,7 @@ public class BehaviourSeeds extends DefaultDispenseItemBehavior { BlockPos pos = source.getBlockPos().offset(facing); World world = source.getWorld(); - if(world.isAirBlock(pos) && block.getDefaultState().isValidPosition(world, pos)) { + if (world.isAirBlock(pos) && block.getDefaultState().isValidPosition(world, pos)) { world.setBlockState(pos, block.getDefaultState()); stack.shrink(1); return stack; @@ -44,4 +42,4 @@ public class BehaviourSeeds extends DefaultDispenseItemBehavior { return super.dispenseStack(source, stack); } -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourWand.java b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourWand.java index 358ff03fa..595700948 100644 --- a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourWand.java +++ b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourWand.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 16, 2014, 11:11:31 PM (GMT)] */ package vazkii.botania.common.block.dispenser; @@ -18,6 +16,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import vazkii.botania.api.wand.IWandable; import javax.annotation.Nonnull; @@ -31,7 +30,7 @@ public class BehaviourWand extends DefaultDispenseItemBehavior { Direction facing = world.getBlockState(source.getBlockPos()).get(DispenserBlock.FACING); BlockPos pos = source.getBlockPos().offset(facing); Block block = world.getBlockState(pos).getBlock(); - if(block instanceof IWandable) { + if (block instanceof IWandable) { ((IWandable) block).onUsedByWand(null, stack, world, pos, facing.getOpposite()); return stack; } diff --git a/src/main/java/vazkii/botania/common/block/dispenser/SeedBehaviours.java b/src/main/java/vazkii/botania/common/block/dispenser/SeedBehaviours.java index 5790f1da0..71c82c027 100644 --- a/src/main/java/vazkii/botania/common/block/dispenser/SeedBehaviours.java +++ b/src/main/java/vazkii/botania/common/block/dispenser/SeedBehaviours.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [21/09/2016, 21:06:43 (GMT)] */ package vazkii.botania.common.block.dispenser; diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockAlchemyCatalyst.java b/src/main/java/vazkii/botania/common/block/mana/BlockAlchemyCatalyst.java index e8cd96546..d0d670126 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockAlchemyCatalyst.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockAlchemyCatalyst.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 2, 2014, 7:18:49 PM (GMT)] */ package vazkii.botania.common.block.mana; @@ -15,6 +13,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.mana.IPoolOverlayProvider; import vazkii.botania.client.core.handler.MiscellaneousIcons; import vazkii.botania.common.block.BlockMod; diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockBellows.java b/src/main/java/vazkii/botania/common/block/mana/BlockBellows.java index 86eba7805..75892df66 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockBellows.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockBellows.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 28, 2015, 5:18:13 PM (GMT)] */ package vazkii.botania.common.block.mana; @@ -27,6 +25,7 @@ import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; + import vazkii.botania.common.block.BlockMod; import vazkii.botania.common.block.tile.mana.TileBellows; import vazkii.botania.common.entity.EntityDoppleganger; @@ -60,8 +59,9 @@ public class BlockBellows extends BlockMod { @Override public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { - if(EntityDoppleganger.isTruePlayer(player)) + if (EntityDoppleganger.isTruePlayer(player)) { ((TileBellows) world.getTileEntity(pos)).interact(); + } return ActionResultType.SUCCESS; } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockBrewery.java b/src/main/java/vazkii/botania/common/block/mana/BlockBrewery.java index 2e9542a65..f11011f9e 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockBrewery.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockBrewery.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Oct 31, 2014, 4:37:29 PM (GMT)] */ package vazkii.botania.common.block.mana; @@ -28,6 +26,7 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.api.wand.IWandHUD; import vazkii.botania.common.block.BlockMod; @@ -61,22 +60,23 @@ public class BlockBrewery extends BlockMod implements IWandHUD { public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { TileBrewery brew = (TileBrewery) world.getTileEntity(pos); - if(player.isSneaking()) { - if(brew.recipe == null && !state.get(BotaniaStateProps.POWERED)) { + if (player.isSneaking()) { + if (brew.recipe == null && !state.get(BotaniaStateProps.POWERED)) { InventoryHelper.withdrawFromInventory(brew, player); return ActionResultType.SUCCESS; } } else { ItemStack stack = player.getHeldItem(hand); - if(!stack.isEmpty()) + if (!stack.isEmpty()) { return brew.addItem(player, stack, hand) ? ActionResultType.SUCCESS : ActionResultType.PASS; + } } return ActionResultType.PASS; } @Override public void onReplaced(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState newState, boolean isMoving) { - if(state.getBlock() != newState.getBlock()) { + if (state.getBlock() != newState.getBlock()) { TileSimpleInventory inv = (TileSimpleInventory) world.getTileEntity(pos); InventoryHelper.dropInventory(inv, world, state, pos); super.onReplaced(state, world, pos, newState, isMoving); diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockConjurationCatalyst.java b/src/main/java/vazkii/botania/common/block/mana/BlockConjurationCatalyst.java index b4a389683..35835b806 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockConjurationCatalyst.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockConjurationCatalyst.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 20, 2014, 1:27:14 AM (GMT)] */ package vazkii.botania.common.block.mana; @@ -15,6 +13,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.client.core.handler.MiscellaneousIcons; public class BlockConjurationCatalyst extends BlockAlchemyCatalyst { diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockDistributor.java b/src/main/java/vazkii/botania/common/block/mana/BlockDistributor.java index 9a02a851a..768c32a2b 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockDistributor.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockDistributor.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 3, 2014, 1:44:29 AM (GMT)] */ package vazkii.botania.common.block.mana; @@ -17,6 +15,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; + import vazkii.botania.common.block.BlockMod; import vazkii.botania.common.block.tile.mana.TileDistributor; @@ -29,7 +28,7 @@ public class BlockDistributor extends BlockMod { public BlockDistributor(Properties builder) { super(builder); } - + @Nonnull @Override public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext ctx) { diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockEnchanter.java b/src/main/java/vazkii/botania/common/block/mana/BlockEnchanter.java index 8d5402e96..9491fd8bb 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockEnchanter.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockEnchanter.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 15, 2014, 4:08:26 PM (GMT)] */ package vazkii.botania.common.block.mana; @@ -29,6 +27,7 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.items.ItemHandlerHelper; + import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.api.wand.IWandHUD; import vazkii.botania.api.wand.IWandable; @@ -65,23 +64,24 @@ public class BlockEnchanter extends BlockMod implements IWandable, IWandHUD { public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { TileEnchanter enchanter = (TileEnchanter) world.getTileEntity(pos); ItemStack stack = player.getHeldItem(hand); - if(!stack.isEmpty() && stack.getItem() == ModItems.twigWand) + if (!stack.isEmpty() && stack.getItem() == ModItems.twigWand) { return ActionResultType.PASS; + } boolean stackEnchantable = !stack.isEmpty() && stack.getItem() != Items.BOOK && stack.isEnchantable() && stack.getCount() == 1; - if(enchanter.itemToEnchant.isEmpty()) { - if(stackEnchantable) { + if (enchanter.itemToEnchant.isEmpty()) { + if (stackEnchantable) { enchanter.itemToEnchant = stack.copy(); player.setHeldItem(hand, ItemStack.EMPTY); enchanter.sync(); } else { return ActionResultType.PASS; } - } else if(enchanter.stage == TileEnchanter.State.IDLE) { + } else if (enchanter.stage == TileEnchanter.State.IDLE) { ItemHandlerHelper.giveItemToPlayer(player, enchanter.itemToEnchant.copy()); enchanter.itemToEnchant = ItemStack.EMPTY; enchanter.sync(); @@ -95,7 +95,7 @@ public class BlockEnchanter extends BlockMod implements IWandable, IWandHUD { if (state.getBlock() != newState.getBlock()) { TileEnchanter enchanter = (TileEnchanter) world.getTileEntity(pos); - if(!enchanter.itemToEnchant.isEmpty()) { + if (!enchanter.itemToEnchant.isEmpty()) { world.addEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), enchanter.itemToEnchant)); } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockForestDrum.java b/src/main/java/vazkii/botania/common/block/mana/BlockForestDrum.java index 17174b179..fe27a5749 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockForestDrum.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockForestDrum.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 16, 2014, 7:34:37 PM (GMT)] */ package vazkii.botania.common.block.mana; @@ -27,6 +25,7 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.common.IShearable; + import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.api.mana.IManaTrigger; import vazkii.botania.common.block.BlockMod; @@ -35,6 +34,7 @@ import vazkii.botania.common.item.ItemHorn; import vazkii.botania.common.item.ModItems; import javax.annotation.Nonnull; + import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -63,31 +63,32 @@ public class BlockForestDrum extends BlockMod implements IManaTrigger { @Override public void onBurstCollision(IManaBurst burst, World world, BlockPos pos) { - if(burst.isFake()) + if (burst.isFake()) { return; - if(world.isRemote) { + } + if (world.isRemote) { world.addParticle(ParticleTypes.NOTE, pos.getX() + 0.5, pos.getY() + 1.2, pos.getZ() + 0.5D, 1.0 / 24.0, 0, 0); return; } - if(variant == Variant.WILD) + if (variant == Variant.WILD) { ItemHorn.breakGrass(world, new ItemStack(ModItems.grassHorn), pos); - else if(variant == Variant.CANOPY) + } else if (variant == Variant.CANOPY) { ItemHorn.breakGrass(world, new ItemStack(ModItems.leavesHorn), pos); - else { + } else { int range = 10; List entities = world.getEntitiesWithinAABB(MobEntity.class, new AxisAlignedBB(pos.add(-range, -range, -range), pos.add(range + 1, range + 1, range + 1))); List shearables = new ArrayList<>(); ItemStack stack = new ItemStack(ModBlocks.gatheringDrum); - for(MobEntity entity : entities) { - if(entity instanceof IShearable && ((IShearable) entity).isShearable(stack, world, new BlockPos(entity))) { + for (MobEntity entity : entities) { + if (entity instanceof IShearable && ((IShearable) entity).isShearable(stack, world, new BlockPos(entity))) { shearables.add(entity); - } else if(entity instanceof CowEntity) { + } else if (entity instanceof CowEntity) { List items = world.getEntitiesWithinAABB(ItemEntity.class, entity.getBoundingBox()); - for(ItemEntity item : items) { + for (ItemEntity item : items) { ItemStack itemstack = item.getItem(); - if(!itemstack.isEmpty() && itemstack.getItem() == Items.BUCKET && !world.isRemote) { - while(itemstack.getCount() > 0) { + if (!itemstack.isEmpty() && itemstack.getItem() == Items.BUCKET && !world.isRemote) { + while (itemstack.getCount() > 0) { ItemEntity ent = entity.entityDropItem(new ItemStack(Items.MILK_BUCKET), 1.0F); ent.setMotion(ent.getMotion().add( world.rand.nextFloat() * 0.05F, @@ -105,12 +106,13 @@ public class BlockForestDrum extends BlockMod implements IManaTrigger { Collections.shuffle(shearables); int sheared = 0; - for(MobEntity entity : shearables) { - if(sheared > 4) + for (MobEntity entity : shearables) { + if (sheared > 4) { break; + } List stacks = ((IShearable) entity).onSheared(stack, world, new BlockPos(entity), 0); - for(ItemStack wool : stacks) { + for (ItemStack wool : stacks) { ItemEntity ent = entity.entityDropItem(wool, 1.0F); ent.setMotion(ent.getMotion().add( world.rand.nextFloat() * 0.05F, @@ -122,7 +124,8 @@ public class BlockForestDrum extends BlockMod implements IManaTrigger { } } - for(int i = 0; i < 10; i++) + for (int i = 0; i < 10; i++) { world.playSound(null, pos, SoundEvents.BLOCK_NOTE_BLOCK_BASEDRUM, SoundCategory.BLOCKS, 1F, 1F); + } } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockManaDetector.java b/src/main/java/vazkii/botania/common/block/mana/BlockManaDetector.java index 3a0f15bbc..7f6a8ce05 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockManaDetector.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockManaDetector.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 10, 2014, 7:57:38 PM (GMT)] */ package vazkii.botania.common.block.mana; @@ -21,6 +19,7 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; + import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.api.mana.IManaCollisionGhost; import vazkii.botania.api.state.BotaniaStateProps; @@ -54,8 +53,8 @@ public class BlockManaDetector extends BlockMod implements IManaCollisionGhost { @Nonnull @Override public VoxelShape getCollisionShape(@Nonnull BlockState state, @Nonnull IBlockReader world, @Nonnull BlockPos pos, - ISelectionContext context) { - if(context.getEntity() instanceof IManaBurst) { + ISelectionContext context) { + if (context.getEntity() instanceof IManaBurst) { return VoxelShapes.empty(); } else { return super.getCollisionShape(state, world, pos, context); diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockManaVoid.java b/src/main/java/vazkii/botania/common/block/mana/BlockManaVoid.java index a1b382e3f..09bb83690 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockManaVoid.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockManaVoid.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 5, 2014, 12:55:47 AM (GMT)] */ package vazkii.botania.common.block.mana; @@ -18,6 +16,7 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.mana.IPoolOverlayProvider; import vazkii.botania.client.core.handler.MiscellaneousIcons; import vazkii.botania.common.block.BlockMod; diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockPool.java b/src/main/java/vazkii/botania/common/block/mana/BlockPool.java index 558720efa..3ea71b44b 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockPool.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockPool.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 26, 2014, 12:22:58 AM (GMT)] */ package vazkii.botania.common.block.mana; @@ -30,6 +28,7 @@ import net.minecraft.world.storage.loot.LootContext; import net.minecraft.world.storage.loot.LootParameters; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.wand.IWandHUD; import vazkii.botania.api.wand.IWandable; @@ -37,6 +36,7 @@ import vazkii.botania.common.block.BlockMod; import vazkii.botania.common.block.tile.mana.TilePool; import javax.annotation.Nonnull; + import java.util.Collections; import java.util.List; @@ -68,7 +68,7 @@ public class BlockPool extends BlockMod implements IWandHUD, IWandable { @Override public List getDrops(@Nonnull BlockState state, LootContext.Builder builder) { if (builder.get(LootParameters.BLOCK_ENTITY) instanceof TilePool - && ((TilePool) builder.get(LootParameters.BLOCK_ENTITY)).fragile) { + && ((TilePool) builder.get(LootParameters.BLOCK_ENTITY)).fragile) { return Collections.emptyList(); } else { return super.getDrops(state, builder); @@ -88,19 +88,22 @@ public class BlockPool extends BlockMod implements IWandHUD, IWandable { @Override public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) { - if(entity instanceof ItemEntity) { + if (entity instanceof ItemEntity) { TilePool tile = (TilePool) world.getTileEntity(pos); - if(tile.collideEntityItem((ItemEntity) entity)) + if (tile.collideEntityItem((ItemEntity) entity)) { VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos); + } } } @Nonnull @Override public BlockRenderType getRenderType(BlockState state) { - if (variant == Variant.FABULOUS) + if (variant == Variant.FABULOUS) { return BlockRenderType.ENTITYBLOCK_ANIMATED; - else return BlockRenderType.MODEL; + } else { + return BlockRenderType.MODEL; + } } @Override diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockPrism.java b/src/main/java/vazkii/botania/common/block/mana/BlockPrism.java index 1274dda04..1fe8de5eb 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockPrism.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockPrism.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 17, 2015, 7:16:48 PM (GMT)] */ package vazkii.botania.common.block.mana; @@ -24,9 +22,8 @@ import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.items.ItemHandlerHelper; + import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.api.mana.ILens; import vazkii.botania.api.mana.IManaCollisionGhost; @@ -63,20 +60,22 @@ public class BlockPrism extends BlockMod implements IManaTrigger, IManaCollision @Override public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { TileEntity tile = world.getTileEntity(pos); - if(!(tile instanceof TilePrism)) + if (!(tile instanceof TilePrism)) { return ActionResultType.PASS; + } TilePrism prism = (TilePrism) tile; ItemStack lens = prism.getItemHandler().getStackInSlot(0); ItemStack heldItem = player.getHeldItem(hand); boolean isHeldItemLens = !heldItem.isEmpty() && heldItem.getItem() instanceof ILens; - if(lens.isEmpty() && isHeldItemLens) { - if(!player.abilities.isCreativeMode) + if (lens.isEmpty() && isHeldItemLens) { + if (!player.abilities.isCreativeMode) { player.setHeldItem(hand, ItemStack.EMPTY); + } prism.getItemHandler().setStackInSlot(0, heldItem.copy()); - } else if(!lens.isEmpty()) { + } else if (!lens.isEmpty()) { ItemHandlerHelper.giveItemToPlayer(player, lens); prism.getItemHandler().setStackInSlot(0, ItemStack.EMPTY); } @@ -89,11 +88,12 @@ public class BlockPrism extends BlockMod implements IManaTrigger, IManaCollision boolean power = world.getRedstonePowerFromNeighbors(pos) > 0 || world.getRedstonePowerFromNeighbors(pos.up()) > 0; boolean powered = state.get(BotaniaStateProps.POWERED); - if(!world.isRemote) { - if(power && !powered) + if (!world.isRemote) { + if (power && !powered) { world.setBlockState(pos, state.with(BotaniaStateProps.POWERED, true)); - else if(!power && powered) + } else if (!power && powered) { world.setBlockState(pos, state.with(BotaniaStateProps.POWERED, false)); + } } } @@ -120,8 +120,9 @@ public class BlockPrism extends BlockMod implements IManaTrigger, IManaCollision @Override public void onBurstCollision(IManaBurst burst, World world, BlockPos pos) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TilePrism) + if (tile instanceof TilePrism) { ((TilePrism) tile).onBurstCollision(burst); + } } @Override diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockPump.java b/src/main/java/vazkii/botania/common/block/mana/BlockPump.java index 91d350c5a..0aad36ede 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockPump.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockPump.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 17, 2015, 9:46:53 PM (GMT)] */ package vazkii.botania.common.block.mana; @@ -22,6 +20,7 @@ import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; + import vazkii.botania.common.block.BlockMod; import vazkii.botania.common.block.tile.mana.TilePump; @@ -52,7 +51,7 @@ public class BlockPump extends BlockMod { @Nonnull @Override public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext ctx) { - if(state.get(BlockStateProperties.HORIZONTAL_FACING).getAxis() == Direction.Axis.X) { + if (state.get(BlockStateProperties.HORIZONTAL_FACING).getAxis() == Direction.Axis.X) { return X_SHAPE; } else { return Z_SHAPE; diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockRFGenerator.java b/src/main/java/vazkii/botania/common/block/mana/BlockRFGenerator.java index 96bfc6005..f1dd93c58 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockRFGenerator.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockRFGenerator.java @@ -1,18 +1,17 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 29, 2014, 9:51:58 PM (GMT)] */ package vazkii.botania.common.block.mana; import net.minecraft.block.BlockState; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockReader; + import vazkii.botania.common.block.BlockMod; import vazkii.botania.common.block.tile.mana.TileRFGenerator; diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockRuneAltar.java b/src/main/java/vazkii/botania/common/block/mana/BlockRuneAltar.java index 75d06158b..700853534 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockRuneAltar.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockRuneAltar.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 2, 2014, 2:10:14 PM (GMT)] */ package vazkii.botania.common.block.mana; @@ -26,6 +24,7 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.wand.IWandable; import vazkii.botania.common.block.BlockMod; @@ -53,23 +52,24 @@ public class BlockRuneAltar extends BlockMod implements IWandable { @Override public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { - if(world.isRemote) + if (world.isRemote) { return ActionResultType.SUCCESS; + } TileRuneAltar altar = (TileRuneAltar) world.getTileEntity(pos); ItemStack stack = player.getHeldItem(hand); - if(player.isSneaking()) { - if(altar.manaToGet == 0) { + if (player.isSneaking()) { + if (altar.manaToGet == 0) { InventoryHelper.withdrawFromInventory(altar, player); VanillaPacketDispatcher.dispatchTEToNearbyPlayers(altar); return ActionResultType.SUCCESS; } - } else if(altar.isEmpty() && stack.isEmpty()) { + } else if (altar.isEmpty() && stack.isEmpty()) { altar.trySetLastRecipe(player); VanillaPacketDispatcher.dispatchTEToNearbyPlayers(altar); return ActionResultType.SUCCESS; - } else if(!stack.isEmpty()) { + } else if (!stack.isEmpty()) { boolean result = altar.addItem(player, stack, hand); VanillaPacketDispatcher.dispatchTEToNearbyPlayers(altar); return result ? ActionResultType.SUCCESS : ActionResultType.PASS; @@ -115,5 +115,4 @@ public class BlockRuneAltar extends BlockMod implements IWandable { return true; } - } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockSpawnerClaw.java b/src/main/java/vazkii/botania/common/block/mana/BlockSpawnerClaw.java index 31f43af48..70135e74e 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockSpawnerClaw.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockSpawnerClaw.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 23, 2014, 5:28:55 PM (GMT)] */ package vazkii.botania.common.block.mana; @@ -20,6 +18,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; + import vazkii.botania.common.block.BlockMod; import vazkii.botania.common.block.tile.TileSpawnerClaw; diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockSpreader.java b/src/main/java/vazkii/botania/common/block/mana/BlockSpreader.java index bafd25cab..771e2b75f 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockSpreader.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockSpreader.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 25, 2014, 9:38:23 PM (GMT)] */ package vazkii.botania.common.block.mana; import com.google.common.collect.ImmutableList; + import net.minecraft.block.Block; import net.minecraft.block.BlockRenderType; import net.minecraft.block.BlockState; @@ -27,13 +26,13 @@ import net.minecraft.util.Hand; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.items.ItemHandlerHelper; + import vazkii.botania.api.ColorHelper; import vazkii.botania.api.mana.ILens; import vazkii.botania.api.wand.IWandHUD; @@ -45,16 +44,17 @@ import vazkii.botania.common.core.helper.InventoryHelper; import vazkii.botania.common.item.ModItems; import javax.annotation.Nonnull; -import javax.annotation.Nullable; + import java.util.List; public class BlockSpreader extends BlockMod implements IWandable, IWandHUD, IWireframeAABBProvider { private static final VoxelShape RENDER_SHAPE = makeCuboidShape(1, 1, 1, 15, 15, 15); + public enum Variant { - MANA (160, 1000, 0x20FF20, 0x00FF00, 60, 4f, 1f), - REDSTONE (160, 1000, 0xFF2020, 0xFF0000, 60, 4f, 1f), - ELVEN (240, 1000, 0xFF45C4, 0xFF00AE, 80, 4f, 1.25f), - GAIA (640, 6400, 0x20FF20, 0x00FF00, 120, 20f, 2f); + MANA(160, 1000, 0x20FF20, 0x00FF00, 60, 4f, 1f), + REDSTONE(160, 1000, 0xFF2020, 0xFF0000, 60, 4f, 1f), + ELVEN(240, 1000, 0xFF45C4, 0xFF00AE, 80, 4f, 1.25f), + GAIA(640, 6400, 0x20FF20, 0x00FF00, 120, 20f, 2f); public final int burstMana; public final int manaCapacity; @@ -76,6 +76,7 @@ public class BlockSpreader extends BlockMod implements IWandable, IWandHUD, IWir } public final Variant variant; + public BlockSpreader(Variant v, Properties builder) { super(builder); this.variant = v; @@ -97,7 +98,7 @@ public class BlockSpreader extends BlockMod implements IWandable, IWandHUD, IWir Direction orientation = Direction.getFacingDirections(placer)[0].getOpposite(); TileSpreader spreader = (TileSpreader) world.getTileEntity(pos); - switch(orientation) { + switch (orientation) { case DOWN: spreader.rotationY = -90F; break; @@ -127,8 +128,9 @@ public class BlockSpreader extends BlockMod implements IWandable, IWandHUD, IWir @Override public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { TileEntity tile = world.getTileEntity(pos); - if(!(tile instanceof TileSpreader)) + if (!(tile instanceof TileSpreader)) { return ActionResultType.PASS; + } TileSpreader spreader = (TileSpreader) tile; ItemStack lens = spreader.getItemHandler().getStackInSlot(0); @@ -136,29 +138,33 @@ public class BlockSpreader extends BlockMod implements IWandable, IWandHUD, IWir boolean isHeldItemLens = !heldItem.isEmpty() && heldItem.getItem() instanceof ILens; boolean wool = !heldItem.isEmpty() && ColorHelper.WOOL_MAP.containsValue(Block.getBlockFromItem(heldItem.getItem()).delegate); - if(!heldItem.isEmpty()) - if(heldItem.getItem() == ModItems.twigWand) + if (!heldItem.isEmpty()) { + if (heldItem.getItem() == ModItems.twigWand) { return ActionResultType.PASS; + } + } - if(lens.isEmpty() && isHeldItemLens) { - if (!player.abilities.isCreativeMode) + if (lens.isEmpty() && isHeldItemLens) { + if (!player.abilities.isCreativeMode) { player.setHeldItem(hand, ItemStack.EMPTY); + } spreader.getItemHandler().setStackInSlot(0, heldItem.copy()); spreader.markDirty(); - } else if(!lens.isEmpty() && !wool) { + } else if (!lens.isEmpty() && !wool) { ItemHandlerHelper.giveItemToPlayer(player, lens); spreader.getItemHandler().setStackInSlot(0, ItemStack.EMPTY); spreader.markDirty(); } - if(wool && spreader.paddingColor == null) { + if (wool && spreader.paddingColor == null) { Block block = Block.getBlockFromItem(heldItem.getItem()); spreader.paddingColor = ColorHelper.WOOL_MAP.inverse().get(block.delegate); heldItem.shrink(1); - if(heldItem.isEmpty()) + if (heldItem.isEmpty()) { player.setHeldItem(hand, ItemStack.EMPTY); - } else if(heldItem.isEmpty() && spreader.paddingColor != null && lens.isEmpty()) { + } + } else if (heldItem.isEmpty() && spreader.paddingColor != null && lens.isEmpty()) { ItemStack pad = new ItemStack(ColorHelper.WOOL_MAP.get(spreader.paddingColor).get()); ItemHandlerHelper.giveItemToPlayer(player, pad); spreader.paddingColor = null; @@ -172,12 +178,13 @@ public class BlockSpreader extends BlockMod implements IWandable, IWandHUD, IWir public void onReplaced(@Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState newState, boolean isMoving) { if (state.getBlock() != newState.getBlock()) { TileEntity tile = world.getTileEntity(pos); - if(!(tile instanceof TileSpreader)) + if (!(tile instanceof TileSpreader)) { return; + } TileSpreader inv = (TileSpreader) tile; - if(inv.paddingColor != null) { + if (inv.paddingColor != null) { ItemStack padding = new ItemStack(ColorHelper.WOOL_MAP.get(inv.paddingColor).get()); world.addEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), padding)); } @@ -213,6 +220,6 @@ public class BlockSpreader extends BlockMod implements IWandable, IWandHUD, IWir @Override public List getWireframeAABB(World world, BlockPos pos) { - return ImmutableList.of(new AxisAlignedBB(pos).shrink(1.0/16.0)); + return ImmutableList.of(new AxisAlignedBB(pos).shrink(1.0 / 16.0)); } } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockTerraPlate.java b/src/main/java/vazkii/botania/common/block/mana/BlockTerraPlate.java index 76e47bc87..06bd2c21e 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockTerraPlate.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockTerraPlate.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 8, 2014, 5:25:12 PM (GMT)] */ package vazkii.botania.common.block.mana; @@ -25,6 +23,7 @@ import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; + import vazkii.botania.common.block.BlockMod; import vazkii.botania.common.block.tile.TileTerraPlate; import vazkii.botania.common.item.ModItems; @@ -48,9 +47,9 @@ public class BlockTerraPlate extends BlockMod { @Override public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { ItemStack stack = player.getHeldItem(hand); - if(!stack.isEmpty() + if (!stack.isEmpty() && (stack.getItem() == ModItems.manaSteel || stack.getItem() == ModItems.manaPearl || stack.getItem() == ModItems.manaDiamond)) { - if(!world.isRemote) { + if (!world.isRemote) { ItemStack target = stack.split(1); ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, target); item.setPickupDelay(40); @@ -89,8 +88,9 @@ public class BlockTerraPlate extends BlockMod { public int getComparatorInputOverride(BlockState state, World world, BlockPos pos) { TileTerraPlate plate = (TileTerraPlate) world.getTileEntity(pos); int val = (int) ((double) plate.getCurrentMana() / (double) TileTerraPlate.MAX_MANA * 15.0); - if(plate.getCurrentMana() > 0) + if (plate.getCurrentMana() > 0) { val = Math.max(val, 1); + } return val; } diff --git a/src/main/java/vazkii/botania/common/block/mana/BlockTurntable.java b/src/main/java/vazkii/botania/common/block/mana/BlockTurntable.java index a6f83b3d5..d30b1395b 100644 --- a/src/main/java/vazkii/botania/common/block/mana/BlockTurntable.java +++ b/src/main/java/vazkii/botania/common/block/mana/BlockTurntable.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 16, 2014, 10:08:14 PM (GMT)] */ package vazkii.botania.common.block.mana; @@ -21,6 +19,7 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.wand.IWandHUD; import vazkii.botania.api.wand.IWandable; import vazkii.botania.common.block.BlockMod; diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedString.java b/src/main/java/vazkii/botania/common/block/string/BlockRedString.java index e3c9e8129..44852d609 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedString.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedString.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 14, 2014, 4:43:14 PM (GMT)] */ package vazkii.botania.common.block.string; @@ -15,6 +13,7 @@ import net.minecraft.block.BlockState; import net.minecraft.item.BlockItemUseContext; import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; + import vazkii.botania.common.block.BlockMod; public abstract class BlockRedString extends BlockMod { diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedStringComparator.java b/src/main/java/vazkii/botania/common/block/string/BlockRedStringComparator.java index 69a12b2d4..37cba8340 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedStringComparator.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedStringComparator.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 16, 2014, 10:19:28 PM (GMT)] */ package vazkii.botania.common.block.string; @@ -17,6 +15,7 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; + import vazkii.botania.common.block.tile.string.TileRedString; import vazkii.botania.common.block.tile.string.TileRedStringComparator; diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedStringContainer.java b/src/main/java/vazkii/botania/common/block/string/BlockRedStringContainer.java index 8d301a554..a548ff1f9 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedStringContainer.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedStringContainer.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 14, 2014, 5:29:56 PM (GMT)] */ package vazkii.botania.common.block.string; @@ -15,6 +13,7 @@ import net.minecraft.block.BlockState; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.util.Direction; import net.minecraft.world.IBlockReader; + import vazkii.botania.common.block.tile.string.TileRedString; import vazkii.botania.common.block.tile.string.TileRedStringContainer; diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedStringDispenser.java b/src/main/java/vazkii/botania/common/block/string/BlockRedStringDispenser.java index eaf09e540..e34b6716c 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedStringDispenser.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedStringDispenser.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 14, 2014, 10:59:20 PM (GMT)] */ package vazkii.botania.common.block.string; @@ -18,6 +16,7 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; + import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.common.block.tile.string.TileRedString; import vazkii.botania.common.block.tile.string.TileRedStringDispenser; @@ -42,11 +41,12 @@ public class BlockRedStringDispenser extends BlockRedString { boolean power = world.getRedstonePowerFromNeighbors(pos) > 0 || world.getRedstonePowerFromNeighbors(pos.up()) > 0; boolean powered = state.get(BotaniaStateProps.POWERED); - if(power && !powered) { + if (power && !powered) { ((TileRedStringDispenser) world.getTileEntity(pos)).tickDispenser(); world.setBlockState(pos, state.with(BotaniaStateProps.POWERED, true), 4); - } else if(!power && powered) + } else if (!power && powered) { world.setBlockState(pos, state.with(BotaniaStateProps.POWERED, false), 4); + } } @Nonnull diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedStringFertilizer.java b/src/main/java/vazkii/botania/common/block/string/BlockRedStringFertilizer.java index c654bea46..91cf3a990 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedStringFertilizer.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedStringFertilizer.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 16, 2014, 7:10:46 PM (GMT)] */ package vazkii.botania.common.block.string; @@ -19,10 +17,12 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; + import vazkii.botania.common.block.tile.string.TileRedString; import vazkii.botania.common.block.tile.string.TileRedStringFertilizer; import javax.annotation.Nonnull; + import java.util.Random; public class BlockRedStringFertilizer extends BlockRedString implements IGrowable { diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedStringInterceptor.java b/src/main/java/vazkii/botania/common/block/string/BlockRedStringInterceptor.java index 1fb2a2d5b..1fd198a3b 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedStringInterceptor.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedStringInterceptor.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 21, 2015, 4:56:52 PM (GMT)] */ package vazkii.botania.common.block.string; @@ -22,12 +20,14 @@ import net.minecraft.world.server.ServerWorld; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.common.block.tile.string.TileRedString; import vazkii.botania.common.block.tile.string.TileRedStringInterceptor; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.Random; @Mod.EventBusSubscriber(modid = LibMisc.MOD_ID) diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedStringRelay.java b/src/main/java/vazkii/botania/common/block/string/BlockRedStringRelay.java index 6a30f6c99..4fb2ee058 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedStringRelay.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedStringRelay.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 16, 2014, 10:46:48 PM (GMT)] */ package vazkii.botania.common.block.string; @@ -15,6 +13,7 @@ import net.minecraft.block.BlockState; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.util.Direction; import net.minecraft.world.IBlockReader; + import vazkii.botania.common.block.tile.string.TileRedString; import vazkii.botania.common.block.tile.string.TileRedStringRelay; diff --git a/src/main/java/vazkii/botania/common/block/subtile/SubTileManastar.java b/src/main/java/vazkii/botania/common/block/subtile/SubTileManastar.java index a216ded72..7c9919b6b 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/SubTileManastar.java +++ b/src/main/java/vazkii/botania/common/block/subtile/SubTileManastar.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 6, 2014, 9:57:19 PM (GMT)] */ package vazkii.botania.common.block.subtile; @@ -15,6 +13,7 @@ import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.mana.IManaPool; import vazkii.botania.api.subtile.TileEntitySpecialFlower; import vazkii.botania.client.fx.WispParticleData; @@ -22,8 +21,7 @@ import vazkii.botania.common.core.helper.MathHelper; import vazkii.botania.common.lib.LibMisc; public class SubTileManastar extends TileEntitySpecialFlower { - @ObjectHolder(LibMisc.MOD_ID + ":manastar") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":manastar") public static TileEntityType TYPE; private static final int SET_STATE_EVENT = 0; private static final int NONE = 0, DECREASING = 1, INCREASING = 2; @@ -39,8 +37,8 @@ public class SubTileManastar extends TileEntitySpecialFlower { public void tickFlower() { super.tickFlower(); - if(getWorld().isRemote) { - if(state != NONE && Math.random() > 0.6) { + if (getWorld().isRemote) { + if (state != NONE && Math.random() > 0.6) { float r = state == INCREASING ? 0.05F : 1F; float b = state == INCREASING ? 1F : 0.05F; WispParticleData data = WispParticleData.wisp((float) Math.random() / 7, r, 0.05F, b, 1); @@ -48,27 +46,30 @@ public class SubTileManastar extends TileEntitySpecialFlower { } } else { int mana = 0; - for(Direction dir : MathHelper.HORIZONTALS) { + for (Direction dir : MathHelper.HORIZONTALS) { BlockPos pos = getEffectivePos().offset(dir); - if(getWorld().isBlockLoaded(pos)) { + if (getWorld().isBlockLoaded(pos)) { TileEntity tile = getWorld().getTileEntity(pos); - if(tile instanceof IManaPool) + if (tile instanceof IManaPool) { mana += ((IManaPool) tile).getCurrentMana(); + } } } int newState = mana > lastMana ? INCREASING : mana < lastMana ? DECREASING : NONE; - if(newState != state) + if (newState != state) { getWorld().addBlockEvent(getPos(), getBlockState().getBlock(), SET_STATE_EVENT, newState); + } - if(ticksExisted % 60 == 0) + if (ticksExisted % 60 == 0) { lastMana = mana; + } } } @Override public boolean receiveClientEvent(int id, int param) { - if(id == SET_STATE_EVENT) { + if (id == SET_STATE_EVENT) { state = param; return true; } else { diff --git a/src/main/java/vazkii/botania/common/block/subtile/SubTilePureDaisy.java b/src/main/java/vazkii/botania/common/block/subtile/SubTilePureDaisy.java index 5154a1abc..cf4dd65e3 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/SubTilePureDaisy.java +++ b/src/main/java/vazkii/botania/common/block/subtile/SubTilePureDaisy.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 28, 2014, 9:09:39 PM (GMT)] */ package vazkii.botania.common.block.subtile; @@ -17,6 +15,7 @@ import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipePureDaisy; import vazkii.botania.api.subtile.RadiusDescriptor; @@ -29,22 +28,21 @@ import vazkii.botania.common.lib.LibMisc; import java.util.Arrays; public class SubTilePureDaisy extends TileEntitySpecialFlower { - @ObjectHolder(LibMisc.MOD_ID + ":pure_daisy") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":pure_daisy") public static TileEntityType TYPE; private static final String TAG_POSITION = "position"; private static final String TAG_TICKS_REMAINING = "ticksRemaining"; private static final int RECIPE_COMPLETE_EVENT = 0; private static final BlockPos[] POSITIONS = { - new BlockPos(-1, 0, -1 ), - new BlockPos(-1, 0, 0 ), - new BlockPos(-1, 0, 1 ), - new BlockPos(0, 0, 1 ), - new BlockPos(1, 0, 1 ), - new BlockPos(1, 0, 0 ), - new BlockPos(1, 0, -1 ), - new BlockPos(0, 0, -1 ), + new BlockPos(-1, 0, -1), + new BlockPos(-1, 0, 0), + new BlockPos(-1, 0, 1), + new BlockPos(0, 0, 1), + new BlockPos(1, 0, 1), + new BlockPos(1, 0, 0), + new BlockPos(1, 0, -1), + new BlockPos(0, 0, -1), }; private int positionAt = 0; @@ -61,7 +59,7 @@ public class SubTilePureDaisy extends TileEntitySpecialFlower { public void tickFlower() { super.tickFlower(); - if(getWorld().isRemote) { + if (getWorld().isRemote) { for (int i = 0; i < POSITIONS.length; i++) { if (ticksRemaining[i] > 0) { BlockPos coords = getEffectivePos().add(POSITIONS[i]); @@ -74,35 +72,41 @@ public class SubTilePureDaisy extends TileEntitySpecialFlower { } positionAt++; - if(positionAt == POSITIONS.length) + if (positionAt == POSITIONS.length) { positionAt = 0; + } BlockPos acoords = POSITIONS[positionAt]; BlockPos coords = getEffectivePos().add(acoords); World world = getWorld(); - if(!world.isAirBlock(coords)) { + if (!world.isAirBlock(coords)) { world.getProfiler().startSection("findRecipe"); RecipePureDaisy recipe = findRecipe(coords); world.getProfiler().endSection(); - if(recipe != null) { + if (recipe != null) { if (ticksRemaining[positionAt] == -1) { ticksRemaining[positionAt] = recipe.getTime(); } ticksRemaining[positionAt]--; - if(ticksRemaining[positionAt] <= 0) { + if (ticksRemaining[positionAt] <= 0) { ticksRemaining[positionAt] = -1; - if(recipe.set(world,coords, this)) { - if(ConfigHandler.COMMON.blockBreakParticles.get()) + if (recipe.set(world, coords, this)) { + if (ConfigHandler.COMMON.blockBreakParticles.get()) { getWorld().playEvent(2001, coords, Block.getStateId(recipe.getOutputState())); + } } } - } else ticksRemaining[positionAt] = -1; - } else ticksRemaining[positionAt] = -1; + } else { + ticksRemaining[positionAt] = -1; + } + } else { + ticksRemaining[positionAt] = -1; + } if (!Arrays.equals(ticksRemaining, prevTicksRemaining)) { markDirty(); @@ -114,8 +118,8 @@ public class SubTilePureDaisy extends TileEntitySpecialFlower { private RecipePureDaisy findRecipe(BlockPos coords) { BlockState state = getWorld().getBlockState(coords); - for(RecipePureDaisy recipe : BotaniaAPI.pureDaisyRecipes.values()) { - if(recipe.matches(getWorld(), coords, this, state)) { + for (RecipePureDaisy recipe : BotaniaAPI.pureDaisyRecipes.values()) { + if (recipe.matches(getWorld(), coords, this, state)) { return recipe; } } @@ -126,43 +130,46 @@ public class SubTilePureDaisy extends TileEntitySpecialFlower { @Override public boolean receiveClientEvent(int type, int param) { switch (type) { - case RECIPE_COMPLETE_EVENT: { - if (getWorld().isRemote) { - BlockPos coords = getEffectivePos().add(POSITIONS[param]); - for(int i = 0; i < 25; i++) { - double x = coords.getX() + Math.random(); - double y = coords.getY() + Math.random() + 0.5; - double z = coords.getZ() + Math.random(); + case RECIPE_COMPLETE_EVENT: { + if (getWorld().isRemote) { + BlockPos coords = getEffectivePos().add(POSITIONS[param]); + for (int i = 0; i < 25; i++) { + double x = coords.getX() + Math.random(); + double y = coords.getY() + Math.random() + 0.5; + double z = coords.getZ() + Math.random(); - WispParticleData data = WispParticleData.wisp((float) Math.random() / 2F, 1, 1, 1); - getWorld().addParticle(data, x, y, z, 0, 0, 0); - } + WispParticleData data = WispParticleData.wisp((float) Math.random() / 2F, 1, 1, 1); + getWorld().addParticle(data, x, y, z, 0, 0, 0); } - - return true; } - default: return super.receiveClientEvent(type, param); + + return true; + } + default: + return super.receiveClientEvent(type, param); } } @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(getEffectivePos(), 1); + return new RadiusDescriptor.Square(getEffectivePos(), 1); } @Override public void readFromPacketNBT(CompoundNBT cmp) { positionAt = cmp.getInt(TAG_POSITION); - for(int i = 0; i < ticksRemaining.length; i++) + for (int i = 0; i < ticksRemaining.length; i++) { ticksRemaining[i] = cmp.getInt(TAG_TICKS_REMAINING + i); + } } @Override public void writeToPacketNBT(CompoundNBT cmp) { cmp.putInt(TAG_POSITION, positionAt); - for(int i = 0; i < ticksRemaining.length; i++) + for (int i = 0; i < ticksRemaining.length; i++) { cmp.putInt(TAG_TICKS_REMAINING + i, ticksRemaining[i]); + } } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/BergamuteEventHandler.java b/src/main/java/vazkii/botania/common/block/subtile/functional/BergamuteEventHandler.java index 14d5608eb..02307c5b7 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/BergamuteEventHandler.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/BergamuteEventHandler.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.common.block.subtile.functional; import net.minecraft.client.audio.ISound; @@ -14,13 +22,14 @@ import net.minecraftforge.client.event.sound.PlaySoundEvent; import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.common.block.tile.mana.TilePool; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import java.awt.*; + import java.util.Random; @Mod.EventBusSubscriber(value = Dist.CLIENT, modid = LibMisc.MOD_ID) @@ -36,7 +45,7 @@ public class BergamuteEventHandler { ISound sound = evt.getResultSound(); if (sound != null && shouldSilence(sound)) { - if(sound instanceof ITickableSound) { + if (sound instanceof ITickableSound) { evt.setResultSound(new WrappedTickableSound((ITickableSound) sound, MULTIPLIER)); } else { SubTileBergamute berg = SubTileBergamute.getBergamuteNearby(sound.getX(), sound.getY(), sound.getZ()); @@ -49,7 +58,7 @@ public class BergamuteEventHandler { float red = (color >> 16 & 0xFF) / 255F; float green = (color >> 8 & 0xFF) / 255F; float blue = (color & 0xFF) / 255F; - BotaniaAPI.internalHandler.sparkleFX(berg.getWorld(), berg.getEffectivePos().getX() + 0.3 + Math.random() * 0.5, berg.getEffectivePos().getY() + 0.5 + Math.random() * 0.5, berg.getEffectivePos().getZ() + 0.3 + Math.random() * 0.5, red, green, blue, (float) Math.random(), 5); + BotaniaAPI.internalHandler.sparkleFX(berg.getWorld(), berg.getEffectivePos().getX() + 0.3 + Math.random() * 0.5, berg.getEffectivePos().getY() + 0.5 + Math.random() * 0.5, berg.getEffectivePos().getZ() + 0.3 + Math.random() * 0.5, red, green, blue, (float) Math.random(), 5); } } } @@ -81,18 +90,70 @@ public class BergamuteEventHandler { return compose.getVolume() * mult; } - @Nonnull @Override public ResourceLocation getSoundLocation() { return compose.getSoundLocation(); } - @Nullable @Override public SoundEventAccessor createAccessor(@Nonnull SoundHandler handler) { return compose.createAccessor(handler); } - @Nonnull @Override public Sound getSound() { return compose.getSound(); } - @Nonnull @Override public SoundCategory getCategory() { return compose.getCategory(); } - @Override public boolean canRepeat() { return compose.canRepeat(); } - @Override public boolean isGlobal() { return compose.isGlobal(); } - @Override public int getRepeatDelay() { return compose.getRepeatDelay(); } - @Override public float getPitch() { return compose.getPitch(); } - @Override public float getX() { return compose.getX(); } - @Override public float getY() { return compose.getY(); } - @Override public float getZ() { return compose.getZ(); } - @Nonnull @Override public AttenuationType getAttenuationType() { return compose.getAttenuationType(); } + @Nonnull + @Override + public ResourceLocation getSoundLocation() { + return compose.getSoundLocation(); + } + + @Nullable + @Override + public SoundEventAccessor createAccessor(@Nonnull SoundHandler handler) { + return compose.createAccessor(handler); + } + + @Nonnull + @Override + public Sound getSound() { + return compose.getSound(); + } + + @Nonnull + @Override + public SoundCategory getCategory() { + return compose.getCategory(); + } + + @Override + public boolean canRepeat() { + return compose.canRepeat(); + } + + @Override + public boolean isGlobal() { + return compose.isGlobal(); + } + + @Override + public int getRepeatDelay() { + return compose.getRepeatDelay(); + } + + @Override + public float getPitch() { + return compose.getPitch(); + } + + @Override + public float getX() { + return compose.getX(); + } + + @Override + public float getY() { + return compose.getY(); + } + + @Override + public float getZ() { + return compose.getZ(); + } + + @Nonnull + @Override + public AttenuationType getAttenuationType() { + return compose.getAttenuationType(); + } } @OnlyIn(Dist.CLIENT) @@ -105,7 +166,14 @@ public class BergamuteEventHandler { compose = toWrap; } - @Override public boolean isDonePlaying() { return compose.isDonePlaying(); } - @Override public void tick() { compose.tick(); } + @Override + public boolean isDonePlaying() { + return compose.isDonePlaying(); + } + + @Override + public void tick() { + compose.tick(); + } } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileAgricarnation.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileAgricarnation.java index 4046a4bd8..f7930b86f 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileAgricarnation.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileAgricarnation.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 19, 2014, 10:16:53 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; import com.google.common.collect.ImmutableSet; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -18,14 +17,13 @@ import net.minecraft.block.BushBlock; import net.minecraft.block.CropsBlock; import net.minecraft.block.IGrowable; import net.minecraft.block.SaplingBlock; -import net.minecraft.block.SeaPickleBlock; import net.minecraft.block.SweetBerryBushBlock; import net.minecraft.block.material.Material; -import net.minecraft.tags.BlockTags; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityFunctionalFlower; import vazkii.botania.common.core.handler.ConfigHandler; @@ -35,8 +33,7 @@ import vazkii.botania.common.lib.LibMisc; import java.util.Set; public class SubTileAgricarnation extends TileEntityFunctionalFlower { - @ObjectHolder(LibMisc.MOD_ID + ":agricarnation") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":agricarnation") public static TileEntityType TYPE; private static final Set MATERIALS = ImmutableSet.of(Material.PLANTS, Material.CACTUS, Material.ORGANIC, Material.LEAVES, Material.GOURD, Material.OCEAN_PLANT, Material.BAMBOO); @@ -55,29 +52,33 @@ public class SubTileAgricarnation extends TileEntityFunctionalFlower { public void tickFlower() { super.tickFlower(); - if(getWorld().isRemote) + if (getWorld().isRemote) { return; + } - if(ticksExisted % 200 == 0) + if (ticksExisted % 200 == 0) { sync(); + } - if(ticksExisted % 6 == 0 && redstoneSignal == 0) { + if (ticksExisted % 6 == 0 && redstoneSignal == 0) { int range = getRange(); int x = getEffectivePos().getX() + getWorld().rand.nextInt(range * 2 + 1) - range; int z = getEffectivePos().getZ() + getWorld().rand.nextInt(range * 2 + 1) - range; - for(int i = 4; i > -2; i--) { + for (int i = 4; i > -2; i--) { int y = getEffectivePos().getY() + i; BlockPos pos = new BlockPos(x, y, z); - if(getWorld().isAirBlock(pos)) + if (getWorld().isAirBlock(pos)) { continue; + } - if(isPlant(pos) && getMana() > 5) { + if (isPlant(pos) && getMana() > 5) { Block block = getWorld().getBlockState(pos).getBlock(); addMana(-5); getWorld().getPendingBlockTicks().scheduleTick(pos, block, 1); - if(ConfigHandler.COMMON.blockBreakParticles.get()) + if (ConfigHandler.COMMON.blockBreakParticles.get()) { getWorld().playEvent(2005, pos, 6 + getWorld().rand.nextInt(4)); + } getWorld().playSound(null, x, y, z, ModSounds.agricarnation, SoundCategory.BLOCKS, 0.01F, 0.5F + (float) Math.random() * 0.5F); break; @@ -93,21 +94,24 @@ public class SubTileAgricarnation extends TileEntityFunctionalFlower { /** * @return Whether the block at {@code pos} grows "naturally". That is, whether its IGrowable action is simply - * growing itself, instead of something like spreading around or creating flowers around, etc, and whether this - * action would have happened normally over time without bonemeal. + * growing itself, instead of something like spreading around or creating flowers around, etc, and whether + * this + * action would have happened normally over time without bonemeal. */ private boolean isPlant(BlockPos pos) { BlockState state = getWorld().getBlockState(pos); Block block = state.getBlock(); // Grass spreads when ticked - if(block == Blocks.GRASS_BLOCK) + if (block == Blocks.GRASS_BLOCK) { return false; + } // Exclude all BushBlock except known vanilla subclasses if (block instanceof BushBlock && !(block instanceof CropsBlock) - && !(block instanceof SaplingBlock) && !(block instanceof SweetBerryBushBlock)) + && !(block instanceof SaplingBlock) && !(block instanceof SweetBerryBushBlock)) { return false; + } return MATERIALS.contains(state.getMaterial()) && block instanceof IGrowable @@ -130,18 +134,20 @@ public class SubTileAgricarnation extends TileEntityFunctionalFlower { @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(getEffectivePos(), getRange()); + return new RadiusDescriptor.Square(getEffectivePos(), getRange()); } public static class Mini extends SubTileAgricarnation { - @ObjectHolder(LibMisc.MOD_ID + ":agricarnation_chibi") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":agricarnation_chibi") public static TileEntityType TYPE; public Mini() { super(TYPE); } - @Override public int getRange() { return RANGE_MINI; } + @Override + public int getRange() { + return RANGE_MINI; + } } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBellethorn.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBellethorn.java index 2eebb6d08..8d9596c69 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBellethorn.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBellethorn.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 27, 2014, 2:47:40 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -18,6 +16,7 @@ import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.DamageSource; import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityFunctionalFlower; import vazkii.botania.common.lib.LibMisc; @@ -26,8 +25,7 @@ import java.util.List; import java.util.function.Predicate; public class SubTileBellethorn extends TileEntityFunctionalFlower { - @ObjectHolder(LibMisc.MOD_ID + ":bellethorn") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":bellethorn") public static TileEntityType TYPE; public static final int RANGE = 6; public static final int RANGE_MINI = 1; @@ -54,23 +52,26 @@ public class SubTileBellethorn extends TileEntityFunctionalFlower { public void tickFlower() { super.tickFlower(); - if(getWorld().isRemote || redstoneSignal > 0) + if (getWorld().isRemote || redstoneSignal > 0) { return; + } - if(ticksExisted % 200 == 0) + if (ticksExisted % 200 == 0) { sync(); + } final int manaToUse = getManaCost(); - if(ticksExisted % 5 == 0) { + if (ticksExisted % 5 == 0) { int range = getRange(); List entities = getWorld().getEntitiesWithinAABB(LivingEntity.class, new AxisAlignedBB(getEffectivePos().add(-range, -range, -range), getEffectivePos().add(range + 1, range + 1, range + 1)), getSelector()); - for(LivingEntity entity : entities) { - if(entity.hurtTime == 0 && getMana() >= manaToUse) { + for (LivingEntity entity : entities) { + if (entity.hurtTime == 0 && getMana() >= manaToUse) { int dmg = 4; - if(entity instanceof WitchEntity) + if (entity instanceof WitchEntity) { dmg = 20; + } entity.attackEntityFrom(DamageSource.MAGIC, dmg); addMana(-manaToUse); @@ -99,18 +100,20 @@ public class SubTileBellethorn extends TileEntityFunctionalFlower { @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(getEffectivePos(), getRange()); + return new RadiusDescriptor.Square(getEffectivePos(), getRange()); } public static class Mini extends SubTileBellethorn { - @ObjectHolder(LibMisc.MOD_ID + ":bellethorn_chibi") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":bellethorn_chibi") public static TileEntityType TYPE; public Mini() { super(TYPE); } - @Override public int getRange() { return RANGE_MINI; } + @Override + public int getRange() { + return RANGE_MINI; + } } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBergamute.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBergamute.java index 32c6ac11b..87d17d60d 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBergamute.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBergamute.java @@ -1,7 +1,16 @@ +/* + * This class is 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 + */ package vazkii.botania.common.block.subtile.functional; import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityFunctionalFlower; import vazkii.botania.common.lib.LibMisc; @@ -11,8 +20,7 @@ import java.util.Set; import java.util.WeakHashMap; public class SubTileBergamute extends TileEntityFunctionalFlower { - @ObjectHolder(LibMisc.MOD_ID + ":bergamute") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":bergamute") public static TileEntityType TYPE; private static final int RANGE = 4; private static final Set existingFlowers = Collections.newSetFromMap(new WeakHashMap<>()); @@ -26,7 +34,7 @@ public class SubTileBergamute extends TileEntityFunctionalFlower { super.tickFlower(); if (getWorld().isRemote) { - if(!existingFlowers.contains(this)) { + if (!existingFlowers.contains(this)) { existingFlowers.add(this); } } @@ -57,7 +65,7 @@ public class SubTileBergamute extends TileEntityFunctionalFlower { @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Circle(getEffectivePos(), RANGE); + return new RadiusDescriptor.Circle(getEffectivePos(), RANGE); } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBubbell.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBubbell.java index a19f53dc1..e34e4fefb 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBubbell.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileBubbell.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 10, 2015, 10:28:42 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -18,6 +16,7 @@ import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityFunctionalFlower; import vazkii.botania.common.block.ModBlocks; @@ -25,9 +24,7 @@ import vazkii.botania.common.block.tile.TileFakeAir; import vazkii.botania.common.lib.LibMisc; public class SubTileBubbell extends TileEntityFunctionalFlower { - @ObjectHolder(LibMisc.MOD_ID + ":bubbell") - public static TileEntityType TYPE; - + @ObjectHolder(LibMisc.MOD_ID + ":bubbell") public static TileEntityType TYPE; private static final int RANGE = 12; private static final int RANGE_MINI = 6; @@ -48,22 +45,25 @@ public class SubTileBubbell extends TileEntityFunctionalFlower { public void tickFlower() { super.tickFlower(); - if(getWorld().isRemote) + if (getWorld().isRemote) { return; + } - if(ticksExisted % 200 == 0) + if (ticksExisted % 200 == 0) { sync(); + } - if(getMana() > COST_PER_TICK) { + if (getMana() > COST_PER_TICK) { addMana(-COST_PER_TICK); - if(ticksExisted % 10 == 0 && range < getRange()) + if (ticksExisted % 10 == 0 && range < getRange()) { range++; + } - for(BlockPos pos : BlockPos.getAllInBoxMutable(getEffectivePos().add(-range, -range, -range), getEffectivePos().add(range, range, range))) { - if(getEffectivePos().distanceSq(pos) < range * range) { + for (BlockPos pos : BlockPos.getAllInBoxMutable(getEffectivePos().add(-range, -range, -range), getEffectivePos().add(range, range, range))) { + if (getEffectivePos().distanceSq(pos) < range * range) { BlockState state = getWorld().getBlockState(pos); - if(state.getMaterial() == Material.WATER) { + if (state.getMaterial() == Material.WATER) { getWorld().setBlockState(pos, ModBlocks.fakeAir.getDefaultState(), 2); TileFakeAir air = (TileFakeAir) getWorld().getTileEntity(pos); air.setFlower(this); @@ -75,7 +75,7 @@ public class SubTileBubbell extends TileEntityFunctionalFlower { public static boolean isValidBubbell(World world, BlockPos pos) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof SubTileBubbell) { + if (tile instanceof SubTileBubbell) { return ((SubTileBubbell) tile).getMana() > COST_PER_TICK; } @@ -114,14 +114,16 @@ public class SubTileBubbell extends TileEntityFunctionalFlower { } public static class Mini extends SubTileBubbell { - @ObjectHolder(LibMisc.MOD_ID + ":bubbell_chibi") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":bubbell_chibi") public static TileEntityType TYPE; public Mini() { super(TYPE); } - @Override public int getRange() { return RANGE_MINI; } + @Override + public int getRange() { + return RANGE_MINI; + } } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileClayconia.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileClayconia.java index d68775d9f..b79cd022d 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileClayconia.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileClayconia.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 17, 2014, 12:05:37 AM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -18,6 +16,7 @@ import net.minecraft.item.Items; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.BlockPos; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityFunctionalFlower; import vazkii.botania.common.core.handler.ConfigHandler; @@ -27,8 +26,7 @@ import java.util.ArrayList; import java.util.List; public class SubTileClayconia extends TileEntityFunctionalFlower { - @ObjectHolder(LibMisc.MOD_ID + ":clayconia") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":clayconia") public static TileEntityType TYPE; private static final int COST = 80; private static final int RANGE = 5; @@ -49,13 +47,14 @@ public class SubTileClayconia extends TileEntityFunctionalFlower { public void tickFlower() { super.tickFlower(); - if(!getWorld().isRemote && ticksExisted % 5 == 0) { - if(getMana() >= COST) { + if (!getWorld().isRemote && ticksExisted % 5 == 0) { + if (getMana() >= COST) { BlockPos coords = getCoordsToPut(); - if(coords != null) { + if (coords != null) { getWorld().removeBlock(coords, false); - if(ConfigHandler.COMMON.blockBreakParticles.get()) + if (ConfigHandler.COMMON.blockBreakParticles.get()) { getWorld().playEvent(2001, coords, Block.getStateId(Blocks.SAND.getDefaultState())); + } ItemEntity item = new ItemEntity(getWorld(), coords.getX() + 0.5, coords.getY() + 0.5, coords.getZ() + 0.5, new ItemStack(Items.CLAY_BALL)); getWorld().addEntity(item); addMana(-COST); @@ -70,23 +69,27 @@ public class SubTileClayconia extends TileEntityFunctionalFlower { int range = getRange(); int rangeY = getRangeY(); - for(int i = -range; i < range + 1; i++) - for(int j = -rangeY; j < rangeY + 1; j++) - for(int k = -range; k < range + 1; k++) { + for (int i = -range; i < range + 1; i++) { + for (int j = -rangeY; j < rangeY + 1; j++) { + for (int k = -range; k < range + 1; k++) { BlockPos pos = getEffectivePos().add(i, j, k); Block block = getWorld().getBlockState(pos).getBlock(); - if(block == Blocks.SAND) + if (block == Blocks.SAND) { possibleCoords.add(pos); + } } + } + } - if(possibleCoords.isEmpty()) + if (possibleCoords.isEmpty()) { return null; + } return possibleCoords.get(getWorld().rand.nextInt(possibleCoords.size())); } @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(getEffectivePos(), getRange()); + return new RadiusDescriptor.Square(getEffectivePos(), getRange()); } public int getRange() { @@ -108,14 +111,20 @@ public class SubTileClayconia extends TileEntityFunctionalFlower { } public static class Mini extends SubTileClayconia { - @ObjectHolder(LibMisc.MOD_ID + ":bellethorn_chibi") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":bellethorn_chibi") public static TileEntityType TYPE; public Mini() { super(TYPE); } - @Override public int getRange() { return RANGE_MINI; } - @Override public int getRangeY() { return RANGE_Y_MINI; } + @Override + public int getRange() { + return RANGE_MINI; + } + + @Override + public int getRangeY() { + return RANGE_Y_MINI; + } } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileDaffomill.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileDaffomill.java index 1be63932c..48e07c313 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileDaffomill.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileDaffomill.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 20, 2014, 11:43:02 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -25,6 +23,7 @@ import net.minecraft.world.World; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityFunctionalFlower; import vazkii.botania.client.fx.WispParticleData; @@ -35,8 +34,7 @@ import vazkii.botania.common.network.PacketItemAge; import java.util.List; public class SubTileDaffomill extends TileEntityFunctionalFlower { - @ObjectHolder(LibMisc.MOD_ID + ":daffomill") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":daffomill") public static TileEntityType TYPE; private static final String TAG_ORIENTATION = "orientation"; private static final String TAG_WIND_TICKS = "windTicks"; @@ -52,24 +50,24 @@ public class SubTileDaffomill extends TileEntityFunctionalFlower { public void tickFlower() { super.tickFlower(); - if(getWorld().rand.nextInt(4) == 0) { + if (getWorld().rand.nextInt(4) == 0) { WispParticleData data = WispParticleData.wisp(0.25F + (float) Math.random() * 0.15F, 0.05F, 0.05F, 0.05F); world.addParticle(data, getEffectivePos().getX() + Math.random(), getEffectivePos().getY() + Math.random(), getEffectivePos().getZ() + Math.random(), orientation.getXOffset() * 0.1F, orientation.getYOffset() * 0.1F, orientation.getZOffset() * 0.1F); } - if(windTicks == 0 && getMana() > 0) { + if (windTicks == 0 && getMana() > 0) { windTicks = 20; addMana(-1); } - if(windTicks > 0 && redstoneSignal == 0) { + if (windTicks > 0 && redstoneSignal == 0) { AxisAlignedBB axis = aabbForOrientation(); - if(axis != null) { + if (axis != null) { List items = getWorld().getEntitiesWithinAABB(ItemEntity.class, axis); int slowdown = getSlowdownFactor(); - for(ItemEntity item : items) { - if(item.isAlive() && item.age >= slowdown) { + for (ItemEntity item : items) { + if (item.isAlive() && item.age >= slowdown) { item.setMotion( item.getMotion().getX() + orientation.getXOffset() * 0.05, item.getMotion().getY() + orientation.getYOffset() * 0.05, @@ -92,19 +90,20 @@ public class SubTileDaffomill extends TileEntityFunctionalFlower { int l = 16; AxisAlignedBB axis = null; - switch(orientation) { - case NORTH : + switch (orientation) { + case NORTH: axis = new AxisAlignedBB(x - w, y - h, z - l, x + w + 1, y + h, z); break; - case SOUTH : + case SOUTH: axis = new AxisAlignedBB(x - w, y - h, z + 1, x + w + 1, y + h, z + l + 1); break; - case WEST : + case WEST: axis = new AxisAlignedBB(x - l, y - h, z - w, x, y + h, z + w + 1); break; - case EAST : + case EAST: axis = new AxisAlignedBB(x + 1, y - h, z - w, x + l + 1, y + h, z + w + 1); - default: break; + default: + break; } return axis; } @@ -116,23 +115,27 @@ public class SubTileDaffomill extends TileEntityFunctionalFlower { @Override public boolean onWanded(PlayerEntity player, ItemStack wand) { - if(player == null) + if (player == null) { return false; + } - if(player.isSneaking()) { - if(!player.world.isRemote) { + if (player.isSneaking()) { + if (!player.world.isRemote) { orientation = orientation.rotateY(); sync(); } return true; - } else return super.onWanded(player, wand); + } else { + return super.onWanded(player, wand); + } } - + @Override public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, LivingEntity entity, ItemStack stack) { - if(entity != null) + if (entity != null) { orientation = entity.getHorizontalFacing(); + } super.onBlockPlacedBy(world, pos, state, entity, stack); } @@ -140,7 +143,7 @@ public class SubTileDaffomill extends TileEntityFunctionalFlower { public RadiusDescriptor getRadius() { AxisAlignedBB aabb = aabbForOrientation(); aabb = new AxisAlignedBB(aabb.minX, getEffectivePos().getY(), aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ); - return new RadiusDescriptor.Rectangle(getEffectivePos(), aabb); + return new RadiusDescriptor.Rectangle(getEffectivePos(), aabb); } @Override @@ -172,7 +175,7 @@ public class SubTileDaffomill extends TileEntityFunctionalFlower { // Send item age to client to prevent client desync when an item is e.g. dropped by a powered open crate @SubscribeEvent public static void onItemTrack(PlayerEvent.StartTracking evt) { - if(evt.getTarget() instanceof ItemEntity) { + if (evt.getTarget() instanceof ItemEntity) { int entityId = evt.getTarget().getEntityId(); int age = ((ItemEntity) evt.getTarget()).age; PacketHandler.sendTo((ServerPlayerEntity) evt.getPlayer(), new PacketItemAge(entityId, age)); diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileDreadthorn.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileDreadthorn.java index 8de2f7a36..f6ec5e731 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileDreadthorn.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileDreadthorn.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 15, 2014, 4:25:24 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -14,13 +12,13 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.passive.AnimalEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.common.lib.LibMisc; import java.util.function.Predicate; public class SubTileDreadthorn extends SubTileBellethorn { - @ObjectHolder(LibMisc.MOD_ID + ":dreadthorn") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":dreadthorn") public static TileEntityType TYPE; public SubTileDreadthorn() { super(TYPE); @@ -41,5 +39,4 @@ public class SubTileDreadthorn extends SubTileBellethorn { return 30; } - } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileExoflame.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileExoflame.java index 8597b2a3d..55da40a2b 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileExoflame.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileExoflame.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 19, 2014, 3:42:32 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -15,6 +13,7 @@ import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.item.IExoflameHeatable; import vazkii.botania.api.subtile.RadiusDescriptor; @@ -22,8 +21,7 @@ import vazkii.botania.api.subtile.TileEntityFunctionalFlower; import vazkii.botania.common.lib.LibMisc; public class SubTileExoflame extends TileEntityFunctionalFlower { - @ObjectHolder(LibMisc.MOD_ID + ":exoflame") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":exoflame") public static TileEntityType TYPE; private static final int RANGE = 5; private static final int RANGE_Y = 2; @@ -37,40 +35,43 @@ public class SubTileExoflame extends TileEntityFunctionalFlower { public void tickFlower() { super.tickFlower(); - if(getWorld().isRemote || getMana() <= 2) + if (getWorld().isRemote || getMana() <= 2) { return; + } boolean did = false; - for(BlockPos pos : BlockPos.getAllInBoxMutable(getEffectivePos().add(-RANGE, -RANGE_Y, -RANGE), + for (BlockPos pos : BlockPos.getAllInBoxMutable(getEffectivePos().add(-RANGE, -RANGE_Y, -RANGE), getEffectivePos().add(RANGE, RANGE_Y, RANGE))) { TileEntity tile = getWorld().getTileEntity(pos); - if(tile != null) { + if (tile != null) { LazyOptional cap = tile.getCapability(BotaniaAPI.EXOFLAME_HEATABLE_CAP); - if(cap.isPresent()) { + if (cap.isPresent()) { IExoflameHeatable heatable = cap.orElseThrow(NullPointerException::new); - if(heatable.canSmelt() && getMana() > 2) { - if(heatable.getBurnTime() < 2) { + if (heatable.canSmelt() && getMana() > 2) { + if (heatable.getBurnTime() < 2) { heatable.boostBurnTime(); addMana(-COST); did = true; } - if(ticksExisted % 2 == 0) + if (ticksExisted % 2 == 0) { heatable.boostCookTime(); + } - if(getMana() <= 0) + if (getMana() <= 0) { break; + } } } } } - if(did) + if (did) { sync(); + } } - @Override public RadiusDescriptor getRadius() { return new RadiusDescriptor.Square(getEffectivePos(), RANGE); diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileFallenKanade.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileFallenKanade.java index d54b97db2..357158058 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileFallenKanade.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileFallenKanade.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 14, 2014, 8:54:11 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -17,6 +15,7 @@ import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.world.dimension.EndDimension; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityFunctionalFlower; import vazkii.botania.common.lib.LibMisc; @@ -24,8 +23,7 @@ import vazkii.botania.common.lib.LibMisc; import java.util.List; public class SubTileFallenKanade extends TileEntityFunctionalFlower { - @ObjectHolder(LibMisc.MOD_ID + ":fallen_kanade") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":fallen_kanade") public static TileEntityType TYPE; private static final int RANGE = 2; private static final int COST = 120; @@ -38,24 +36,25 @@ public class SubTileFallenKanade extends TileEntityFunctionalFlower { public void tickFlower() { super.tickFlower(); - if(!getWorld().isRemote && !(getWorld().getDimension() instanceof EndDimension)) { + if (!getWorld().isRemote && !(getWorld().getDimension() instanceof EndDimension)) { boolean did = false; List players = getWorld().getEntitiesWithinAABB(PlayerEntity.class, new AxisAlignedBB(getEffectivePos().add(-RANGE, -RANGE, -RANGE), getEffectivePos().add(RANGE + 1, RANGE + 1, RANGE + 1))); - for(PlayerEntity player : players) { - if(player.getActivePotionEffect(Effects.REGENERATION) == null && getMana() >= COST) { + for (PlayerEntity player : players) { + if (player.getActivePotionEffect(Effects.REGENERATION) == null && getMana() >= COST) { player.addPotionEffect(new EffectInstance(Effects.REGENERATION, 59, 2, true, true)); addMana(-COST); did = true; } } - if(did) + if (did) { sync(); + } } } @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(getEffectivePos(), RANGE); + return new RadiusDescriptor.Square(getEffectivePos(), RANGE); } @Override diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHeiseiDream.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHeiseiDream.java index 0f35472f2..cf7f779ce 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHeiseiDream.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHeiseiDream.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 16, 2014, 12:37:40 AM (GMT)] */ package vazkii.botania.common.block.subtile.functional; import com.google.common.base.Predicates; + import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.MobEntity; @@ -20,6 +19,7 @@ import net.minecraft.entity.monster.IMob; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityFunctionalFlower; import vazkii.botania.common.lib.LibMisc; @@ -27,8 +27,7 @@ import vazkii.botania.common.lib.LibMisc; import java.util.List; public class SubTileHeiseiDream extends TileEntityFunctionalFlower { - @ObjectHolder(LibMisc.MOD_ID + ":heisei_dream") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":heisei_dream") public static TileEntityType TYPE; private static final int RANGE = 5; private static final int COST = 100; @@ -41,35 +40,38 @@ public class SubTileHeiseiDream extends TileEntityFunctionalFlower { public void tickFlower() { super.tickFlower(); - if(getWorld().isRemote) + if (getWorld().isRemote) { return; + } @SuppressWarnings("unchecked") List mobs = (List) getWorld().getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(getEffectivePos().add(-RANGE, -RANGE, -RANGE), getEffectivePos().add(RANGE + 1, RANGE + 1, RANGE + 1)), Predicates.instanceOf(IMob.class)); - if(mobs.size() > 1 && getMana() >= COST) - for(IMob mob : mobs) { - if(mob instanceof MobEntity) { + if (mobs.size() > 1 && getMana() >= COST) { + for (IMob mob : mobs) { + if (mob instanceof MobEntity) { MobEntity entity = (MobEntity) mob; - if(brainwashEntity(entity, mobs)) { + if (brainwashEntity(entity, mobs)) { addMana(-COST); sync(); break; } } } + } } public static boolean brainwashEntity(MobEntity entity, List mobs) { LivingEntity target = entity.getAttackTarget(); boolean did = false; - if(!(target instanceof IMob)) { + if (!(target instanceof IMob)) { IMob newTarget; - do newTarget = mobs.get(entity.world.rand.nextInt(mobs.size())); - while(newTarget == entity); + do { + newTarget = mobs.get(entity.world.rand.nextInt(mobs.size())); + } while (newTarget == entity); - if(newTarget instanceof MobEntity) { + if (newTarget instanceof MobEntity) { entity.setAttackTarget(null); // Move any EntityAIHurtByTarget to highest priority @@ -93,7 +95,7 @@ public class SubTileHeiseiDream extends TileEntityFunctionalFlower { @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(getEffectivePos(), RANGE); + return new RadiusDescriptor.Square(getEffectivePos(), RANGE); } @Override diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHopperhock.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHopperhock.java index a0b33cf0d..a1c370a3f 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHopperhock.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHopperhock.java @@ -1,18 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 20, 2014, 5:54:39 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.block.Block; + import net.minecraft.block.BlockState; import net.minecraft.block.ChestBlock; import net.minecraft.client.Minecraft; @@ -23,8 +20,6 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.state.properties.ChestType; -import net.minecraft.tileentity.ChestTileEntity; -import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraft.util.math.AxisAlignedBB; @@ -34,21 +29,19 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.registries.ObjectHolder; -import org.lwjgl.opengl.GL11; + import vazkii.botania.api.corporea.InvWithLocation; import vazkii.botania.api.mana.IManaItem; import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityFunctionalFlower; import vazkii.botania.common.core.helper.InventoryHelper; -import vazkii.botania.common.core.helper.MathHelper; import vazkii.botania.common.lib.LibMisc; import java.util.ArrayList; import java.util.List; public class SubTileHopperhock extends TileEntityFunctionalFlower { - @ObjectHolder(LibMisc.MOD_ID + ":hopperhock") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":hopperhock") public static TileEntityType TYPE; private static final String TAG_FILTER_TYPE = "filterType"; private static final int RANGE_MANA = 10; @@ -71,8 +64,9 @@ public class SubTileHopperhock extends TileEntityFunctionalFlower { public void tickFlower() { super.tickFlower(); - if(getWorld().isRemote || redstoneSignal > 0) + if (getWorld().isRemote || redstoneSignal > 0) { return; + } boolean pulledAny = false; int range = getRange(); @@ -82,20 +76,21 @@ public class SubTileHopperhock extends TileEntityFunctionalFlower { List items = getWorld().getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(pos.add(-range, -range, -range), pos.add(range + 1, range + 1, range + 1))); int slowdown = getSlowdownFactor(); - for(ItemEntity item : items) { - if(item.age < 60 + slowdown || item.age >= 105 && item.age < 110 || !item.isAlive() || item.getItem().isEmpty()) + for (ItemEntity item : items) { + if (item.age < 60 + slowdown || item.age >= 105 && item.age < 110 || !item.isAlive() || item.getItem().isEmpty()) { continue; + } ItemStack stack = item.getItem(); IItemHandler invToPutItemIn = null; boolean priorityInv = false; int amountToPutIn = 0; - for(Direction dir : Direction.values()) { + for (Direction dir : Direction.values()) { BlockPos pos_ = pos.offset(dir); InvWithLocation inv = InventoryHelper.getInventoryWithLocation(getWorld(), pos_, dir.getOpposite()); - if(inv != null) { + if (inv != null) { List filter = getFilterForInventory(pos_, true); boolean canAccept = canAcceptItem(stack, filter, filterType); @@ -104,12 +99,13 @@ public class SubTileHopperhock extends TileEntityFunctionalFlower { canAccept &= availablePut > 0; - if(canAccept) { + if (canAccept) { boolean priority = !filter.isEmpty(); - setInv : { - if(priorityInv && !priority) + setInv: { + if (priorityInv && !priority) { break setInv; + } invToPutItemIn = inv.handler; priorityInv = priority; @@ -119,7 +115,7 @@ public class SubTileHopperhock extends TileEntityFunctionalFlower { } } - if(invToPutItemIn != null && item.isAlive()) { + if (invToPutItemIn != null && item.isAlive()) { SubTileSpectranthemum.spawnExplosionParticles(item, 3); ItemHandlerHelper.insertItem(invToPutItemIn, stack.split(amountToPutIn), false); item.setItem(stack); // Just in case someone subclasses EntityItem and changes something important. @@ -127,49 +123,57 @@ public class SubTileHopperhock extends TileEntityFunctionalFlower { } } - if(pulledAny && getMana() > 0) + if (pulledAny && getMana() > 0) { addMana(-1); + } } public boolean canAcceptItem(ItemStack stack, List filter, int filterType) { - if(stack.isEmpty()) + if (stack.isEmpty()) { return false; + } - if(filter.isEmpty()) + if (filter.isEmpty()) { return true; + } - switch(filterType) { - case 0 : { // Accept items in frames only + switch (filterType) { + case 0: { // Accept items in frames only boolean anyFilter = false; - for(ItemStack filterEntry : filter) { - if(filterEntry == null) + for (ItemStack filterEntry : filter) { + if (filterEntry == null) { continue; + } anyFilter = true; boolean itemEqual = stack.getItem() == filterEntry.getItem(); boolean nbtEqual = ItemStack.areItemStackTagsEqual(filterEntry, stack); - if(itemEqual && nbtEqual) + if (itemEqual && nbtEqual) { return true; + } - if(stack.getItem() instanceof IManaItem && itemEqual) + if (stack.getItem() instanceof IManaItem && itemEqual) { return true; + } } return !anyFilter; } - case 1 : return !canAcceptItem(stack, filter, 0); // Accept items not in frames only - default : return true; // Accept all items + case 1: + return !canAcceptItem(stack, filter, 0); // Accept items not in frames only + default: + return true; // Accept all items } } public List getFilterForInventory(BlockPos pos, boolean recursiveForDoubleChests) { List filter = new ArrayList<>(); - if(recursiveForDoubleChests) { + if (recursiveForDoubleChests) { BlockState chest = getWorld().getBlockState(pos); - if(chest.has(ChestBlock.TYPE)) { + if (chest.has(ChestBlock.TYPE)) { ChestType type = chest.get(ChestBlock.TYPE); if (type != ChestType.SINGLE) { BlockPos other = pos.offset(ChestBlock.getDirectionToAttached(chest)); @@ -180,12 +184,13 @@ public class SubTileHopperhock extends TileEntityFunctionalFlower { } } - for(Direction dir : Direction.values()) { + for (Direction dir : Direction.values()) { AxisAlignedBB aabb = new AxisAlignedBB(pos.offset(dir)); List frames = getWorld().getEntitiesWithinAABB(ItemFrameEntity.class, aabb); - for(ItemFrameEntity frame : frames) { - if(frame.getHorizontalFacing() == dir) + for (ItemFrameEntity frame : frames) { + if (frame.getHorizontalFacing() == dir) { filter.add(frame.getDisplayedItem()); + } } } @@ -199,18 +204,19 @@ public class SubTileHopperhock extends TileEntityFunctionalFlower { @Override public boolean onWanded(PlayerEntity player, ItemStack wand) { - if(player == null || player.isSneaking()) { + if (player == null || player.isSneaking()) { filterType = filterType == 2 ? 0 : filterType + 1; sync(); return true; + } else { + return super.onWanded(player, wand); } - else return super.onWanded(player, wand); } @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(getEffectivePos(), getRange()); + return new RadiusDescriptor.Square(getEffectivePos(), getRange()); } public int getRange() { @@ -256,13 +262,15 @@ public class SubTileHopperhock extends TileEntityFunctionalFlower { } public static class Mini extends SubTileHopperhock { - @ObjectHolder(LibMisc.MOD_ID + ":hopperhock_chibi") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":hopperhock_chibi") public static TileEntityType TYPE; public Mini() { super(TYPE); } - @Override public int getRange() { return getMana() > 0 ? RANGE_MANA_MINI : RANGE_MINI; } + @Override + public int getRange() { + return getMana() > 0 ? RANGE_MANA_MINI : RANGE_MINI; + } } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHyacidus.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHyacidus.java index 603a049e9..4fa0aff8d 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHyacidus.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileHyacidus.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 15, 2014, 4:47:41 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -18,6 +16,7 @@ import net.minecraft.potion.Effects; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityFunctionalFlower; import vazkii.botania.common.lib.LibMisc; @@ -25,8 +24,7 @@ import vazkii.botania.common.lib.LibMisc; import java.util.List; public class SubTileHyacidus extends TileEntityFunctionalFlower { - @ObjectHolder(LibMisc.MOD_ID + ":hyacidus") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":hyacidus") public static TileEntityType TYPE; private static final int RANGE = 6; private static final int COST = 20; @@ -39,12 +37,13 @@ public class SubTileHyacidus extends TileEntityFunctionalFlower { public void tickFlower() { super.tickFlower(); - if(getWorld().isRemote || redstoneSignal > 0) + if (getWorld().isRemote || redstoneSignal > 0) { return; + } List entities = getWorld().getEntitiesWithinAABB(LivingEntity.class, new AxisAlignedBB(getEffectivePos().add(-RANGE, -RANGE, -RANGE), getEffectivePos().add(RANGE + 1, RANGE + 1, RANGE + 1))); - for(LivingEntity entity : entities) { - if(!(entity instanceof PlayerEntity) && entity.getActivePotionEffect(Effects.POISON) == null && getMana() >= COST && !entity.world.isRemote && entity.getCreatureAttribute() != CreatureAttribute.UNDEAD) { + for (LivingEntity entity : entities) { + if (!(entity instanceof PlayerEntity) && entity.getActivePotionEffect(Effects.POISON) == null && getMana() >= COST && !entity.world.isRemote && entity.getCreatureAttribute() != CreatureAttribute.UNDEAD) { entity.addPotionEffect(new EffectInstance(Effects.POISON, 60, 0)); addMana(-COST); } @@ -68,7 +67,7 @@ public class SubTileHyacidus extends TileEntityFunctionalFlower { @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(getEffectivePos(), RANGE); + return new RadiusDescriptor.Square(getEffectivePos(), RANGE); } -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileJadedAmaranthus.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileJadedAmaranthus.java index f83c970a2..d16f05920 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileJadedAmaranthus.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileJadedAmaranthus.java @@ -1,22 +1,20 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 3, 2014, 10:31:29 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.block.material.Material; import net.minecraft.item.DyeColor; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.BlockPos; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityFunctionalFlower; import vazkii.botania.common.block.ModBlocks; @@ -24,8 +22,7 @@ import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.lib.LibMisc; public class SubTileJadedAmaranthus extends TileEntityFunctionalFlower { - @ObjectHolder(LibMisc.MOD_ID + ":jaded_amaranthus") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":jaded_amaranthus") public static TileEntityType TYPE; private static final int COST = 100; final int RANGE = 4; @@ -38,25 +35,27 @@ public class SubTileJadedAmaranthus extends TileEntityFunctionalFlower { public void tickFlower() { super.tickFlower(); - if(getWorld().isRemote || redstoneSignal > 0) + if (getWorld().isRemote || redstoneSignal > 0) { return; + } - if(ticksExisted % 30 == 0 && getMana() >= COST) { + if (ticksExisted % 30 == 0 && getMana() >= COST) { BlockPos pos = new BlockPos( getEffectivePos().getX() - RANGE + getWorld().rand.nextInt(RANGE * 2 + 1), getEffectivePos().getY() + RANGE, getEffectivePos().getZ() - RANGE + getWorld().rand.nextInt(RANGE * 2 + 1) - ); + ); BlockPos up = pos.up(); - for(int i = 0; i < RANGE * 2; i++) { + for (int i = 0; i < RANGE * 2; i++) { DyeColor color = DyeColor.byId(getWorld().rand.nextInt(16)); BlockState flower = ModBlocks.getFlower(color).getDefaultState(); - if(getWorld().isAirBlock(up) && flower.isValidPosition(getWorld(), up)) { - if(ConfigHandler.COMMON.blockBreakParticles.get()) + if (getWorld().isAirBlock(up) && flower.isValidPosition(getWorld(), up)) { + if (ConfigHandler.COMMON.blockBreakParticles.get()) { getWorld().playEvent(2001, up, Block.getStateId(flower)); + } getWorld().setBlockState(up, flower); addMana(-COST); sync(); @@ -82,7 +81,7 @@ public class SubTileJadedAmaranthus extends TileEntityFunctionalFlower { @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(getEffectivePos(), RANGE); + return new RadiusDescriptor.Square(getEffectivePos(), RANGE); } @Override diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileJiyuulia.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileJiyuulia.java index 896e133b7..7ffc04871 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileJiyuulia.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileJiyuulia.java @@ -1,23 +1,21 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 14, 2014, 11:40:51 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; import net.minecraft.entity.LivingEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.common.lib.LibMisc; public class SubTileJiyuulia extends SubTileTangleberrie { - @ObjectHolder(LibMisc.MOD_ID + ":jiyuulia") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":jiyuulia") public static TileEntityType TYPE; public SubTileJiyuulia() { super(TYPE); diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileLoonuim.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileLoonuim.java index 45d04cacd..75e29a039 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileLoonuim.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileLoonuim.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 31, 2014, 7:49:43 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; + import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.SharedMonsterAttributes; @@ -44,6 +43,7 @@ import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityFunctionalFlower; import vazkii.botania.common.lib.LibMisc; @@ -55,8 +55,7 @@ import java.util.Random; @Mod.EventBusSubscriber(modid = LibMisc.MOD_ID) public class SubTileLoonuim extends TileEntityFunctionalFlower { - @ObjectHolder(LibMisc.MOD_ID + ":loonium") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":loonium") public static TileEntityType TYPE; private static final int COST = 35000; private static final int RANGE = 5; @@ -74,7 +73,7 @@ public class SubTileLoonuim extends TileEntityFunctionalFlower { super.tickFlower(); World world = getWorld(); - if(!world.isRemote && redstoneSignal == 0 && ticksExisted % 100 == 0 && getMana() >= COST) { + if (!world.isRemote && redstoneSignal == 0 && ticksExisted % 100 == 0 && getMana() >= COST) { Random rand = world.rand; ItemStack stack; @@ -82,56 +81,65 @@ public class SubTileLoonuim extends TileEntityFunctionalFlower { LootContext ctx = new LootContext.Builder((ServerWorld) world).build(LootParameterSets.EMPTY); List stacks = ((ServerWorld) world).getServer().getLootTableManager() .getLootTableFromLocation(lootTable).generate(ctx); - if (stacks.isEmpty()) + if (stacks.isEmpty()) { return; - else { + } else { Collections.shuffle(stacks); stack = stacks.get(0); } - } while(stack.isEmpty() || ModTags.Items.LOONIUM_BLACKLIST.contains(stack.getItem())); + } while (stack.isEmpty() || ModTags.Items.LOONIUM_BLACKLIST.contains(stack.getItem())); int bound = RANGE * 2 + 1; int xp = getEffectivePos().getX() - RANGE + rand.nextInt(bound); int yp = getEffectivePos().getY(); int zp = getEffectivePos().getZ() - RANGE + rand.nextInt(bound); - + BlockPos pos = new BlockPos(xp, yp - 1, zp); do { pos = pos.up(); - if(pos.getY() >= 254) + if (pos.getY() >= 254) { return; - } while(world.getBlockState(pos).causesSuffocation(world, pos)); + } + } while (world.getBlockState(pos).causesSuffocation(world, pos)); pos = pos.up(); double x = pos.getX() + Math.random(); double y = pos.getY() + Math.random(); double z = pos.getZ() + Math.random(); - + MonsterEntity entity = null; - if(world.rand.nextInt(50) == 0) + if (world.rand.nextInt(50) == 0) { entity = new EndermanEntity(EntityType.ENDERMAN, world); - else if(world.rand.nextInt(10) == 0) { + } else if (world.rand.nextInt(10) == 0) { entity = new CreeperEntity(EntityType.CREEPER, world); - if(world.rand.nextInt(200) == 0) + if (world.rand.nextInt(200) == 0) { entity.onStruckByLightning(null); - } else - switch(world.rand.nextInt(3)) { + } + } else { + switch (world.rand.nextInt(3)) { case 0: - if(world.rand.nextInt(10) == 0) + if (world.rand.nextInt(10) == 0) { entity = new HuskEntity(EntityType.HUSK, world); - else entity = new ZombieEntity(world); + } else { + entity = new ZombieEntity(world); + } break; case 1: - if(world.rand.nextInt(10) == 0) + if (world.rand.nextInt(10) == 0) { entity = new StrayEntity(EntityType.STRAY, world); - else entity = new SkeletonEntity(EntityType.SKELETON, world); + } else { + entity = new SkeletonEntity(EntityType.SKELETON, world); + } break; case 2: - if(world.rand.nextInt(10) == 0) + if (world.rand.nextInt(10) == 0) { entity = new CaveSpiderEntity(EntityType.CAVE_SPIDER, world); - else entity = new SpiderEntity(EntityType.SPIDER, world); + } else { + entity = new SpiderEntity(EntityType.SPIDER, world); + } break; } + } entity.setPositionAndRotation(x, y, z, world.rand.nextFloat() * 360F, 0); entity.setMotion(Vec3d.ZERO); @@ -154,7 +162,7 @@ public class SubTileLoonuim extends TileEntityFunctionalFlower { entity.onInitialSpawn(world, world.getDifficultyForLocation(pos), SpawnReason.SPAWNER, null, null); world.addEntity(entity); entity.spawnExplosionParticle(); - + addMana(-COST); sync(); } @@ -177,14 +185,15 @@ public class SubTileLoonuim extends TileEntityFunctionalFlower { @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(getEffectivePos(), RANGE); + return new RadiusDescriptor.Square(getEffectivePos(), RANGE); } @Override public void readFromPacketNBT(CompoundNBT cmp) { super.readFromPacketNBT(cmp); - if (cmp.contains(TAG_LOOT_TABLE)) + if (cmp.contains(TAG_LOOT_TABLE)) { lootTable = new ResourceLocation(cmp.getString(TAG_LOOT_TABLE)); + } } @Override @@ -196,7 +205,7 @@ public class SubTileLoonuim extends TileEntityFunctionalFlower { @SubscribeEvent(priority = EventPriority.LOWEST) public static void onDrops(LivingDropsEvent event) { LivingEntity e = event.getEntityLiving(); - if(e.getPersistentData().contains(TAG_ITEMSTACK_TO_DROP)) { + if (e.getPersistentData().contains(TAG_ITEMSTACK_TO_DROP)) { CompoundNBT cmp = e.getPersistentData().getCompound(TAG_ITEMSTACK_TO_DROP); ItemStack stack = ItemStack.read(cmp); event.getDrops().clear(); diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileMarimorphosis.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileMarimorphosis.java index dce827ae8..54fa956ae 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileMarimorphosis.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileMarimorphosis.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 29, 2015, 8:17:55 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -19,6 +17,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.common.BiomeDictionary.Type; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityFunctionalFlower; import vazkii.botania.common.block.ModFluffBlocks; @@ -30,8 +29,7 @@ import java.util.List; import java.util.Set; public class SubTileMarimorphosis extends TileEntityFunctionalFlower { - @ObjectHolder(LibMisc.MOD_ID + ":marimorphosis") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":marimorphosis") public static TileEntityType TYPE; private static final int COST = 12; private static final int RANGE = 8; @@ -62,17 +60,19 @@ public class SubTileMarimorphosis extends TileEntityFunctionalFlower { @Override public void tickFlower() { super.tickFlower(); - if(getWorld().isRemote || redstoneSignal > 0) + if (getWorld().isRemote || redstoneSignal > 0) { return; + } - if(getMana() >= COST && ticksExisted % 2 == 0) { + if (getMana() >= COST && ticksExisted % 2 == 0) { BlockPos coords = getCoordsToPut(); - if(coords != null) { + if (coords != null) { BlockState state = getStoneToPut(coords); - if(state != null) { + if (state != null) { getWorld().setBlockState(coords, state); - if(ConfigHandler.COMMON.blockBreakParticles.get()) + if (ConfigHandler.COMMON.blockBreakParticles.get()) { getWorld().playEvent(2001, coords, Block.getStateId(state)); + } addMana(-COST); sync(); @@ -87,28 +87,39 @@ public class SubTileMarimorphosis extends TileEntityFunctionalFlower { List values = new ArrayList<>(); for (Type type : TYPES) { int times = 1; - if (types.contains(type)) + if (types.contains(type)) { times = 12; + } Block block = biomeTypeToBlock(type); - for (int j = 0; j < times; j++) + for (int j = 0; j < times; j++) { values.add(block); + } } return values.get(getWorld().rand.nextInt(values.size())).getDefaultState(); } private Block biomeTypeToBlock(Type biomeType) { - switch(biomeType.getName()) { - default: throw new IllegalArgumentException("Should have verified type is suitable already: " + biomeType); - case "FOREST": return ModFluffBlocks.biomeStoneForest; - case "PLAINS": return ModFluffBlocks.biomeStonePlains; - case "MOUNTAIN": return ModFluffBlocks.biomeStoneMountain; - case "MUSHROOM": return ModFluffBlocks.biomeStoneFungal; - case "SWAMP": return ModFluffBlocks.biomeStoneSwamp; - case "SANDY": return ModFluffBlocks.biomeStoneDesert; - case "COLD": return ModFluffBlocks.biomeStoneTaiga; - case "MESA": return ModFluffBlocks.biomeStoneMesa; + switch (biomeType.getName()) { + default: + throw new IllegalArgumentException("Should have verified type is suitable already: " + biomeType); + case "FOREST": + return ModFluffBlocks.biomeStoneForest; + case "PLAINS": + return ModFluffBlocks.biomeStonePlains; + case "MOUNTAIN": + return ModFluffBlocks.biomeStoneMountain; + case "MUSHROOM": + return ModFluffBlocks.biomeStoneFungal; + case "SWAMP": + return ModFluffBlocks.biomeStoneSwamp; + case "SANDY": + return ModFluffBlocks.biomeStoneDesert; + case "COLD": + return ModFluffBlocks.biomeStoneTaiga; + case "MESA": + return ModFluffBlocks.biomeStoneMesa; } } @@ -119,21 +130,23 @@ public class SubTileMarimorphosis extends TileEntityFunctionalFlower { int rangeY = getRangeY(); BlockStateMatcher matcher = BlockStateMatcher.forBlock(Blocks.STONE); - for(BlockPos pos : BlockPos.getAllInBoxMutable(getEffectivePos().add(-range, -rangeY, -range), + for (BlockPos pos : BlockPos.getAllInBoxMutable(getEffectivePos().add(-range, -rangeY, -range), getEffectivePos().add(range, rangeY, range))) { BlockState state = getWorld().getBlockState(pos); - if(state.getBlock().isReplaceableOreGen(state, getWorld(), pos, matcher)) + if (state.getBlock().isReplaceableOreGen(state, getWorld(), pos, matcher)) { possibleCoords.add(pos.toImmutable()); + } } - if(possibleCoords.isEmpty()) + if (possibleCoords.isEmpty()) { return null; + } return possibleCoords.get(getWorld().rand.nextInt(possibleCoords.size())); } @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(getEffectivePos(), getRange()); + return new RadiusDescriptor.Square(getEffectivePos(), getRange()); } public int getRange() { @@ -160,15 +173,21 @@ public class SubTileMarimorphosis extends TileEntityFunctionalFlower { } public static class Mini extends SubTileMarimorphosis { - @ObjectHolder(LibMisc.MOD_ID + ":marimorphosis_chibi") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":marimorphosis_chibi") public static TileEntityType TYPE; public Mini() { super(TYPE); } - @Override public int getRange() { return RANGE_MINI; } - @Override public int getRangeY() { return RANGE_Y_MINI; } + @Override + public int getRange() { + return RANGE_MINI; + } + + @Override + public int getRangeY() { + return RANGE_Y_MINI; + } } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileMedumone.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileMedumone.java index 19efcd080..55219debf 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileMedumone.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileMedumone.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 27, 2015, 7:33:17 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -17,6 +15,7 @@ import net.minecraft.potion.Effects; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityFunctionalFlower; import vazkii.botania.common.lib.LibMisc; @@ -24,8 +23,7 @@ import vazkii.botania.common.lib.LibMisc; import java.util.List; public class SubTileMedumone extends TileEntityFunctionalFlower { - @ObjectHolder(LibMisc.MOD_ID + ":medumone") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":medumone") public static TileEntityType TYPE; private static final int RANGE = 6; @@ -37,16 +35,18 @@ public class SubTileMedumone extends TileEntityFunctionalFlower { public void tickFlower() { super.tickFlower(); - if(!getWorld().isRemote && getMana() > 0) { + if (!getWorld().isRemote && getMana() > 0) { List entities = getWorld().getEntitiesWithinAABB(LivingEntity.class, new AxisAlignedBB(getEffectivePos().add(-RANGE, -RANGE, -RANGE), getEffectivePos().add(RANGE + 1, RANGE + 1, RANGE + 1))); - for(LivingEntity entity : entities) - if(!(entity instanceof PlayerEntity)) { + for (LivingEntity entity : entities) { + if (!(entity instanceof PlayerEntity)) { entity.addPotionEffect(new EffectInstance(Effects.SLOWNESS, 2, 100)); addMana(-1); - if(getMana() == 0) + if (getMana() == 0) { return; + } } + } } } @@ -57,7 +57,7 @@ public class SubTileMedumone extends TileEntityFunctionalFlower { @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(getEffectivePos(), RANGE); + return new RadiusDescriptor.Square(getEffectivePos(), RANGE); } @Override diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechid.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechid.java index 261799fd8..88c480b7e 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechid.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechid.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 11, 2014, 5:40:55 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -21,6 +19,7 @@ import net.minecraft.util.SoundCategory; import net.minecraft.util.WeightedRandom; import net.minecraft.util.math.BlockPos; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityFunctionalFlower; @@ -30,6 +29,7 @@ import vazkii.botania.common.core.handler.ModSounds; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nullable; + import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -38,8 +38,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; public class SubTileOrechid extends TileEntityFunctionalFlower { - @ObjectHolder(LibMisc.MOD_ID + ":orechid") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":orechid") public static TileEntityType TYPE; private static final int COST = 17500; private static final int COST_GOG = 700; @@ -60,18 +59,20 @@ public class SubTileOrechid extends TileEntityFunctionalFlower { public void tickFlower() { super.tickFlower(); - if(getWorld().isRemote || redstoneSignal > 0 || !canOperate()) + if (getWorld().isRemote || redstoneSignal > 0 || !canOperate()) { return; + } int cost = getCost(); - if(getMana() >= cost && ticksExisted % getDelay() == 0) { + if (getMana() >= cost && ticksExisted % getDelay() == 0) { BlockPos coords = getCoordsToPut(); - if(coords != null) { + if (coords != null) { BlockState state = getOreToPut(); - if(state != null) { + if (state != null) { getWorld().setBlockState(coords, state); - if(ConfigHandler.COMMON.blockBreakParticles.get()) + if (ConfigHandler.COMMON.blockBreakParticles.get()) { getWorld().playEvent(2001, coords, Block.getStateId(state)); + } getWorld().playSound(null, coords, ModSounds.orechid, SoundCategory.BLOCKS, 2F, 1F); addMana(-cost); @@ -106,15 +107,17 @@ public class SubTileOrechid extends TileEntityFunctionalFlower { private BlockPos getCoordsToPut() { List possibleCoords = new ArrayList<>(); - for(BlockPos pos : BlockPos.getAllInBoxMutable(getEffectivePos().add(-RANGE, -RANGE_Y, -RANGE), + for (BlockPos pos : BlockPos.getAllInBoxMutable(getEffectivePos().add(-RANGE, -RANGE_Y, -RANGE), getEffectivePos().add(RANGE, RANGE_Y, RANGE))) { BlockState state = getWorld().getBlockState(pos); - if(state.getBlock().isReplaceableOreGen(state, getWorld(), pos, getReplaceMatcher())) + if (state.getBlock().isReplaceableOreGen(state, getWorld(), pos, getReplaceMatcher())) { possibleCoords.add(pos.toImmutable()); + } } - if(possibleCoords.isEmpty()) + if (possibleCoords.isEmpty()) { return null; + } return possibleCoords.get(getWorld().rand.nextInt(possibleCoords.size())); } @@ -140,7 +143,7 @@ public class SubTileOrechid extends TileEntityFunctionalFlower { @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(getEffectivePos(), RANGE); + return new RadiusDescriptor.Square(getEffectivePos(), RANGE); } @Override diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechidIgnem.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechidIgnem.java index c402da5ad..174cb302e 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechidIgnem.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileOrechidIgnem.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 30, 2015, 3:27:20 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -15,6 +13,7 @@ import net.minecraft.block.Blocks; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.ResourceLocation; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.common.lib.LibMisc; @@ -22,8 +21,7 @@ import java.util.Map; import java.util.function.Predicate; public class SubTileOrechidIgnem extends SubTileOrechid { - @ObjectHolder(LibMisc.MOD_ID + ":orechid_ignem") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":orechid_ignem") public static TileEntityType TYPE; private static final int COST = 20000; diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTilePollidisiac.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTilePollidisiac.java index 2b5252ccc..73680a877 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTilePollidisiac.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTilePollidisiac.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 15, 2014, 5:56:47 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -16,6 +14,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityFunctionalFlower; import vazkii.botania.common.lib.LibMisc; @@ -23,8 +22,7 @@ import vazkii.botania.common.lib.LibMisc; import java.util.List; public class SubTilePollidisiac extends TileEntityFunctionalFlower { - @ObjectHolder(LibMisc.MOD_ID + ":pollidisiac") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":pollidisiac") public static TileEntityType TYPE; private static final int RANGE = 6; private static final int MANA_COST = 12; @@ -37,28 +35,30 @@ public class SubTilePollidisiac extends TileEntityFunctionalFlower { public void tickFlower() { super.tickFlower(); - if(!getWorld().isRemote) { + if (!getWorld().isRemote) { List items = getWorld().getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(getEffectivePos().add(-RANGE, -RANGE, -RANGE), getEffectivePos().add(RANGE + 1, RANGE + 1, RANGE + 1))); List animals = getWorld().getEntitiesWithinAABB(AnimalEntity.class, new AxisAlignedBB(getEffectivePos().add(-RANGE, -RANGE, -RANGE), getEffectivePos().add(RANGE + 1, RANGE + 1, RANGE + 1))); int slowdown = getSlowdownFactor(); - for(AnimalEntity animal : animals) { - if(getMana() < MANA_COST) + for (AnimalEntity animal : animals) { + if (getMana() < MANA_COST) { break; + } - if(animal.getGrowingAge() == 0 && !animal.isInLove()) { - for(ItemEntity item : items) { - if(item.age < 60 + slowdown || !item.isAlive()) + if (animal.getGrowingAge() == 0 && !animal.isInLove()) { + for (ItemEntity item : items) { + if (item.age < 60 + slowdown || !item.isAlive()) { continue; + } ItemStack stack = item.getItem(); - if(!stack.isEmpty() && animal.isBreedingItem(stack)) { + if (!stack.isEmpty() && animal.isBreedingItem(stack)) { stack.shrink(1); addMana(-MANA_COST); animal.setInLove(1200); - getWorld().setEntityState(animal, (byte)18); + getWorld().setEntityState(animal, (byte) 18); } } } @@ -68,7 +68,7 @@ public class SubTilePollidisiac extends TileEntityFunctionalFlower { @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(getEffectivePos(), RANGE); + return new RadiusDescriptor.Square(getEffectivePos(), RANGE); } @Override diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileRannuncarpus.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileRannuncarpus.java index 0cf736c08..d98e35bfe 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileRannuncarpus.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileRannuncarpus.java @@ -1,20 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 1, 2014, 6:08:25 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; -import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.RenderHelper; import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItemUseContext; @@ -33,7 +29,7 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.registries.ObjectHolder; -import org.lwjgl.opengl.GL11; + import vazkii.botania.api.item.IFlowerPlaceable; import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityFunctionalFlower; @@ -41,14 +37,14 @@ import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; public class SubTileRannuncarpus extends TileEntityFunctionalFlower { - @ObjectHolder(LibMisc.MOD_ID + ":rannuncarpus") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":rannuncarpus") public static TileEntityType TYPE; private static final int RANGE = 2; private static final int RANGE_Y = 3; @@ -72,41 +68,45 @@ public class SubTileRannuncarpus extends TileEntityFunctionalFlower { public void tickFlower() { super.tickFlower(); - if(getWorld().isRemote || redstoneSignal > 0) + if (getWorld().isRemote || redstoneSignal > 0) { return; + } - if(ticksExisted % 10 == 0) { + if (ticksExisted % 10 == 0) { List items = getWorld().getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(getEffectivePos().add(-RANGE, -RANGE_Y, -RANGE), getEffectivePos().add(RANGE + 1, RANGE_Y + 1, RANGE + 1))); List validPositions = getCandidatePositions(); int slowdown = getSlowdownFactor(); - for(ItemEntity item : items) { - if(item.age < 60 + slowdown || !item.isAlive() || item.getItem().isEmpty()) + for (ItemEntity item : items) { + if (item.age < 60 + slowdown || !item.isAlive() || item.getItem().isEmpty()) { continue; + } ItemStack stack = item.getItem(); Item stackItem = stack.getItem(); - if(stackItem instanceof BlockItem || stackItem instanceof IFlowerPlaceable) { - if(!validPositions.isEmpty()) { + if (stackItem instanceof BlockItem || stackItem instanceof IFlowerPlaceable) { + if (!validPositions.isEmpty()) { BlockPos coords = validPositions.get(getWorld().rand.nextInt(validPositions.size())); BlockRayTraceResult ray = new BlockRayTraceResult(Vec3d.ZERO, Direction.UP, coords, false); BlockItemUseContext ctx = new RannuncarpusPlaceContext(getWorld(), stack, ray); boolean success = false; - if(stackItem instanceof IFlowerPlaceable) { + if (stackItem instanceof IFlowerPlaceable) { success = ((IFlowerPlaceable) stackItem).tryPlace(this, ctx); - } if(stackItem instanceof BlockItem) { + } + if (stackItem instanceof BlockItem) { success = ((BlockItem) stackItem).tryPlace(ctx) == ActionResultType.SUCCESS; } - if(success) { - if(ConfigHandler.COMMON.blockBreakParticles.get()) { + if (success) { + if (ConfigHandler.COMMON.blockBreakParticles.get()) { BlockState state = getWorld().getBlockState(ctx.getPos()); getWorld().playEvent(2001, coords, Block.getStateId(state)); } validPositions.remove(coords); - if(getMana() > 1) + if (getMana() > 1) { addMana(-1); + } return; } } @@ -130,8 +130,9 @@ public class SubTileRannuncarpus extends TileEntityFunctionalFlower { center.add(rangePlace, rangePlaceY, rangePlace))) { BlockState state = getWorld().getBlockState(pos); BlockState up = getWorld().getBlockState(pos.up()); - if (filter == state && (up.isAir(getWorld(), pos.up()) || up.getMaterial().isReplaceable())) + if (filter == state && (up.isAir(getWorld(), pos.up()) || up.getMaterial().isReplaceable())) { ret.add(pos.toImmutable()); + } } return ret; } @@ -150,7 +151,7 @@ public class SubTileRannuncarpus extends TileEntityFunctionalFlower { ItemStack recieverStack = new ItemStack(filter.getBlock()); int color = getColor(); - if(!recieverStack.isEmpty()) { + if (!recieverStack.isEmpty()) { ITextComponent stackName = recieverStack.getDisplayName(); int width = 16 + mc.fontRenderer.getStringWidth(stackName.getString()) / 2; int x = mc.getWindow().getScaledWidth() / 2 - width; @@ -164,7 +165,7 @@ public class SubTileRannuncarpus extends TileEntityFunctionalFlower { @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(getEffectivePos(), getRange()); + return new RadiusDescriptor.Square(getEffectivePos(), getRange()); } public int getRange() { @@ -186,15 +187,21 @@ public class SubTileRannuncarpus extends TileEntityFunctionalFlower { } public static class Mini extends SubTileRannuncarpus { - @ObjectHolder(LibMisc.MOD_ID + ":rannuncarpus_chibi") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":rannuncarpus_chibi") public static TileEntityType TYPE; public Mini() { super(TYPE); } - @Override public int getRange() { return getMana() > 0 ? RANGE_PLACE_MANA_MINI : RANGE_PLACE_MINI; } - @Override public int getRangeY() { return RANGE_PLACE_Y_MINI; } + @Override + public int getRange() { + return getMana() > 0 ? RANGE_PLACE_MANA_MINI : RANGE_PLACE_MINI; + } + + @Override + public int getRangeY() { + return RANGE_PLACE_Y_MINI; + } } // BlockItemUseContext uses a nullable player field without checking it -.- @@ -217,7 +224,7 @@ public class SubTileRannuncarpus extends TileEntityFunctionalFlower { @Nonnull @Override public Direction[] getNearestLookingDirections() { - return lookDirs; + return lookDirs; } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileSolegnolia.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileSolegnolia.java index ff8e5da9f..a22c6f1b6 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileSolegnolia.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileSolegnolia.java @@ -1,19 +1,19 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 11, 2015, 4:53:35 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; import com.google.common.collect.MapMaker; + import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityFunctionalFlower; import vazkii.botania.common.lib.LibMisc; @@ -22,8 +22,7 @@ import java.util.Collections; import java.util.Set; public class SubTileSolegnolia extends TileEntityFunctionalFlower { - @ObjectHolder(LibMisc.MOD_ID + ":solegnolia") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":solegnolia") public static TileEntityType TYPE; private static final double RANGE = 5; private static final double RANGE_MINI = 1; @@ -42,7 +41,7 @@ public class SubTileSolegnolia extends TileEntityFunctionalFlower { public void tickFlower() { super.tickFlower(); - if(!existingFlowers.contains(this)) { + if (!existingFlowers.contains(this)) { existingFlowers.add(this); } } @@ -75,18 +74,20 @@ public class SubTileSolegnolia extends TileEntityFunctionalFlower { @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Circle(getEffectivePos(), getRange()); + return new RadiusDescriptor.Circle(getEffectivePos(), getRange()); } public static class Mini extends SubTileSolegnolia { - @ObjectHolder(LibMisc.MOD_ID + ":solegnolia_chibi") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":solegnolia_chibi") public static TileEntityType TYPE; public Mini() { super(TYPE); } - @Override public double getRange() { return RANGE_MINI; } + @Override + public double getRange() { + return RANGE_MINI; + } } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileSpectranthemum.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileSpectranthemum.java index 7a0810c01..9073d7318 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileSpectranthemum.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileSpectranthemum.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 27, 2015, 4:06:58 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -25,6 +23,7 @@ import net.minecraft.util.math.Vec3d; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.mana.IManaItem; import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityFunctionalFlower; @@ -35,8 +34,7 @@ import vazkii.botania.common.network.PacketHandler; import java.util.List; public class SubTileSpectranthemum extends TileEntityFunctionalFlower { - @ObjectHolder(LibMisc.MOD_ID + ":spectranthemum") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":spectranthemum") public static TileEntityType TYPE; private static final String TAG_BIND_X = "bindX"; private static final String TAG_BIND_Y = "bindY"; @@ -58,7 +56,7 @@ public class SubTileSpectranthemum extends TileEntityFunctionalFlower { public void tickFlower() { super.tickFlower(); - if(!getWorld().isRemote && redstoneSignal == 0 && getWorld().isBlockLoaded(bindPos)) { + if (!getWorld().isRemote && redstoneSignal == 0 && getWorld().isBlockLoaded(bindPos)) { BlockPos pos = getEffectivePos(); boolean did = false; @@ -66,18 +64,20 @@ public class SubTileSpectranthemum extends TileEntityFunctionalFlower { List items = getWorld().getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(pos.add(-RANGE, -RANGE, -RANGE), pos.add(RANGE + 1, RANGE + 1, RANGE + 1))); int slowdown = getSlowdownFactor(); - for(ItemEntity item : items) { - if(item.age < 60 + slowdown || !item.isAlive() || item.getPersistentData().getBoolean(TAG_TELEPORTED)) + for (ItemEntity item : items) { + if (item.age < 60 + slowdown || !item.isAlive() || item.getPersistentData().getBoolean(TAG_TELEPORTED)) { continue; + } ItemStack stack = item.getItem(); - if(!stack.isEmpty()) { + if (!stack.isEmpty()) { Item sitem = stack.getItem(); - if(sitem instanceof IManaItem) + if (sitem instanceof IManaItem) { continue; + } int cost = stack.getCount() * COST; - if(getMana() >= cost) { + if (getMana() >= cost) { spawnExplosionParticles(item, 10); item.setPosition(bindPos.getX() + 0.5, bindPos.getY() + 1.5, bindPos.getZ() + 0.5); item.getPersistentData().putBoolean(TAG_TELEPORTED, true); @@ -89,8 +89,9 @@ public class SubTileSpectranthemum extends TileEntityFunctionalFlower { } } - if(did) + if (did) { sync(); + } } } @@ -100,7 +101,7 @@ public class SubTileSpectranthemum extends TileEntityFunctionalFlower { @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(getEffectivePos(), RANGE); + return new RadiusDescriptor.Square(getEffectivePos(), RANGE); } @Override @@ -118,7 +119,7 @@ public class SubTileSpectranthemum extends TileEntityFunctionalFlower { cmp.getInt(TAG_BIND_X), cmp.getInt(TAG_BIND_Y), cmp.getInt(TAG_BIND_Z) - ); + ); } @Override @@ -140,7 +141,7 @@ public class SubTileSpectranthemum extends TileEntityFunctionalFlower { public boolean bindTo(PlayerEntity player, ItemStack wand, BlockPos pos, Direction side) { boolean bound = super.bindTo(player, wand, pos, side); - if(!bound && !pos.equals(bindPos) && pos.distanceSq(getEffectivePos()) <= BIND_RANGE * BIND_RANGE && !pos.equals(getEffectivePos())) { + if (!bound && !pos.equals(bindPos) && pos.distanceSq(getEffectivePos()) <= BIND_RANGE * BIND_RANGE && !pos.equals(getEffectivePos())) { bindPos = pos; sync(); diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTangleberrie.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTangleberrie.java index 7d0494a95..054f85374 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTangleberrie.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTangleberrie.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 14, 2014, 11:40:59 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -15,6 +13,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityFunctionalFlower; import vazkii.botania.client.fx.SparkleParticleData; @@ -25,8 +24,7 @@ import vazkii.botania.common.lib.LibMisc; import java.util.List; public class SubTileTangleberrie extends TileEntityFunctionalFlower { - @ObjectHolder(LibMisc.MOD_ID + ":tangleberrie") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":tangleberrie") public static TileEntityType TYPE; public SubTileTangleberrie(TileEntityType type) { super(type); @@ -40,7 +38,7 @@ public class SubTileTangleberrie extends TileEntityFunctionalFlower { public void tickFlower() { super.tickFlower(); - if(getMana() > 0) { + if (getMana() > 0) { double x1 = getEffectivePos().getX() + 0.5; double y1 = getEffectivePos().getY() + 0.5; double z1 = getEffectivePos().getZ() + 0.5; @@ -52,9 +50,10 @@ public class SubTileTangleberrie extends TileEntityFunctionalFlower { List entities = getWorld().getEntitiesWithinAABB(LivingEntity.class, boundingBox); SparkleParticleData data = SparkleParticleData.sparkle(1F, 0.5F, 0.5F, 0.5F, 3); - for(LivingEntity entity : entities) { - if(entity instanceof PlayerEntity || !entity.isNonBoss()) + for (LivingEntity entity : entities) { + if (entity instanceof PlayerEntity || !entity.isNonBoss()) { continue; + } double x2 = entity.getX(); double y2 = entity.getY(); @@ -62,15 +61,15 @@ public class SubTileTangleberrie extends TileEntityFunctionalFlower { float distance = MathHelper.pointDistanceSpace(x1, y1, z1, x2, y2, z2); - if(distance > maxDist && distance < range) { + if (distance > maxDist && distance < range) { MathHelper.setEntityMotionFromVector(entity, new Vector3(x1, y1, z1), getMotionVelocity(entity)); - if(getWorld().rand.nextInt(3) == 0) { - world.addParticle(data, x2 + Math.random() * entity.getWidth(), y2 + Math.random() * entity.getHeight(), z2 + Math.random() * entity.getWidth(), 0, 0, 0); - } + if (getWorld().rand.nextInt(3) == 0) { + world.addParticle(data, x2 + Math.random() * entity.getWidth(), y2 + Math.random() * entity.getHeight(), z2 + Math.random() * entity.getWidth(), 0, 0, 0); + } } } - if(ticksExisted % 4 == 0) { + if (ticksExisted % 4 == 0) { addMana(-1); sync(); } @@ -91,7 +90,7 @@ public class SubTileTangleberrie extends TileEntityFunctionalFlower { @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Circle(getEffectivePos(), getRange()); + return new RadiusDescriptor.Circle(getEffectivePos(), getRange()); } @Override diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTigerseye.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTigerseye.java index 9267c6335..bdb414e57 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTigerseye.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTigerseye.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 16, 2014, 3:36:26 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -21,6 +19,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityFunctionalFlower; import vazkii.botania.common.lib.LibMisc; @@ -29,8 +28,7 @@ import java.util.ArrayList; import java.util.List; public class SubTileTigerseye extends TileEntityFunctionalFlower { - @ObjectHolder(LibMisc.MOD_ID + ":tigerseye") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":tigerseye") public static TileEntityType TYPE; private static final int RANGE = 10; private static final int RANGE_Y = 4; @@ -44,33 +42,37 @@ public class SubTileTigerseye extends TileEntityFunctionalFlower { public void tickFlower() { super.tickFlower(); - if(getWorld().isRemote) + if (getWorld().isRemote) { return; + } boolean shouldAfffect = getMana() >= COST; List entities = getWorld().getEntitiesWithinAABB(MobEntity.class, new AxisAlignedBB(getEffectivePos().add(-RANGE, -RANGE_Y, -RANGE), getEffectivePos().add(RANGE + 1, RANGE_Y + 1, RANGE + 1))); - for(MobEntity entity : entities) { + for (MobEntity entity : entities) { List entries = new ArrayList<>(entity.goalSelector.goals); entries.addAll(entity.targetSelector.goals); boolean avoidsOcelots = false; - if(shouldAfffect) - for(PrioritizedGoal entry : entries) { - if(entry.getGoal() instanceof AvoidEntityGoal) + if (shouldAfffect) { + for (PrioritizedGoal entry : entries) { + if (entry.getGoal() instanceof AvoidEntityGoal) { avoidsOcelots = messWithRunAwayAI((AvoidEntityGoal) entry.getGoal()) || avoidsOcelots; + } - if(entry.getGoal() instanceof NearestAttackableTargetGoal) + if (entry.getGoal() instanceof NearestAttackableTargetGoal) { messWithGetTargetAI((NearestAttackableTargetGoal) entry.getGoal()); + } } + } - if(entity instanceof CreeperEntity) { + if (entity instanceof CreeperEntity) { ((CreeperEntity) entity).timeSinceIgnited = 2; entity.setAttackTarget(null); } - if(avoidsOcelots) { + if (avoidsOcelots) { addMana(-COST); sync(); shouldAfffect = false; @@ -79,7 +81,7 @@ public class SubTileTigerseye extends TileEntityFunctionalFlower { } private boolean messWithRunAwayAI(AvoidEntityGoal aiEntry) { - if(aiEntry.classToAvoid == OcelotEntity.class) { + if (aiEntry.classToAvoid == OcelotEntity.class) { aiEntry.classToAvoid = PlayerEntity.class; return true; } @@ -87,13 +89,14 @@ public class SubTileTigerseye extends TileEntityFunctionalFlower { } private void messWithGetTargetAI(NearestAttackableTargetGoal aiEntry) { - if(aiEntry.targetClass == PlayerEntity.class) + if (aiEntry.targetClass == PlayerEntity.class) { aiEntry.targetClass = EnderCrystalEntity.class; // Something random that won't be around + } } @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(getEffectivePos(), RANGE); + return new RadiusDescriptor.Square(getEffectivePos(), RANGE); } @Override diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileVinculotus.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileVinculotus.java index 2dad23f51..b578a7aac 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileVinculotus.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileVinculotus.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 15, 2014, 4:30:08 PM (GMT)] */ package vazkii.botania.common.block.subtile.functional; @@ -17,6 +15,7 @@ import net.minecraftforge.event.entity.living.EnderTeleportEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityFunctionalFlower; import vazkii.botania.common.core.helper.MathHelper; @@ -30,8 +29,7 @@ import java.util.WeakHashMap; @Mod.EventBusSubscriber(modid = LibMisc.MOD_ID) public class SubTileVinculotus extends TileEntityFunctionalFlower { - @ObjectHolder(LibMisc.MOD_ID + ":vinculotus") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":vinculotus") public static TileEntityType TYPE; public static final Set existingFlowers = Collections.newSetFromMap(new WeakHashMap<>()); private static final int RANGE = 64; @@ -44,14 +42,14 @@ public class SubTileVinculotus extends TileEntityFunctionalFlower { public void tickFlower() { super.tickFlower(); - if(!getWorld().isRemote) { + if (!getWorld().isRemote) { existingFlowers.add(this); } } @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Circle(getEffectivePos(), RANGE); + return new RadiusDescriptor.Circle(getEffectivePos(), RANGE); } @Override @@ -73,26 +71,28 @@ public class SubTileVinculotus extends TileEntityFunctionalFlower { public static void onEndermanTeleport(EnderTeleportEvent event) { int cost = 50; - if(event.getEntityLiving() instanceof EndermanEntity) { + if (event.getEntityLiving() instanceof EndermanEntity) { List possibleFlowers = new ArrayList<>(); - for(SubTileVinculotus flower : existingFlowers) { + for (SubTileVinculotus flower : existingFlowers) { BlockPos activePos = flower.getEffectivePos(); - if(flower.redstoneSignal > 0 || flower.getMana() <= cost + if (flower.redstoneSignal > 0 || flower.getMana() <= cost || flower.getWorld() != event.getEntityLiving().world - || flower.getWorld().getTileEntity(flower.getPos()) != flower) + || flower.getWorld().getTileEntity(flower.getPos()) != flower) { continue; + } double x = activePos.getX() + 0.5; double y = activePos.getY() + 1.5; double z = activePos.getZ() + 0.5; - if(MathHelper.pointDistanceSpace(x, y, z, event.getTargetX(), event.getTargetY(), event.getTargetZ()) < RANGE) + if (MathHelper.pointDistanceSpace(x, y, z, event.getTargetX(), event.getTargetY(), event.getTargetZ()) < RANGE) { possibleFlowers.add(flower); + } } - if(!possibleFlowers.isEmpty()) { - SubTileVinculotus flower = possibleFlowers.get(event.getEntityLiving().world.rand.nextInt(possibleFlowers.size())); + if (!possibleFlowers.isEmpty()) { + SubTileVinculotus flower = possibleFlowers.get(event.getEntityLiving().world.rand.nextInt(possibleFlowers.size())); BlockPos activePos = flower.getEffectivePos(); double x = activePos.getX() + 0.5; diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileArcaneRose.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileArcaneRose.java index b62f5e216..4d22251ae 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileArcaneRose.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileArcaneRose.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 18, 2014, 8:45:25 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; @@ -15,6 +13,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityGeneratingFlower; import vazkii.botania.common.core.helper.ExperienceHelper; @@ -23,8 +22,7 @@ import vazkii.botania.common.lib.LibMisc; import java.util.List; public class SubTileArcaneRose extends TileEntityGeneratingFlower { - @ObjectHolder(LibMisc.MOD_ID + ":rosa_arcana") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":rosa_arcana") public static TileEntityType TYPE; private static final int RANGE = 1; @@ -36,19 +34,21 @@ public class SubTileArcaneRose extends TileEntityGeneratingFlower { public void tickFlower() { super.tickFlower(); - if(getMana() >= getMaxMana()) + if (getMana() >= getMaxMana()) { return; + } List players = getWorld().getEntitiesWithinAABB(PlayerEntity.class, new AxisAlignedBB(getEffectivePos().add(-RANGE, -RANGE, -RANGE), getEffectivePos().add(RANGE + 1, RANGE + 1, RANGE + 1))); - for(PlayerEntity player : players) - if(ExperienceHelper.getPlayerXP(player) >= 1 && player.onGround) { + for (PlayerEntity player : players) { + if (ExperienceHelper.getPlayerXP(player) >= 1 && player.onGround) { ExperienceHelper.drainPlayerXP(player, 1); addMana(50); return; } + } List orbs = getWorld().getEntitiesWithinAABB(ExperienceOrbEntity.class, new AxisAlignedBB(getEffectivePos().add(-RANGE, -RANGE, -RANGE), getEffectivePos().add(RANGE + 1, RANGE + 1, RANGE + 1))); - for(ExperienceOrbEntity orb : orbs) { + for (ExperienceOrbEntity orb : orbs) { if (orb.isAlive()) { addMana(orb.getXpValue() * 35); orb.remove(); @@ -60,7 +60,7 @@ public class SubTileArcaneRose extends TileEntityGeneratingFlower { @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(getEffectivePos(), RANGE); + return new RadiusDescriptor.Square(getEffectivePos(), RANGE); } @Override diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileDandelifeon.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileDandelifeon.java index 171d3701b..df976e825 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileDandelifeon.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileDandelifeon.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 6, 2015, 3:46:10 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; @@ -17,6 +15,7 @@ import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityGeneratingFlower; import vazkii.botania.common.block.ModBlocks; @@ -27,8 +26,7 @@ import java.util.ArrayList; import java.util.List; public class SubTileDandelifeon extends TileEntityGeneratingFlower { - @ObjectHolder(LibMisc.MOD_ID + ":dandelifeon") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":dandelifeon") public static TileEntityType TYPE; private static final int RANGE = 12; private static final int SPEED = 10; @@ -37,14 +35,14 @@ public class SubTileDandelifeon extends TileEntityGeneratingFlower { private static final int MANA_PER_GEN = 60; private static final int[][] ADJACENT_BLOCKS = new int[][] { - { -1, -1 }, - { -1, +0 }, - { -1, +1 }, - { +0, +1 }, - { +1, +1 }, - { +1, +0 }, - { +1, -1 }, - { +0, -1 } + { -1, -1 }, + { -1, +0 }, + { -1, +1 }, + { +0, +1 }, + { +1, +1 }, + { +1, +0 }, + { +1, -1 }, + { +0, -1 } }; public SubTileDandelifeon() { @@ -55,8 +53,9 @@ public class SubTileDandelifeon extends TileEntityGeneratingFlower { public void tickFlower() { super.tickFlower(); - if(!getWorld().isRemote && redstoneSignal > 0 && ticksExisted % SPEED == 0) + if (!getWorld().isRemote && redstoneSignal > 0 && ticksExisted % SPEED == 0) { runSimulation(); + } } private void runSimulation() { @@ -64,43 +63,47 @@ public class SubTileDandelifeon extends TileEntityGeneratingFlower { List changes = new ArrayList<>(); boolean wipe = false; - for(int i = 0; i < table.length; i++) - for(int j = 0; j < table[0].length; j++) { + for (int i = 0; i < table.length; i++) { + for (int j = 0; j < table[0].length; j++) { int gen = table[i][j]; int adj = getAdjCells(table, i, j); int newVal = gen; - if(adj < 2 || adj > 3) + if (adj < 2 || adj > 3) { newVal = -1; - else { - if(adj == 3 && gen == -1) + } else { + if (adj == 3 && gen == -1) { newVal = getSpawnCellGeneration(table, i, j); - else if(gen > -1) + } else if (gen > -1) { newVal = gen + 1; + } } int xdist = Math.abs(i - RANGE); int zdist = Math.abs(j - RANGE); int allowDist = 1; - if(xdist <= allowDist && zdist <= allowDist && newVal > -1) { + if (xdist <= allowDist && zdist <= allowDist && newVal > -1) { gen = newVal; newVal = gen == 1 ? -1 : -2; } - if(newVal != gen) { + if (newVal != gen) { changes.add(new int[] { i, j, newVal, gen }); - if(newVal == -2) + if (newVal == -2) { wipe = true; + } } } + } BlockPos pos = getEffectivePos(); - for(int[] change : changes) { + for (int[] change : changes) { BlockPos pos_ = pos.add(-RANGE + change[0], 0, -RANGE + change[1]); int val = change[2]; - if(val != -2 && wipe) + if (val != -2 && wipe) { val = -1; + } int old = change[3]; @@ -114,32 +117,35 @@ public class SubTileDandelifeon extends TileEntityGeneratingFlower { BlockPos pos = getEffectivePos(); - for(int i = 0; i < diam; i++) - for(int j = 0; j < diam; j++) { + for (int i = 0; i < diam; i++) { + for (int j = 0; j < diam; j++) { BlockPos pos_ = pos.add(-RANGE + i, 0, -RANGE + j); table[i][j] = getCellGeneration(pos_); } + } return table; } private int getCellGeneration(BlockPos pos) { TileEntity tile = getWorld().getTileEntity(pos); - if(tile instanceof TileCell) + if (tile instanceof TileCell) { return ((TileCell) tile).isSameFlower(this) ? ((TileCell) tile).getGeneration() : 0; + } - return -1; + return -1; } private int getAdjCells(int[][] table, int x, int z) { int count = 0; - for(int[] shift : ADJACENT_BLOCKS) { + for (int[] shift : ADJACENT_BLOCKS) { int xp = x + shift[0]; int zp = z + shift[1]; - if(!isOffBounds(table, xp, zp)) { + if (!isOffBounds(table, xp, zp)) { int gen = table[xp][zp]; - if(gen >= 0) + if (gen >= 0) { count++; + } } } @@ -148,13 +154,14 @@ public class SubTileDandelifeon extends TileEntityGeneratingFlower { private int getSpawnCellGeneration(int[][] table, int x, int z) { int max = -1; - for(int[] shift : ADJACENT_BLOCKS) { + for (int[] shift : ADJACENT_BLOCKS) { int xp = x + shift[0]; int zp = z + shift[1]; - if(!isOffBounds(table, xp, zp)) { + if (!isOffBounds(table, xp, zp)) { int gen = table[xp][zp]; - if(gen > max) + if (gen > max) { max = gen; + } } } @@ -170,14 +177,16 @@ public class SubTileDandelifeon extends TileEntityGeneratingFlower { BlockState stateAt = world.getBlockState(pos); Block blockAt = stateAt.getBlock(); TileEntity tile = world.getTileEntity(pos); - if(gen == -2) { + if (gen == -2) { int val = Math.min(MAX_MANA_GENERATIONS, prevGen) * MANA_PER_GEN; addMana(val); - } else if(blockAt == ModBlocks.cellBlock) { - if(gen < 0) + } else if (blockAt == ModBlocks.cellBlock) { + if (gen < 0) { world.removeBlock(pos, false); - else ((TileCell) tile).setGeneration(this, gen); - } else if(gen >= 0 && stateAt.isAir(getWorld(), pos)) { + } else { + ((TileCell) tile).setGeneration(this, gen); + } + } else if (gen >= 0 && stateAt.isAir(getWorld(), pos)) { world.setBlockState(pos, ModBlocks.cellBlock.getDefaultState()); tile = world.getTileEntity(pos); ((TileCell) tile).setGeneration(this, gen); @@ -191,7 +200,7 @@ public class SubTileDandelifeon extends TileEntityGeneratingFlower { @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(getEffectivePos(), RANGE); + return new RadiusDescriptor.Square(getEffectivePos(), RANGE); } @Override diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEndoflame.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEndoflame.java index 764dce1c8..1864dc8ab 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEndoflame.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEndoflame.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 15, 2014, 9:47:56 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; @@ -22,6 +20,7 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.Vec3d; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityGeneratingFlower; import vazkii.botania.common.block.mana.BlockSpreader; @@ -29,8 +28,7 @@ import vazkii.botania.common.core.handler.ModSounds; import vazkii.botania.common.lib.LibMisc; public class SubTileEndoflame extends TileEntityGeneratingFlower { - @ObjectHolder(LibMisc.MOD_ID + ":endoflame") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":endoflame") public static TileEntityType TYPE; private static final String TAG_BURN_TIME = "burnTime"; private static final int FUEL_CAP = 32000; @@ -47,30 +45,32 @@ public class SubTileEndoflame extends TileEntityGeneratingFlower { public void tickFlower() { super.tickFlower(); - if(burnTime > 0) + if (burnTime > 0) { burnTime--; + } - if(getWorld().isRemote) { - if(burnTime > 0 && getWorld().rand.nextInt(10) == 0) { + if (getWorld().isRemote) { + if (burnTime > 0 && getWorld().rand.nextInt(10) == 0) { Vec3d offset = getWorld().getBlockState(getEffectivePos()).getOffset(getWorld(), getEffectivePos()).add(0.4, 0.7, 0.4); getWorld().addParticle(ParticleTypes.FLAME, getEffectivePos().getX() + offset.x + Math.random() * 0.2, getEffectivePos().getY() + offset.y, getEffectivePos().getZ() + offset.z + Math.random() * 0.2, 0.0D, 0.0D, 0.0D); } return; } - if(linkedCollector != null) { - if(burnTime == 0) { - if(getMana() < getMaxMana()) { + if (linkedCollector != null) { + if (burnTime == 0) { + if (getMana() < getMaxMana()) { int slowdown = getSlowdownFactor(); - for(ItemEntity item : getWorld().getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(getEffectivePos().add(-RANGE, -RANGE, -RANGE), getEffectivePos().add(RANGE + 1, RANGE + 1, RANGE + 1)))) { - if(item.age >= 59 + slowdown && !item.removed) { + for (ItemEntity item : getWorld().getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(getEffectivePos().add(-RANGE, -RANGE, -RANGE), getEffectivePos().add(RANGE + 1, RANGE + 1, RANGE + 1)))) { + if (item.age >= 59 + slowdown && !item.removed) { ItemStack stack = item.getItem(); - if(stack.isEmpty() || stack.getItem().hasContainerItem(stack)) + if (stack.isEmpty() || stack.getItem().hasContainerItem(stack)) { continue; + } int burnTime = getBurnTime(stack); - if(burnTime > 0 && stack.getCount() > 0) { + if (burnTime > 0 && stack.getCount() > 0) { this.burnTime = Math.min(FUEL_CAP, burnTime) / 2; stack.shrink(1); @@ -89,9 +89,9 @@ public class SubTileEndoflame extends TileEntityGeneratingFlower { @Override public boolean receiveClientEvent(int event, int param) { - if(event == START_BURN_EVENT) { + if (event == START_BURN_EVENT) { Entity e = getWorld().getEntityByID(param); - if(e != null) { + if (e != null) { e.world.addParticle(ParticleTypes.LARGE_SMOKE, e.getX(), e.getY() + 0.1, e.getZ(), 0.0D, 0.0D, 0.0D); e.world.addParticle(ParticleTypes.FLAME, e.getX(), e.getY(), e.getZ(), 0.0D, 0.0D, 0.0D); } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEntropinnyum.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEntropinnyum.java index 76f2b924d..5a857d96a 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEntropinnyum.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEntropinnyum.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 7, 2014, 10:59:44 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; @@ -19,6 +17,7 @@ import net.minecraft.util.SoundEvents; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityGeneratingFlower; import vazkii.botania.client.fx.SparkleParticleData; @@ -27,8 +26,7 @@ import vazkii.botania.common.lib.LibMisc; import java.util.List; public class SubTileEntropinnyum extends TileEntityGeneratingFlower { - @ObjectHolder(LibMisc.MOD_ID + ":entropinnyum") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":entropinnyum") public static TileEntityType TYPE; private static final int RANGE = 12; private static final int EXPLODE_EFFECT_EVENT = 0; @@ -41,11 +39,11 @@ public class SubTileEntropinnyum extends TileEntityGeneratingFlower { public void tickFlower() { super.tickFlower(); - if(!getWorld().isRemote && getMana() == 0) { + if (!getWorld().isRemote && getMana() == 0) { List tnts = getWorld().getEntitiesWithinAABB(TNTEntity.class, new AxisAlignedBB(getEffectivePos().add(-RANGE, -RANGE, -RANGE), getEffectivePos().add(RANGE + 1, RANGE + 1, RANGE + 1))); - for(TNTEntity tnt : tnts) { + for (TNTEntity tnt : tnts) { IFluidState fluid = getWorld().getFluidState(new BlockPos(tnt)); - if(tnt.getFuse() == 1 && tnt.isAlive() && fluid.isEmpty()) { + if (tnt.getFuse() == 1 && tnt.isAlive() && fluid.isEmpty()) { tnt.playSound(SoundEvents.ENTITY_GENERIC_EXPLODE, 0.2F, (1F + (getWorld().rand.nextFloat() - getWorld().rand.nextFloat()) * 0.2F) * 0.7F); tnt.remove(); addMana(getMaxMana()); @@ -60,14 +58,14 @@ public class SubTileEntropinnyum extends TileEntityGeneratingFlower { @Override public boolean receiveClientEvent(int event, int param) { - if(event == EXPLODE_EFFECT_EVENT) { - if(getWorld().isRemote && getWorld().getEntityByID(param) instanceof TNTEntity) { + if (event == EXPLODE_EFFECT_EVENT) { + if (getWorld().isRemote && getWorld().getEntityByID(param) instanceof TNTEntity) { Entity e = getWorld().getEntityByID(param); - for(int i = 0; i < 50; i++) { - SparkleParticleData data = SparkleParticleData.sparkle((float) (Math.random() * 0.65F + 1.25F), 1F, (float) Math.random() * 0.25F, (float) Math.random() * 0.25F, 12); - world.addParticle(data, e.getX() + Math.random() * 4 - 2, e.getY() + Math.random() * 4 - 2, e.getZ() + Math.random() * 4 - 2, 0, 0, 0); - } + for (int i = 0; i < 50; i++) { + SparkleParticleData data = SparkleParticleData.sparkle((float) (Math.random() * 0.65F + 1.25F), 1F, (float) Math.random() * 0.25F, (float) Math.random() * 0.25F, 12); + world.addParticle(data, e.getX() + Math.random() * 4 - 2, e.getY() + Math.random() * 4 - 2, e.getZ() + Math.random() * 4 - 2, 0, 0, 0); + } getWorld().addParticle(ParticleTypes.EXPLOSION_EMITTER, e.getX(), e.getY(), e.getZ(), 1D, 0D, 0D); } @@ -89,7 +87,7 @@ public class SubTileEntropinnyum extends TileEntityGeneratingFlower { @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(getEffectivePos(), RANGE); + return new RadiusDescriptor.Square(getEffectivePos(), RANGE); } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileGourmaryllis.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileGourmaryllis.java index 972f65bd5..1eca8a8ec 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileGourmaryllis.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileGourmaryllis.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 26, 2014, 1:42:17 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; @@ -23,6 +21,7 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityGeneratingFlower; import vazkii.botania.common.lib.LibMisc; @@ -30,8 +29,7 @@ import vazkii.botania.common.lib.LibMisc; import java.util.List; public class SubTileGourmaryllis extends TileEntityGeneratingFlower { - @ObjectHolder(LibMisc.MOD_ID + ":gourmaryllis") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":gourmaryllis") public static TileEntityType TYPE; private static final String TAG_COOLDOWN = "cooldown"; private static final String TAG_DIGESTING_MANA = "digestingMana"; @@ -52,27 +50,29 @@ public class SubTileGourmaryllis extends TileEntityGeneratingFlower { public void tickFlower() { super.tickFlower(); - if (getWorld().isRemote) + if (getWorld().isRemote) { return; - - if(cooldown > -1) + } + + if (cooldown > -1) { cooldown--; - if(digestingMana != 0) { + } + if (digestingMana != 0) { int munchInterval = 2 + (2 * lastFoodCount); - - if(cooldown == 0) { + + if (cooldown == 0) { addMana(digestingMana); digestingMana = 0; - + float burpPitch = 1 - (lastFoodCount - 1) * 0.05F; getWorld().playSound(null, getEffectivePos(), SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.BLOCKS, 1, burpPitch); sync(); - } else if(cooldown % munchInterval == 0) { + } else if (cooldown % munchInterval == 0) { getWorld().playSound(null, getEffectivePos(), SoundEvents.ENTITY_GENERIC_EAT, SoundCategory.BLOCKS, 0.5f, 1); - + Vec3d offset = getWorld().getBlockState(getEffectivePos()).getOffset(getWorld(), getEffectivePos()).add(0.4, 0.6, 0.4); - - ((ServerWorld) getWorld()).spawnParticle(new ItemParticleData(ParticleTypes.ITEM, lastFood), getEffectivePos().getX()+offset.x, getEffectivePos().getY()+offset.y, getEffectivePos().getZ()+offset.z, 10, 0.1D, 0.1D, 0.1D, 0.03D); + + ((ServerWorld) getWorld()).spawnParticle(new ItemParticleData(ParticleTypes.ITEM, lastFood), getEffectivePos().getX() + offset.x, getEffectivePos().getY() + offset.y, getEffectivePos().getZ() + offset.z, 10, 0.1D, 0.1D, 0.1D, 0.03D); } } @@ -80,12 +80,12 @@ public class SubTileGourmaryllis extends TileEntityGeneratingFlower { List items = getWorld().getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(getEffectivePos().add(-RANGE, -RANGE, -RANGE), getEffectivePos().add(RANGE + 1, RANGE + 1, RANGE + 1))); - for(ItemEntity item : items) { + for (ItemEntity item : items) { ItemStack stack = item.getItem(); - if(!stack.isEmpty() && stack.getItem().isFood() && !item.removed && item.age >= slowdown) { - if(cooldown <= 0) { - if(ItemHandlerHelper.canItemStacksStack(lastFood, stack)) { + if (!stack.isEmpty() && stack.getItem().isFood() && !item.removed && item.age >= slowdown) { + if (cooldown <= 0) { + if (ItemHandlerHelper.canItemStacksStack(lastFood, stack)) { lastFoodCount++; } else { lastFood = stack.copy(); @@ -127,7 +127,7 @@ public class SubTileGourmaryllis extends TileEntityGeneratingFlower { @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(getEffectivePos(), RANGE); + return new RadiusDescriptor.Square(getEffectivePos(), RANGE); } @Override diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileHydroangeas.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileHydroangeas.java index df84e92bf..f6ac01c12 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileHydroangeas.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileHydroangeas.java @@ -1,22 +1,17 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [? (GMT)] */ package vazkii.botania.common.block.subtile.generating; import net.minecraft.block.Block; -import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; -import net.minecraft.entity.LivingEntity; import net.minecraft.fluid.Fluid; import net.minecraft.fluid.IFluidState; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tags.FluidTags; import net.minecraft.tags.Tag; @@ -25,13 +20,12 @@ import net.minecraft.util.Direction; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; import net.minecraft.world.biome.Biome; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityGeneratingFlower; import vazkii.botania.client.fx.WispParticleData; -import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.lib.LibMisc; import java.util.Arrays; @@ -39,8 +33,7 @@ import java.util.Collections; import java.util.List; public class SubTileHydroangeas extends TileEntityGeneratingFlower { - @ObjectHolder(LibMisc.MOD_ID + ":hydroangeas") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":hydroangeas") public static TileEntityType TYPE; private static final String TAG_BURN_TIME = "burnTime"; public static final String TAG_COOLDOWN = "cooldown"; @@ -61,43 +54,48 @@ public class SubTileHydroangeas extends TileEntityGeneratingFlower { public void tickFlower() { super.tickFlower(); - if(cooldown > 0) { + if (cooldown > 0) { cooldown--; - for(int i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { WispParticleData data = WispParticleData.wisp((float) Math.random() / 6, 0.1F, 0.1F, 0.1F, 1); world.addParticle(data, getEffectivePos().getX() + 0.5 + Math.random() * 0.2 - 0.1, getEffectivePos().getY() + 0.5 + Math.random() * 0.2 - 0.1, getEffectivePos().getZ() + 0.5 + Math.random() * 0.2 - 0.1, 0, (float) Math.random() / 30, 0); } } - if(burnTime == 0) { - if(getMana() < getMaxMana() && !getWorld().isRemote) { + if (burnTime == 0) { + if (getMana() < getMaxMana() && !getWorld().isRemote) { List offsets = Arrays.asList(OFFSETS); Collections.shuffle(offsets); - for(BlockPos offset : offsets) { + for (BlockPos offset : offsets) { BlockPos pos = getEffectivePos().add(offset); IFluidState fstate = getWorld().getFluidState(pos); Tag search = getMaterialToSearchFor(); - if(fstate.isTagged(search) + if (fstate.isTagged(search) && (getBlockToSearchBelow() == null - || getWorld().getBlockState(pos.down()).getBlock() == getBlockToSearchBelow()) + || getWorld().getBlockState(pos.down()).getBlock() == getBlockToSearchBelow()) && fstate.isSource()) { - if(search != FluidTags.WATER) + if (search != FluidTags.WATER) { getWorld().setBlockState(pos, Blocks.AIR.getDefaultState()); - else { + } else { int waterAround = 0; - for(Direction dir : Direction.values()) - if(getWorld().getFluidState(pos.offset(dir)).isTagged(search)) + for (Direction dir : Direction.values()) { + if (getWorld().getFluidState(pos.offset(dir)).isTagged(search)) { waterAround++; + } + } - if(waterAround < 2) + if (waterAround < 2) { getWorld().setBlockState(pos, Blocks.AIR.getDefaultState()); + } } - if(cooldown == 0) + if (cooldown == 0) { burnTime += getBurnTime(); - else cooldown = getCooldown(); + } else { + cooldown = getCooldown(); + } sync(); playSound(); @@ -106,10 +104,11 @@ public class SubTileHydroangeas extends TileEntityGeneratingFlower { } } } else { - if(getWorld().rand.nextInt(8) == 0) + if (getWorld().rand.nextInt(8) == 0) { doBurnParticles(); + } burnTime--; - if(burnTime == 0) { + if (burnTime == 0) { cooldown = getCooldown(); sync(); } @@ -117,9 +116,9 @@ public class SubTileHydroangeas extends TileEntityGeneratingFlower { } public void doBurnParticles() { - WispParticleData data = WispParticleData.wisp((float) Math.random() / 6, 0.05F, 0.05F, 0.7F, 1); - world.addParticle(data, getEffectivePos().getX() + 0.55 + Math.random() * 0.2 - 0.1, getEffectivePos().getY() + 0.55 + Math.random() * 0.2 - 0.1, getEffectivePos().getZ() + 0.5, 0, (float) Math.random() / 60, 0); - } + WispParticleData data = WispParticleData.wisp((float) Math.random() / 6, 0.05F, 0.05F, 0.7F, 1); + world.addParticle(data, getEffectivePos().getX() + 0.55 + Math.random() * 0.2 - 0.1, getEffectivePos().getY() + 0.55 + Math.random() * 0.2 - 0.1, getEffectivePos().getZ() + 0.5, 0, (float) Math.random() / 60, 0); + } public Tag getMaterialToSearchFor() { return FluidTags.WATER; @@ -139,7 +138,7 @@ public class SubTileHydroangeas extends TileEntityGeneratingFlower { @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(getEffectivePos(), 1); + return new RadiusDescriptor.Square(getEffectivePos(), 1); } @Override @@ -181,7 +180,7 @@ public class SubTileHydroangeas extends TileEntityGeneratingFlower { public int getCooldown() { return 0; } - + @Override public boolean isPassiveFlower() { return true; diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileKekimurus.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileKekimurus.java index 327fb504b..1504093fc 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileKekimurus.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileKekimurus.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 8, 2014, 6:26:37 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; @@ -18,13 +16,13 @@ import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; import net.minecraft.util.math.BlockPos; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityGeneratingFlower; import vazkii.botania.common.lib.LibMisc; public class SubTileKekimurus extends TileEntityGeneratingFlower { - @ObjectHolder(LibMisc.MOD_ID + ":kekimurus") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":kekimurus") public static TileEntityType TYPE; private static final int RANGE = 5; @@ -36,23 +34,26 @@ public class SubTileKekimurus extends TileEntityGeneratingFlower { public void tickFlower() { super.tickFlower(); - if (getWorld().isRemote) + if (getWorld().isRemote) { return; + } int mana = 1800; - if(getMaxMana() - this.getMana() >= mana && !getWorld().isRemote && ticksExisted % 80 == 0) { - for(int i = 0; i < RANGE * 2 + 1; i++) - for(int j = 0; j < RANGE * 2 + 1; j++) - for(int k = 0; k < RANGE * 2 + 1; k++) { + if (getMaxMana() - this.getMana() >= mana && !getWorld().isRemote && ticksExisted % 80 == 0) { + for (int i = 0; i < RANGE * 2 + 1; i++) { + for (int j = 0; j < RANGE * 2 + 1; j++) { + for (int k = 0; k < RANGE * 2 + 1; k++) { BlockPos pos = getEffectivePos().add(i - RANGE, j - RANGE, k - RANGE); BlockState state = getWorld().getBlockState(pos); Block block = state.getBlock(); - if(block instanceof CakeBlock) { + if (block instanceof CakeBlock) { int nextSlicesEaten = state.get(CakeBlock.BITES) + 1; - if(nextSlicesEaten > 6) + if (nextSlicesEaten > 6) { getWorld().removeBlock(pos, false); - else getWorld().setBlockState(pos, state.with(CakeBlock.BITES, nextSlicesEaten)); + } else { + getWorld().setBlockState(pos, state.with(CakeBlock.BITES, nextSlicesEaten)); + } getWorld().playEvent(2001, pos, Block.getStateId(state)); getWorld().playSound(null, getEffectivePos(), SoundEvents.ENTITY_GENERIC_EAT, SoundCategory.BLOCKS, 1F, 0.5F + (float) Math.random() * 0.5F); @@ -61,12 +62,14 @@ public class SubTileKekimurus extends TileEntityGeneratingFlower { return; } } + } + } } } @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(getEffectivePos(), RANGE); + return new RadiusDescriptor.Square(getEffectivePos(), RANGE); } @Override diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileMunchdew.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileMunchdew.java index e47fc1558..681b4b3d3 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileMunchdew.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileMunchdew.java @@ -1,31 +1,25 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 15, 2014, 7:25:47 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tags.BlockTags; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.storage.loot.LootContext; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityGeneratingFlower; import vazkii.botania.common.core.handler.ConfigHandler; -import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.lib.LibMisc; import java.util.ArrayList; @@ -33,8 +27,7 @@ import java.util.Collections; import java.util.List; public class SubTileMunchdew extends TileEntityGeneratingFlower { - @ObjectHolder(LibMisc.MOD_ID + ":munchdew") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":munchdew") public static TileEntityType TYPE; public static final String TAG_COOLDOWN = "cooldown"; private static final String TAG_ATE_ONCE = "ateOnce"; @@ -54,10 +47,11 @@ public class SubTileMunchdew extends TileEntityGeneratingFlower { public void tickFlower() { super.tickFlower(); - if(getWorld().isRemote) + if (getWorld().isRemote) { return; + } - if(cooldown > 0) { + if (cooldown > 0) { cooldown--; ticksWithoutEating = 0; ateOnce = false; // don't start ticking ticksWithoutEating again until we eat again @@ -65,17 +59,16 @@ public class SubTileMunchdew extends TileEntityGeneratingFlower { } int manaPerLeaf = 160; - eatLeaves : { - if(getMaxMana() - getMana() >= manaPerLeaf && ticksExisted % 4 == 0) { + eatLeaves: { + if (getMaxMana() - getMana() >= manaPerLeaf && ticksExisted % 4 == 0) { List coords = new ArrayList<>(); BlockPos pos = getEffectivePos(); - nextCoord: - for(BlockPos pos_ : BlockPos.getAllInBoxMutable(pos.add(-RANGE, 0, -RANGE), + nextCoord: for (BlockPos pos_ : BlockPos.getAllInBoxMutable(pos.add(-RANGE, 0, -RANGE), pos.add(RANGE, RANGE_Y, RANGE))) { - if(getWorld().getBlockState(pos_).getBlock().isIn(BlockTags.LEAVES)) { - for(Direction dir : Direction.values()) { - if(getWorld().isAirBlock(pos_.offset(dir))) { + if (getWorld().getBlockState(pos_).getBlock().isIn(BlockTags.LEAVES)) { + for (Direction dir : Direction.values()) { + if (getWorld().isAirBlock(pos_.offset(dir))) { coords.add(pos_.toImmutable()); break nextCoord; } @@ -83,8 +76,9 @@ public class SubTileMunchdew extends TileEntityGeneratingFlower { } } - if(coords.isEmpty()) + if (coords.isEmpty()) { break eatLeaves; + } Collections.shuffle(coords); BlockPos breakCoords = coords.get(0); @@ -92,15 +86,16 @@ public class SubTileMunchdew extends TileEntityGeneratingFlower { getWorld().removeBlock(breakCoords, false); ticksWithoutEating = 0; ateOnce = true; - if(ConfigHandler.COMMON.blockBreakParticles.get()) + if (ConfigHandler.COMMON.blockBreakParticles.get()) { getWorld().playEvent(2001, breakCoords, Block.getStateId(state)); + } addMana(manaPerLeaf); } } - if(ateOnce) { + if (ateOnce) { ticksWithoutEating++; - if(ticksWithoutEating >= 5) { + if (ticksWithoutEating >= 5) { cooldown = 1600; sync(); } @@ -109,7 +104,7 @@ public class SubTileMunchdew extends TileEntityGeneratingFlower { @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(getEffectivePos(), RANGE); + return new RadiusDescriptor.Square(getEffectivePos(), RANGE); } @Override diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileNarslimmus.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileNarslimmus.java index 80a593506..25fe6c23f 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileNarslimmus.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileNarslimmus.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 29, 2015, 10:43:54 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; @@ -26,6 +24,7 @@ import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityGeneratingFlower; import vazkii.botania.common.lib.LibMisc; @@ -34,8 +33,7 @@ import java.util.List; @Mod.EventBusSubscriber(modid = LibMisc.MOD_ID) public class SubTileNarslimmus extends TileEntityGeneratingFlower { - @ObjectHolder(LibMisc.MOD_ID + ":narslimmus") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":narslimmus") public static TileEntityType TYPE; public static final String TAG_WORLD_SPAWNED = "botania:world_spawned"; @@ -49,14 +47,14 @@ public class SubTileNarslimmus extends TileEntityGeneratingFlower { public void tickFlower() { super.tickFlower(); - if(ticksExisted % 5 == 0) { + if (ticksExisted % 5 == 0) { List slimes = getWorld().getEntitiesWithinAABB(SlimeEntity.class, new AxisAlignedBB(getEffectivePos().add(-RANGE, -RANGE, -RANGE), getEffectivePos().add(RANGE + 1, RANGE + 1, RANGE + 1))); - for(SlimeEntity slime : slimes) { - if(slime.getPersistentData().getBoolean(TAG_WORLD_SPAWNED) && slime.isAlive()) { + for (SlimeEntity slime : slimes) { + if (slime.getPersistentData().getBoolean(TAG_WORLD_SPAWNED) && slime.isAlive()) { int size = slime.getSlimeSize(); int mul = (int) Math.pow(2, size); int mana = 1200 * mul; - if(!slime.world.isRemote) { + if (!slime.world.isRemote) { slime.remove(); slime.playSound(size > 1 ? SoundEvents.ENTITY_SLIME_SQUISH : SoundEvents.ENTITY_SLIME_SQUISH_SMALL, 1, 0.02F); addMana(mana); @@ -64,7 +62,7 @@ public class SubTileNarslimmus extends TileEntityGeneratingFlower { } for (int j = 0; j < mul * 8; ++j) { - float f = slime.world.rand.nextFloat() * (float)Math.PI * 2.0F; + float f = slime.world.rand.nextFloat() * (float) Math.PI * 2.0F; float f1 = slime.world.rand.nextFloat() * 0.5F + 0.5F; float f2 = MathHelper.sin(f) * size * 0.5F * f1; float f3 = MathHelper.cos(f) * size * 0.5F * f1; @@ -79,7 +77,7 @@ public class SubTileNarslimmus extends TileEntityGeneratingFlower { @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(getEffectivePos(), RANGE); + return new RadiusDescriptor.Square(getEffectivePos(), RANGE); } @Override @@ -94,11 +92,12 @@ public class SubTileNarslimmus extends TileEntityGeneratingFlower { @SubscribeEvent public static void onSpawn(LivingSpawnEvent.CheckSpawn event) { - if(event.getEntityLiving() instanceof SlimeEntity + if (event.getEntityLiving() instanceof SlimeEntity && event.getSpawnReason() == SpawnReason.NATURAL && event.getResult() != Event.Result.DENY - && isSlimeChunk(event.getEntityLiving().world, event.getX(), event.getZ())) + && isSlimeChunk(event.getEntityLiving().world, event.getX(), event.getZ())) { event.getEntityLiving().getPersistentData().putBoolean(TAG_WORLD_SPAWNED, true); + } } private static boolean isSlimeChunk(World world, double x, double z) { diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileRafflowsia.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileRafflowsia.java index da3114361..cdcb4a03c 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileRafflowsia.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileRafflowsia.java @@ -1,45 +1,37 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Oct 11, 2015, 5:05:05 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityGeneratingFlower; import vazkii.botania.common.block.ModSubtiles; -import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.lib.LibMisc; import vazkii.botania.common.lib.ModTags; import javax.annotation.Nullable; -import java.util.List; public class SubTileRafflowsia extends TileEntityGeneratingFlower { - @ObjectHolder(LibMisc.MOD_ID + ":rafflowsia") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":rafflowsia") public static TileEntityType TYPE; public static final String TAG_LAST_FLOWER = "lastFlower"; public static final String TAG_LAST_FLOWER_TIMES = "lastFlowerTimes"; - @Nullable - private Block lastFlower; + @Nullable private Block lastFlower; private int lastFlowerTimes; private static final int RANGE = 5; @@ -54,17 +46,17 @@ public class SubTileRafflowsia extends TileEntityGeneratingFlower { int mana = 2100; - if(getMaxMana() - this.getMana() >= mana && !getWorld().isRemote && ticksExisted % 40 == 0) { - for(int i = 0; i < RANGE * 2 + 1; i++) - for(int j = 0; j < RANGE * 2 + 1; j++) - for(int k = 0; k < RANGE * 2 + 1; k++) { + if (getMaxMana() - this.getMana() >= mana && !getWorld().isRemote && ticksExisted % 40 == 0) { + for (int i = 0; i < RANGE * 2 + 1; i++) { + for (int j = 0; j < RANGE * 2 + 1; j++) { + for (int k = 0; k < RANGE * 2 + 1; k++) { BlockPos pos = getEffectivePos().add(i - RANGE, j - RANGE, k - RANGE); BlockState state = getWorld().getBlockState(pos); - if(state.isIn(ModTags.Blocks.SPECIAL_FLOWERS) && state.getBlock() != ModSubtiles.rafflowsia) { - if(state.getBlock() == lastFlower) + if (state.isIn(ModTags.Blocks.SPECIAL_FLOWERS) && state.getBlock() != ModSubtiles.rafflowsia) { + if (state.getBlock() == lastFlower) { lastFlowerTimes++; - else { + } else { lastFlower = state.getBlock(); lastFlowerTimes = 1; } @@ -77,6 +69,8 @@ public class SubTileRafflowsia extends TileEntityGeneratingFlower { return; } } + } + } } } @@ -84,8 +78,9 @@ public class SubTileRafflowsia extends TileEntityGeneratingFlower { public void writeToPacketNBT(CompoundNBT cmp) { super.writeToPacketNBT(cmp); - if(lastFlower != null) + if (lastFlower != null) { cmp.putString(TAG_LAST_FLOWER, lastFlower.getRegistryName().toString()); + } cmp.putInt(TAG_LAST_FLOWER_TIMES, lastFlowerTimes); } @@ -94,14 +89,15 @@ public class SubTileRafflowsia extends TileEntityGeneratingFlower { super.readFromPacketNBT(cmp); ResourceLocation id = ResourceLocation.tryCreate(cmp.getString(TAG_LAST_FLOWER)); - if(id != null) + if (id != null) { lastFlower = ForgeRegistries.BLOCKS.getValue(id); + } lastFlowerTimes = cmp.getInt(TAG_LAST_FLOWER_TIMES); } @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(getEffectivePos(), RANGE); + return new RadiusDescriptor.Square(getEffectivePos(), RANGE); } @Override diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileShulkMeNot.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileShulkMeNot.java index 56b650bf3..5b0c68b3f 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileShulkMeNot.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileShulkMeNot.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.common.block.subtile.generating; import net.minecraft.entity.Entity; @@ -15,6 +23,7 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityGeneratingFlower; import vazkii.botania.common.lib.LibMisc; @@ -22,8 +31,7 @@ import vazkii.botania.common.lib.LibMisc; import java.util.List; public class SubTileShulkMeNot extends TileEntityGeneratingFlower { - @ObjectHolder(LibMisc.MOD_ID + ":shulk_me_not") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":shulk_me_not") public static TileEntityType TYPE; private static final int RADIUS = 8; @@ -34,27 +42,30 @@ public class SubTileShulkMeNot extends TileEntityGeneratingFlower { @Override public void tickFlower() { super.tickFlower(); - + int generate = getMaxMana(); - + World world = getWorld(); BlockPos pos = getEffectivePos(); Vec3d posD = new Vec3d(pos.getX(), pos.getY(), pos.getZ()); List shulkers = world.getEntitiesWithinAABB(ShulkerEntity.class, new AxisAlignedBB(pos).grow(RADIUS)); - if(!world.isRemote) - for(ShulkerEntity shulker : shulkers) { - if(getMaxMana() - getMana() < generate) + if (!world.isRemote) { + for (ShulkerEntity shulker : shulkers) { + if (getMaxMana() - getMana() < generate) { break; + } - if(shulker.isAlive() && shulker.getDistanceSq(posD) < RADIUS * RADIUS) { + if (shulker.isAlive() && shulker.getDistanceSq(posD) < RADIUS * RADIUS) { LivingEntity target = shulker.getAttackTarget(); - if(target != null && target instanceof IMob && target.isAlive() + if (target != null && target instanceof IMob && target.isAlive() && target.getDistanceSq(posD) < RADIUS * RADIUS && target.getActivePotionEffect(Effects.LEVITATION) != null) { target.remove(); shulker.remove(); - - for(int i = 0; i < 10; i++) // so it's really loud >_> + + for (int i = 0; i < 10; i++) // so it's really loud >_> + { world.playSound(null, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.ENTITY_SHULKER_DEATH, SoundCategory.BLOCKS, 10F, 0.1F); + } particles(world, pos, target); particles(world, pos, shulker); @@ -63,10 +74,11 @@ public class SubTileShulkMeNot extends TileEntityGeneratingFlower { } } } + } } - + private void particles(World world, BlockPos pos, Entity entity) { - if(world instanceof ServerWorld) { + if (world instanceof ServerWorld) { ServerWorld ws = (ServerWorld) world; ws.spawnParticle(ParticleTypes.EXPLOSION, entity.getX() + entity.getWidth() / 2, @@ -76,20 +88,20 @@ public class SubTileShulkMeNot extends TileEntityGeneratingFlower { ws.spawnParticle(ParticleTypes.PORTAL, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 40, 0, 0, 0, 0.6); } } - + @Override public int getColor() { return 0x815598; } - + @Override public RadiusDescriptor getRadius() { return new RadiusDescriptor.Circle(getEffectivePos(), RADIUS); } - + @Override public int getMaxMana() { return 75000; } - + } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileSpectrolus.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileSpectrolus.java index 4b5c183b9..b62ab56c4 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileSpectrolus.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileSpectrolus.java @@ -1,20 +1,17 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 30, 2015, 1:37:26 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.RenderHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.passive.SheepEntity; @@ -33,19 +30,17 @@ import net.minecraft.world.server.ServerWorld; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.registries.ObjectHolder; -import org.lwjgl.opengl.GL11; + import vazkii.botania.api.ColorHelper; import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityGeneratingFlower; -import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.lib.LibMisc; import java.util.List; import java.util.function.Predicate; public class SubTileSpectrolus extends TileEntityGeneratingFlower { - @ObjectHolder(LibMisc.MOD_ID + ":spectrolus") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":spectrolus") public static TileEntityType TYPE; public static final String TAG_NEXT_COLOR = "nextColor"; private static final int WOOL_GEN = 1200; @@ -64,8 +59,9 @@ public class SubTileSpectrolus extends TileEntityGeneratingFlower { public void tickFlower() { super.tickFlower(); - if (getWorld().isRemote) + if (getWorld().isRemote) { return; + } // sheep need to enter the actual block space List targets = getWorld().getEntitiesWithinAABB(SheepEntity.class, new AxisAlignedBB(getEffectivePos()), Entity::isAlive); @@ -75,7 +71,7 @@ public class SubTileSpectrolus extends TileEntityGeneratingFlower { Predicate selector = e -> (e instanceof ItemEntity && e.isAlive() && ((ItemEntity) e).age >= slowdown); targets.addAll(getWorld().getEntitiesWithinAABB(Entity.class, itemAABB, selector)); - for(Entity target : targets) { + for (Entity target : targets) { if (target instanceof SheepEntity) { SheepEntity sheep = (SheepEntity) target; if (!sheep.getSheared() && sheep.getFleeceColor() == nextColor) { @@ -94,10 +90,10 @@ public class SubTileSpectrolus extends TileEntityGeneratingFlower { } else if (target instanceof ItemEntity) { ItemStack stack = ((ItemEntity) target).getItem(); - if(!stack.isEmpty() && ColorHelper.WOOL_MAP.containsValue(Block.getBlockFromItem(stack.getItem()).delegate)) { + if (!stack.isEmpty() && ColorHelper.WOOL_MAP.containsValue(Block.getBlockFromItem(stack.getItem()).delegate)) { Block expected = ColorHelper.WOOL_MAP.get(nextColor).get(); - if(expected.asItem() == stack.getItem()) { + if (expected.asItem() == stack.getItem()) { addManaAndCycle(WOOL_GEN); ((ServerWorld) getWorld()).spawnParticle(new ItemParticleData(ParticleTypes.ITEM, stack), target.getX(), target.getY(), target.getZ(), 20, 0.1D, 0.1D, 0.1D, 0.05D); } @@ -116,7 +112,7 @@ public class SubTileSpectrolus extends TileEntityGeneratingFlower { @Override public RadiusDescriptor getRadius() { - return new RadiusDescriptor.Square(getEffectivePos(), RANGE); + return new RadiusDescriptor.Square(getEffectivePos(), RANGE); } @Override @@ -137,7 +133,7 @@ public class SubTileSpectrolus extends TileEntityGeneratingFlower { ItemStack stack = new ItemStack(ColorHelper.WOOL_MAP.get(nextColor).get()); int color = getColor(); - if(!stack.isEmpty()) { + if (!stack.isEmpty()) { ITextComponent stackName = stack.getDisplayName(); int width = 16 + mc.fontRenderer.getStringWidth(stackName.getString()) / 2; int x = mc.getWindow().getScaledWidth() / 2 - width; diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileThermalily.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileThermalily.java index 82e68ab67..656d6b8a1 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileThermalily.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileThermalily.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 10, 2014, 9:44:02 PM (GMT)] */ package vazkii.botania.common.block.subtile.generating; @@ -16,28 +14,28 @@ import net.minecraft.tags.Tag; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.SoundCategory; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.client.fx.WispParticleData; import vazkii.botania.common.core.handler.ModSounds; import vazkii.botania.common.lib.LibMisc; public class SubTileThermalily extends SubTileHydroangeas { - @ObjectHolder(LibMisc.MOD_ID + ":thermalily") - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":thermalily") public static TileEntityType TYPE; public SubTileThermalily() { super(TYPE); } @Override - public int getColor(){ + public int getColor() { return 0xD03C00; } @Override public void doBurnParticles() { - WispParticleData data = WispParticleData.wisp((float) Math.random() / 6, 0.7F, 0.05F, 0.05F, 1); - world.addParticle(data, getEffectivePos().getX() + 0.55 + Math.random() * 0.2 - 0.1, getEffectivePos().getY() + 0.9 + Math.random() * 0.2 - 0.1, getEffectivePos().getZ() + 0.5, 0, (float) Math.random() / 60, 0); - } + WispParticleData data = WispParticleData.wisp((float) Math.random() / 6, 0.7F, 0.05F, 0.05F, 1); + world.addParticle(data, getEffectivePos().getX() + 0.55 + Math.random() * 0.2 - 0.1, getEffectivePos().getY() + 0.9 + Math.random() * 0.2 - 0.1, getEffectivePos().getZ() + 0.5, 0, (float) Math.random() / 60, 0); + } @Override public Tag getMaterialToSearchFor() { diff --git a/src/main/java/vazkii/botania/common/block/tile/TileAlfPortal.java b/src/main/java/vazkii/botania/common/block/tile/TileAlfPortal.java index 1d4ae8308..912ceb600 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileAlfPortal.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileAlfPortal.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 9, 2014, 8:51:55 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -27,6 +25,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.Explosion; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.ElvenPortalUpdateEvent; import vazkii.botania.api.recipe.IElvenItem; @@ -47,6 +46,7 @@ import vazkii.patchouli.api.PatchouliAPI; import javax.annotation.Nonnull; import javax.annotation.Nullable; + import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -55,8 +55,7 @@ import java.util.stream.Collectors; public class TileAlfPortal extends TileMod implements ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.ALF_PORTAL) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.ALF_PORTAL) public static TileEntityType TYPE; public static final LazyValue MULTIBLOCK = new LazyValue<>(() -> PatchouliAPI.instance.makeMultiblock( new String[][] { @@ -83,8 +82,7 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity { private int ticksSinceLastItem = 0; private boolean closeNow = false; private boolean explode = false; - @Nullable - private UUID breadPlayer = null; + @Nullable private UUID breadPlayer = null; public TileAlfPortal() { super(TYPE); @@ -92,7 +90,7 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity { @Override public void tick() { - if(getBlockState().get(BotaniaStateProps.ALFPORTAL_STATE) == AlfPortalState.OFF) { + if (getBlockState().get(BotaniaStateProps.ALFPORTAL_STATE) == AlfPortalState.OFF) { ticksOpen = 0; return; } @@ -106,16 +104,18 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity { ElvenPortalUpdateEvent event = new ElvenPortalUpdateEvent(this, aabb, open, stacksIn); MinecraftForge.EVENT_BUS.post(event); - if(ticksOpen > 60) { + if (ticksOpen > 60) { ticksSinceLastItem++; - if(world.isRemote && ConfigHandler.CLIENT.elfPortalParticlesEnabled.get()) + if (world.isRemote && ConfigHandler.CLIENT.elfPortalParticlesEnabled.get()) { blockParticle(state); + } List items = world.getEntitiesWithinAABB(ItemEntity.class, aabb); - if(!world.isRemote) - for(ItemEntity item : items) { - if(!item.isAlive()) + if (!world.isRemote) { + for (ItemEntity item : items) { + if (!item.isAlive()) { continue; + } ItemStack stack = item.getItem(); boolean consume; @@ -131,28 +131,33 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity { if (consume) { item.remove(); - if (validateItemUsage(item)) + if (validateItemUsage(item)) { addItem(stack); + } ticksSinceLastItem = 0; } } + } - if(!world.isRemote && !stacksIn.isEmpty() && ticksSinceLastItem >= 4) { + if (!world.isRemote && !stacksIn.isEmpty() && ticksSinceLastItem >= 4) { resolveRecipes(); } } - if(closeNow) { + if (closeNow) { world.setBlockState(getPos(), ModBlocks.alfPortal.getDefaultState()); - for(int i = 0; i < 36; i++) + for (int i = 0; i < 36; i++) { blockParticle(state); + } closeNow = false; - } else if(newState != state) { - if(newState == AlfPortalState.OFF) - for(int i = 0; i < 36; i++) + } else if (newState != state) { + if (newState == AlfPortalState.OFF) { + for (int i = 0; i < 36; i++) { blockParticle(state); + } + } world.setBlockState(getPos(), getBlockState().with(BotaniaStateProps.ALFPORTAL_STATE, newState)); - } else if(explode) { + } else if (explode) { world.createExplosion(null, pos.getX() + .5, pos.getY() + 2.0, pos.getZ() + .5, 3f, Explosion.Mode.DESTROY); explode = false; @@ -169,12 +174,12 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity { private boolean validateItemUsage(ItemEntity entity) { ItemStack inputStack = entity.getItem(); - for(RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes.values()) { - if(recipe.containsItem(inputStack)) { + for (RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes.values()) { + if (recipe.containsItem(inputStack)) { return true; } } - if(inputStack.getItem() == Items.BREAD) { + if (inputStack.getItem() == Items.BREAD) { //Don't teleport bread. (See also: #2403) explode = true; breadPlayer = entity.getThrowerId(); @@ -188,16 +193,43 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity { // Pick one of the inner positions switch (world.rand.nextInt(9)) { - default: - case 0: dh = 0; dy = 1; break; - case 1: dh = 0; dy = 2; break; - case 2: dh = 0; dy = 3; break; - case 3: dh = -1; dy = 1; break; - case 4: dh = -1; dy = 2; break; - case 5: dh = -1; dy = 3; break; - case 6: dh = 1; dy = 1; break; - case 7: dh = 1; dy = 2; break; - case 8: dh = 1; dy = 3; break; + default: + case 0: + dh = 0; + dy = 1; + break; + case 1: + dh = 0; + dy = 2; + break; + case 2: + dh = 0; + dy = 3; + break; + case 3: + dh = -1; + dy = 1; + break; + case 4: + dh = -1; + dy = 2; + break; + case 5: + dh = -1; + dy = 3; + break; + case 6: + dh = 1; + dy = 1; + break; + case 7: + dh = 1; + dy = 2; + break; + case 8: + dh = 1; + dy = 3; + break; } double dx = state == AlfPortalState.ON_X ? 0 : dh; double dz = state == AlfPortalState.ON_Z ? 0 : dh; @@ -209,9 +241,9 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity { public boolean onWanded() { AlfPortalState state = getBlockState().get(BotaniaStateProps.ALFPORTAL_STATE); - if(state == AlfPortalState.OFF) { + if (state == AlfPortalState.OFF) { AlfPortalState newState = getValidState(); - if(newState != AlfPortalState.OFF) { + if (newState != AlfPortalState.OFF) { world.setBlockState(getPos(), getBlockState().with(BotaniaStateProps.ALFPORTAL_STATE, newState)); return true; } @@ -222,8 +254,9 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity { private AxisAlignedBB getPortalAABB() { AxisAlignedBB aabb = new AxisAlignedBB(pos.add(-1, 1, 0), pos.add(2, 4, 1)); - if(getBlockState().get(BotaniaStateProps.ALFPORTAL_STATE) == AlfPortalState.ON_X) + if (getBlockState().get(BotaniaStateProps.ALFPORTAL_STATE) == AlfPortalState.ON_X) { aabb = new AxisAlignedBB(pos.add(0, 1, -1), pos.add(1, 4, 2)); + } return aabb; } @@ -231,22 +264,24 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity { private void addItem(ItemStack stack) { int size = stack.getCount(); stack.setCount(1); - for(int i = 0; i < size; i++) + for (int i = 0; i < size; i++) { stacksIn.add(stack.copy()); + } } private void resolveRecipes() { List pylons = locatePylons(); - for(RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes.values()) { + for (RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes.values()) { Optional> match = recipe.match(stacksIn); - if(match.isPresent()) { - if(consumeMana(pylons, 500, false)) { + if (match.isPresent()) { + if (consumeMana(pylons, 500, false)) { List inputs = match.get(); - for(ItemStack stack : inputs) { + for (ItemStack stack : inputs) { stacksIn.remove(stack); } - for(ItemStack output : recipe.getOutputs(inputs)) + for (ItemStack output : recipe.getOutputs(inputs)) { spawnItem(output.copy()); + } } break; } @@ -267,7 +302,7 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity { cmp.putInt(TAG_STACK_COUNT, stacksIn.size()); int i = 0; - for(ItemStack stack : stacksIn) { + for (ItemStack stack : stacksIn) { CompoundNBT stackcmp = stack.write(new CompoundNBT()); cmp.put(TAG_STACK + i, stackcmp); i++; @@ -282,7 +317,7 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity { int count = cmp.getInt(TAG_STACK_COUNT); stacksIn.clear(); - for(int i = 0; i < count; i++) { + for (int i = 0; i < count; i++) { CompoundNBT stackcmp = cmp.getCompound(TAG_STACK + i); ItemStack stack = ItemStack.read(stackcmp); stacksIn.add(stack); @@ -303,16 +338,19 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity { private AlfPortalState getValidState() { Rotation rot = MULTIBLOCK.getValue().validate(world, getPos()); - if (rot == null) + if (rot == null) { return AlfPortalState.OFF; + } lightPylons(); switch (rot) { - default: - case NONE: - case CLOCKWISE_180: return AlfPortalState.ON_Z; - case CLOCKWISE_90: - case COUNTERCLOCKWISE_90: return AlfPortalState.ON_X; + default: + case NONE: + case CLOCKWISE_180: + return AlfPortalState.ON_Z; + case CLOCKWISE_90: + case COUNTERCLOCKWISE_90: + return AlfPortalState.ON_X; } } @@ -329,28 +367,30 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity { } public void lightPylons() { - if(ticksOpen < 50) + if (ticksOpen < 50) { return; + } List pylons = locatePylons(); - for(BlockPos pos : pylons) { + for (BlockPos pos : pylons) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TilePylon) { + if (tile instanceof TilePylon) { TilePylon pylon = (TilePylon) tile; pylon.activated = true; pylon.centerPos = getPos(); } } - if(ticksOpen == 50) + if (ticksOpen == 50) { consumeMana(pylons, 200000, true); + } } public boolean consumeMana(List pylons, int totalCost, boolean close) { List consumePools = new ArrayList<>(); int consumed = 0; - if(pylons.size() < 2) { + if (pylons.size() < 2) { closeNow = true; return false; } @@ -358,31 +398,32 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity { int costPer = Math.max(1, totalCost / pylons.size()); int expectedConsumption = costPer * pylons.size(); - for(BlockPos pos : pylons) { + for (BlockPos pos : pylons) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TilePylon) { + if (tile instanceof TilePylon) { TilePylon pylon = (TilePylon) tile; pylon.activated = true; pylon.centerPos = getPos(); } tile = world.getTileEntity(pos.down()); - if(tile instanceof TilePool) { + if (tile instanceof TilePool) { TilePool pool = (TilePool) tile; - if(pool.getCurrentMana() < costPer) { + if (pool.getCurrentMana() < costPer) { closeNow = closeNow || close; return false; - } else if(!world.isRemote) { + } else if (!world.isRemote) { consumePools.add(pool); consumed += costPer; } } } - if(consumed >= expectedConsumption) { - for(TilePool pool : consumePools) + if (consumed >= expectedConsumption) { + for (TilePool pool : consumePools) { pool.recieveMana(-costPer); + } return true; } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileAltar.java b/src/main/java/vazkii/botania/common/block/tile/TileAltar.java index db758e62f..ca9a845fb 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileAltar.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileAltar.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 21, 2014, 7:51:36 PM (GMT)] */ package vazkii.botania.common.block.tile; import com.google.common.base.Preconditions; import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.block.Blocks; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.I18n; @@ -42,6 +41,7 @@ import net.minecraftforge.fluids.capability.IFluidHandlerItem; import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.item.IPetalApothecary; @@ -57,14 +57,14 @@ import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; import javax.annotation.Nullable; + import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; public class TileAltar extends TileSimpleInventory implements IPetalApothecary, ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.ALTAR) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.ALTAR) public static TileEntityType TYPE; private static final Pattern SEED_PATTERN = Pattern.compile("(?:(?:(?:[A-Z-_.:]|^)seed)|(?:(?:[a-z-_.:]|^)Seed))(?:[sA-Z-_.:]|$)"); private static final int SET_KEEP_TICKS_EVENT = 0; private static final int CRAFT_EFFECT_EVENT = 1; @@ -84,10 +84,11 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary, public boolean collideEntityItem(ItemEntity item) { ItemStack stack = item.getItem(); - if(world.isRemote || stack.isEmpty() || !item.isAlive()) + if (world.isRemote || stack.isEmpty() || !item.isAlive()) { return false; + } - if(getBlockState().getBlock() == ModBlocks.defaultAltar && stack.getItem() == Blocks.VINE.asItem()) { + if (getBlockState().getBlock() == ModBlocks.defaultAltar && stack.getItem() == Blocks.VINE.asItem()) { CompoundNBT tmp = new CompoundNBT(); writePacketNBT(tmp); @@ -95,7 +96,7 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary, world.setBlockState(getPos(), ModBlocks.mossyAltar.getDefaultState()); TileEntity newAltar = world.getTileEntity(getPos()); - if(newAltar instanceof TileAltar) { + if (newAltar instanceof TileAltar) { ((TileAltar) newAltar).readPacketNBT(tmp); } @@ -103,8 +104,8 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary, } boolean hasFluidCapability = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY).isPresent(); - - if(getFluid() == Fluids.EMPTY) { + + if (getFluid() == Fluids.EMPTY) { // XXX: special handling for now since fish buckets don't have fluid cap, may need to be changed later if (stack.getItem() instanceof FishBucketItem && ((FishBucketItem) stack.getItem()).getFluid() == Fluids.WATER) { setFluid(Fluids.WATER); @@ -113,19 +114,19 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary, return true; } - if(hasFluidCapability) { + if (hasFluidCapability) { IFluidHandlerItem fluidHandler = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY).orElseThrow(NullPointerException::new); FluidStack drainWater = fluidHandler.drain(new FluidStack(Fluids.WATER, FluidAttributes.BUCKET_VOLUME), IFluidHandler.FluidAction.SIMULATE); FluidStack drainLava = fluidHandler.drain(new FluidStack(Fluids.LAVA, FluidAttributes.BUCKET_VOLUME), IFluidHandler.FluidAction.SIMULATE); - if(!drainWater.isEmpty() && drainWater.getFluid() == Fluids.WATER && drainWater.getAmount() == FluidAttributes.BUCKET_VOLUME) { - setFluid(Fluids.WATER); + if (!drainWater.isEmpty() && drainWater.getFluid() == Fluids.WATER && drainWater.getAmount() == FluidAttributes.BUCKET_VOLUME) { + setFluid(Fluids.WATER); world.updateComparatorOutputLevel(pos, getBlockState().getBlock()); fluidHandler.drain(new FluidStack(Fluids.WATER, FluidAttributes.BUCKET_VOLUME), IFluidHandler.FluidAction.EXECUTE); item.setItem(fluidHandler.getContainer()); return true; - } else if(!drainLava.isEmpty() && drainLava.getFluid() == Fluids.LAVA && drainLava.getAmount() == FluidAttributes.BUCKET_VOLUME) { + } else if (!drainLava.isEmpty() && drainLava.getFluid() == Fluids.LAVA && drainLava.getAmount() == FluidAttributes.BUCKET_VOLUME) { setFluid(Fluids.LAVA); world.updateComparatorOutputLevel(pos, getBlockState().getBlock()); fluidHandler.drain(new FluidStack(Fluids.LAVA, FluidAttributes.BUCKET_VOLUME), IFluidHandler.FluidAction.EXECUTE); @@ -137,40 +138,42 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary, return false; } - if(getFluid() == Fluids.LAVA) { + if (getFluid() == Fluids.LAVA) { item.setFire(100); return true; } - - if(SEED_PATTERN.matcher(stack.getTranslationKey()).find()) { - for(RecipePetals recipe : BotaniaAPI.petalRecipes.values()) { - if(recipe.matches(itemHandler)) { + + if (SEED_PATTERN.matcher(stack.getTranslationKey()).find()) { + for (RecipePetals recipe : BotaniaAPI.petalRecipes.values()) { + if (recipe.matches(itemHandler)) { saveLastRecipe(); - - for(int i = 0; i < getSizeInventory(); i++) + + for (int i = 0; i < getSizeInventory(); i++) { itemHandler.setStackInSlot(i, ItemStack.EMPTY); - + } + stack.shrink(1); - + ItemStack output = recipe.getOutput().copy(); ItemEntity outputItem = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, output); outputItem.addTag(ITEM_TAG_APOTHECARY_SPAWNED); world.addEntity(outputItem); - + setFluid(Fluids.EMPTY); world.updateComparatorOutputLevel(pos, getBlockState().getBlock()); - + world.addBlockEvent(getPos(), getBlockState().getBlock(), CRAFT_EFFECT_EVENT, 0); - + return true; } } - } else if(!hasFluidCapability && !item.getTags().contains(ITEM_TAG_APOTHECARY_SPAWNED)) { - if(!itemHandler.getStackInSlot(getSizeInventory() - 1).isEmpty()) + } else if (!hasFluidCapability && !item.getTags().contains(ITEM_TAG_APOTHECARY_SPAWNED)) { + if (!itemHandler.getStackInSlot(getSizeInventory() - 1).isEmpty()) { return false; - - for(int i = 0; i < getSizeInventory(); i++) { - if(itemHandler.getStackInSlot(i).isEmpty()) { + } + + for (int i = 0; i < getSizeInventory(); i++) { + if (itemHandler.getStackInSlot(i).isEmpty()) { itemHandler.setStackInSlot(i, stack.split(1)); world.playSound(null, pos, SoundEvents.ENTITY_GENERIC_SPLASH, SoundCategory.BLOCKS, 0.1F, 10F); return true; @@ -184,17 +187,19 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary, @Nullable private ICustomApothecaryColor getFlowerComponent(ItemStack stack) { ICustomApothecaryColor c = null; - if(stack.getItem() instanceof ICustomApothecaryColor) + if (stack.getItem() instanceof ICustomApothecaryColor) { c = (ICustomApothecaryColor) stack.getItem(); + } return c; } public void saveLastRecipe() { lastRecipe = new ArrayList<>(); - for(int i = 0; i < getSizeInventory(); i++) { + for (int i = 0; i < getSizeInventory(); i++) { ItemStack stack = itemHandler.getStackInSlot(i); - if(stack.isEmpty()) + if (stack.isEmpty()) { break; + } lastRecipe.add(stack.copy()); } recipeKeepTicks = 400; @@ -203,23 +208,26 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary, public void trySetLastRecipe(PlayerEntity player) { tryToSetLastRecipe(player, itemHandler, lastRecipe); - if(!isEmpty()) + if (!isEmpty()) { VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos); + } } public static void tryToSetLastRecipe(PlayerEntity player, IItemHandlerModifiable inv, List lastRecipe) { - if(lastRecipe == null || lastRecipe.isEmpty() || player.world.isRemote) + if (lastRecipe == null || lastRecipe.isEmpty() || player.world.isRemote) { return; + } int index = 0; boolean didAny = false; - for(ItemStack stack : lastRecipe) { - if(stack.isEmpty()) + for (ItemStack stack : lastRecipe) { + if (stack.isEmpty()) { continue; + } - for(int i = 0; i < player.inventory.getSizeInventory(); i++) { + for (int i = 0; i < player.inventory.getSizeInventory(); i++) { ItemStack pstack = player.inventory.getStackInSlot(i); - if(player.isCreative() || (!pstack.isEmpty() && pstack.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(stack, pstack))) { + if (player.isCreative() || (!pstack.isEmpty() && pstack.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(stack, pstack))) { inv.setStackInSlot(index, player.isCreative() ? stack.copy() : pstack.split(1)); didAny = true; index++; @@ -228,7 +236,7 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary, } } - if(didAny) { + if (didAny) { player.world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.ENTITY_GENERIC_SPLASH, SoundCategory.BLOCKS, 0.1F, 10F); ServerPlayerEntity mp = (ServerPlayerEntity) player; mp.container.detectAndSendChanges(); @@ -236,54 +244,63 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary, } public boolean isEmpty() { - for(int i = 0; i < getSizeInventory(); i++) - if(!itemHandler.getStackInSlot(i).isEmpty()) + for (int i = 0; i < getSizeInventory(); i++) { + if (!itemHandler.getStackInSlot(i).isEmpty()) { return false; + } + } return true; } @Override public void tick() { - if(!world.isRemote) { + if (!world.isRemote) { List items = world.getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(pos.add(0, 1D / 16D * 20D, 0), pos.add(1, 1D / 16D * 32D, 1))); boolean didChange = false; - for(ItemEntity item : items) + for (ItemEntity item : items) { didChange = collideEntityItem(item) || didChange; + } - if(didChange) + if (didChange) { VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos); + } } else { - for(int i = 0; i < getSizeInventory(); i++) { + for (int i = 0; i < getSizeInventory(); i++) { ItemStack stackAt = itemHandler.getStackInSlot(i); - if(stackAt.isEmpty()) + if (stackAt.isEmpty()) { break; + } - if(Math.random() >= 0.97) { + if (Math.random() >= 0.97) { ICustomApothecaryColor comp = getFlowerComponent(stackAt); int color = comp == null ? 0x888888 : comp.getParticleColor(stackAt); float red = (color >> 16 & 0xFF) / 255F; float green = (color >> 8 & 0xFF) / 255F; float blue = (color & 0xFF) / 255F; - if(Math.random() >= 0.75F) + if (Math.random() >= 0.75F) { world.playSound(null, pos, SoundEvents.ENTITY_GENERIC_SPLASH, SoundCategory.BLOCKS, 0.1F, 10F); - SparkleParticleData data = SparkleParticleData.sparkle((float) Math.random(), red, green, blue, 10); - world.addParticle(data, pos.getX() + 0.5 + Math.random() * 0.4 - 0.2, pos.getY() + 1.2, pos.getZ() + 0.5 + Math.random() * 0.4 - 0.2, 0, 0, 0); - } + } + SparkleParticleData data = SparkleParticleData.sparkle((float) Math.random(), red, green, blue, 10); + world.addParticle(data, pos.getX() + 0.5 + Math.random() * 0.4 - 0.2, pos.getY() + 1.2, pos.getZ() + 0.5 + Math.random() * 0.4 - 0.2, 0, 0, 0); + } } - if(getFluid() == Fluids.LAVA) { + if (getFluid() == Fluids.LAVA) { world.addParticle(ParticleTypes.SMOKE, pos.getX() + 0.5 + Math.random() * 0.4 - 0.2, pos.getY() + 1, pos.getZ() + 0.5 + Math.random() * 0.4 - 0.2, 0, 0.05, 0); - if(Math.random() > 0.9) + if (Math.random() > 0.9) { world.addParticle(ParticleTypes.LAVA, pos.getX() + 0.5 + Math.random() * 0.4 - 0.2, pos.getY() + 1, pos.getZ() + 0.5 + Math.random() * 0.4 - 0.2, 0, 0.01, 0); + } } } - if(recipeKeepTicks > 0) + if (recipeKeepTicks > 0) { --recipeKeepTicks; - else lastRecipe = null; + } else { + lastRecipe = null; + } } @Override @@ -303,22 +320,25 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary, @Override public boolean receiveClientEvent(int id, int param) { - switch(id) { - case SET_KEEP_TICKS_EVENT: recipeKeepTicks = param; return true; - case CRAFT_EFFECT_EVENT: { - if(world.isRemote) { - for(int i = 0; i < 25; i++) { - float red = (float) Math.random(); - float green = (float) Math.random(); - float blue = (float) Math.random(); - SparkleParticleData data = SparkleParticleData.sparkle((float) Math.random(), red, green, blue, 10); - world.addParticle(data, pos.getX() + 0.5 + Math.random() * 0.4 - 0.2, pos.getY() + 1, pos.getZ() + 0.5 + Math.random() * 0.4 - 0.2, 0, 0, 0); - } - world.playSound(pos.getX(), pos.getY(), pos.getZ(), ModSounds.altarCraft, SoundCategory.BLOCKS, 1F, 1F, false); + switch (id) { + case SET_KEEP_TICKS_EVENT: + recipeKeepTicks = param; + return true; + case CRAFT_EFFECT_EVENT: { + if (world.isRemote) { + for (int i = 0; i < 25; i++) { + float red = (float) Math.random(); + float green = (float) Math.random(); + float blue = (float) Math.random(); + SparkleParticleData data = SparkleParticleData.sparkle((float) Math.random(), red, green, blue, 10); + world.addParticle(data, pos.getX() + 0.5 + Math.random() * 0.4 - 0.2, pos.getY() + 1, pos.getZ() + 0.5 + Math.random() * 0.4 - 0.2, 0, 0, 0); } - return true; + world.playSound(pos.getX(), pos.getY(), pos.getZ(), ModSounds.altarCraft, SoundCategory.BLOCKS, 1F, 1F, false); } - default: return super.receiveClientEvent(id, param); + return true; + } + default: + return super.receiveClientEvent(id, param); } } @@ -357,17 +377,18 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary, float angle = -90; int radius = 24; int amt = 0; - for(int i = 0; i < getSizeInventory(); i++) { - if(itemHandler.getStackInSlot(i).isEmpty()) + for (int i = 0; i < getSizeInventory(); i++) { + if (itemHandler.getStackInSlot(i).isEmpty()) { break; + } amt++; } - if(amt > 0) { + if (amt > 0) { float anglePer = 360F / amt; - for(RecipePetals recipe : BotaniaAPI.petalRecipes.values()) - if(recipe.matches(itemHandler)) { + for (RecipePetals recipe : BotaniaAPI.petalRecipes.values()) { + if (recipe.matches(itemHandler)) { RenderSystem.color4f(1F, 1F, 1F, 1F); mc.textureManager.bindTexture(HUDHandler.manaBar); RenderHelper.drawTexturedModalRect(xc + radius + 9, yc - 8, 0, 8, 22, 15); @@ -378,8 +399,9 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary, mc.getItemRenderer().renderItemIntoGUI(new ItemStack(Items.WHEAT_SEEDS), xc + radius + 16, yc + 6); mc.fontRenderer.drawStringWithShadow("+", xc + radius + 14, yc + 10, 0xFFFFFF); } + } - for(int i = 0; i < amt; i++) { + for (int i = 0; i < amt; i++) { double xPos = xc + Math.cos(angle * Math.PI / 180D) * radius - 8; double yPos = yc + Math.sin(angle * Math.PI / 180D) * radius - 8; RenderSystem.translated(xPos, yPos, 0); @@ -388,7 +410,7 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary, angle += anglePer; } - } else if(recipeKeepTicks > 0 && getFluid() == Fluids.WATER) { + } else if (recipeKeepTicks > 0 && getFluid() == Fluids.WATER) { String s = I18n.format("botaniamisc.altarRefill0"); mc.fontRenderer.drawStringWithShadow(s, xc - mc.fontRenderer.getStringWidth(s) / 2, yc + 10, 0xFFFFFF); s = I18n.format("botaniamisc.altarRefill1"); diff --git a/src/main/java/vazkii/botania/common/block/tile/TileAnimatedTorch.java b/src/main/java/vazkii/botania/common/block/tile/TileAnimatedTorch.java index 3e8258247..f40ba19da 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileAnimatedTorch.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileAnimatedTorch.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [28/09/2016, 17:21:24 (GMT)] */ package vazkii.botania.common.block.tile; @@ -23,6 +21,7 @@ import net.minecraft.util.Direction; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.lib.LibBlockNames; @@ -32,8 +31,7 @@ import java.util.Arrays; public class TileAnimatedTorch extends TileMod implements ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.ANIMATED_TORCH) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.ANIMATED_TORCH) public static TileEntityType TYPE; private static final String TAG_SIDE = "side"; private static final String TAG_ROTATING = "rotating"; @@ -67,24 +65,26 @@ public class TileAnimatedTorch extends TileMod implements ITickableTileEntity { @Override public void onLoad() { - if(!world.isRemote) + if (!world.isRemote) { nextRandomRotation = world.rand.nextInt(4); + } } public void handRotate() { - if(!world.isRemote) + if (!world.isRemote) { world.addBlockEvent(getPos(), ModBlocks.animatedTorch, 0, (side + 1) % 4); + } } - + public void onPlace(LivingEntity entity) { - if(entity != null) { + if (entity != null) { side = Arrays.asList(SIDES).indexOf(entity.getHorizontalFacing().getOpposite()); } world.notifyNeighborsOfStateChange(getPos().offset(SIDES[side].getOpposite()), getBlockState().getBlock()); } public void toggle() { - if(!world.isRemote) { + if (!world.isRemote) { world.addBlockEvent(getPos(), ModBlocks.animatedTorch, 0, torchMode.modeSwitcher.rotate(this, side)); nextRandomRotation = world.rand.nextInt(4); VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); @@ -109,15 +109,17 @@ public class TileAnimatedTorch extends TileMod implements ITickableTileEntity { } private void rotateTo(int side) { - if(rotating) + if (rotating) { return; + } currentRandomRotation = nextRandomRotation; int finalRotation = side * 90; double diff = (finalRotation - rotation % 360) % 360; - if(diff < 0) + if (diff < 0) { diff = 360 + diff; + } rotationTicks = 4; anglePerTick = diff / rotationTicks; @@ -126,7 +128,7 @@ public class TileAnimatedTorch extends TileMod implements ITickableTileEntity { // tell neighbors that signal is off because we are rotating world.notifyNeighborsOfStateChange(getPos(), getBlockState().getBlock()); - for(Direction e : Direction.values()) { + for (Direction e : Direction.values()) { world.notifyNeighborsOfStateChange(getPos().offset(e), getBlockState().getBlock()); } } @@ -142,30 +144,33 @@ public class TileAnimatedTorch extends TileMod implements ITickableTileEntity { @Override public void tick() { - if(rotating) { + if (rotating) { lastTickRotation = rotation; rotation = (rotation + anglePerTick) % 360; rotationTicks--; - if(rotationTicks <= 0) { + if (rotationTicks <= 0) { rotating = false; // done rotating, tell neighbors world.notifyNeighborsOfStateChange(getPos(), getBlockState().getBlock()); - for(Direction e : Direction.values()) { + for (Direction e : Direction.values()) { world.notifyNeighborsOfStateChange(getPos().offset(e), getBlockState().getBlock()); } } - } else rotation = side * 90; + } else { + rotation = side * 90; + } - if(world.isRemote) { + if (world.isRemote) { int amt = rotating ? 3 : Math.random() < 0.1 ? 1 : 0; double x = getPos().getX() + 0.5 + Math.cos((rotation + 90) / 180.0 * Math.PI) * 0.35; double y = getPos().getY() + 0.2; double z = getPos().getZ() + 0.5 + Math.sin((rotation + 90) / 180.0 * Math.PI) * 0.35; - for(int i = 0; i < amt; i++) + for (int i = 0; i < amt; i++) { world.addParticle(RedstoneParticleData.REDSTONE_DUST, x, y, z, 0.0D, 0.0D, 0.0D); + } } } @@ -183,8 +188,9 @@ public class TileAnimatedTorch extends TileMod implements ITickableTileEntity { public void readPacketNBT(CompoundNBT cmp) { side = cmp.getInt(TAG_SIDE); rotating = cmp.getBoolean(TAG_ROTATING); - if(world != null && !world.isRemote) + if (world != null && !world.isRemote) { rotationTicks = cmp.getInt(TAG_ROTATION_TICKS); + } anglePerTick = cmp.getDouble(TAG_ANGLE_PER_TICK); nextRandomRotation = cmp.getInt(TAG_NEXT_RANDOM_ROTATION); diff --git a/src/main/java/vazkii/botania/common/block/tile/TileAvatar.java b/src/main/java/vazkii/botania/common/block/tile/TileAvatar.java index d744c6a81..6af574318 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileAvatar.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileAvatar.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Oct 24, 2015, 3:17:44 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -18,6 +16,7 @@ import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.item.IAvatarTile; import vazkii.botania.api.item.IAvatarWieldable; import vazkii.botania.common.lib.LibBlockNames; @@ -27,8 +26,7 @@ import javax.annotation.Nonnull; public class TileAvatar extends TileSimpleInventory implements IAvatarTile, ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.AVATAR) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.AVATAR) public static TileEntityType TYPE; private static final int MAX_MANA = 6400; @@ -47,22 +45,23 @@ public class TileAvatar extends TileSimpleInventory implements IAvatarTile, ITic @Override public void tick() { enabled = true; - for(Direction dir : Direction.values()) { + for (Direction dir : Direction.values()) { int redstoneSide = world.getRedstonePower(pos.offset(dir), dir); - if(redstoneSide > 0) { + if (redstoneSide > 0) { enabled = false; break; } } ItemStack stack = itemHandler.getStackInSlot(0); - if(!stack.isEmpty() && stack.getItem() instanceof IAvatarWieldable) { + if (!stack.isEmpty() && stack.getItem() instanceof IAvatarWieldable) { IAvatarWieldable wieldable = (IAvatarWieldable) stack.getItem(); wieldable.onAvatarUpdate(this, stack); } - if(enabled) + if (enabled) { ticksElapsed++; + } } @Override diff --git a/src/main/java/vazkii/botania/common/block/tile/TileBifrost.java b/src/main/java/vazkii/botania/common/block/tile/TileBifrost.java index ee590dbfb..50e1cd123 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileBifrost.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileBifrost.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 20, 2014, 8:35:27 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -14,6 +12,7 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; @@ -21,8 +20,7 @@ import javax.annotation.Nonnull; public class TileBifrost extends TileMod implements ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.BIFROST) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.BIFROST) public static TileEntityType TYPE; private static final String TAG_TICKS = "ticks"; public int ticks = 0; @@ -33,10 +31,12 @@ public class TileBifrost extends TileMod implements ITickableTileEntity { @Override public void tick() { - if(!world.isRemote) { - if(ticks <= 0) { + if (!world.isRemote) { + if (ticks <= 0) { world.removeBlock(pos, false); - } else ticks--; + } else { + ticks--; + } } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileBrewery.java b/src/main/java/vazkii/botania/common/block/tile/TileBrewery.java index ca0bf109c..3e92cdb94 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileBrewery.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileBrewery.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Oct 31, 2014, 4:42:36 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -21,6 +19,7 @@ import net.minecraft.util.Hand; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.brew.IBrewContainer; import vazkii.botania.api.brew.IBrewItem; @@ -38,13 +37,12 @@ import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import java.awt.*; + import java.util.List; public class TileBrewery extends TileSimpleInventory implements IManaReceiver, ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.BREWERY) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.BREWERY) public static TileEntityType TYPE; private static final String TAG_MANA = "mana"; private static final int CRAFT_EFFECT_EVENT = 0; @@ -58,34 +56,38 @@ public class TileBrewery extends TileSimpleInventory implements IManaReceiver, I } public boolean addItem(@Nullable PlayerEntity player, ItemStack stack, @Nullable Hand hand) { - if(recipe != null || stack.isEmpty() || stack.getItem() instanceof IBrewItem && ((IBrewItem) stack.getItem()).getBrew(stack) != null && ((IBrewItem) stack.getItem()).getBrew(stack) != BotaniaAPI.fallbackBrew || itemHandler.getStackInSlot(0).isEmpty() != stack.getItem() instanceof IBrewContainer) + if (recipe != null || stack.isEmpty() || stack.getItem() instanceof IBrewItem && ((IBrewItem) stack.getItem()).getBrew(stack) != null && ((IBrewItem) stack.getItem()).getBrew(stack) != BotaniaAPI.fallbackBrew || itemHandler.getStackInSlot(0).isEmpty() != stack.getItem() instanceof IBrewContainer) { return false; + } boolean did = false; - for(int i = 0; i < getSizeInventory(); i++) - if(itemHandler.getStackInSlot(i).isEmpty()) { + for (int i = 0; i < getSizeInventory(); i++) { + if (itemHandler.getStackInSlot(i).isEmpty()) { did = true; ItemStack stackToAdd = stack.copy(); stackToAdd.setCount(1); itemHandler.setStackInSlot(i, stackToAdd); - if(player == null || !player.abilities.isCreativeMode) { + if (player == null || !player.abilities.isCreativeMode) { stack.shrink(1); - if(stack.isEmpty() && player != null) + if (stack.isEmpty() && player != null) { player.setHeldItem(hand, ItemStack.EMPTY); + } } break; } + } - if(did) { + if (did) { VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos); - for(RecipeBrew recipe : BotaniaAPI.brewRecipes.values()) - if(recipe.matches(itemHandler) && !recipe.getOutput(itemHandler.getStackInSlot(0)).isEmpty()) { + for (RecipeBrew recipe : BotaniaAPI.brewRecipes.values()) { + if (recipe.matches(itemHandler) && !recipe.getOutput(itemHandler.getStackInSlot(0)).isEmpty()) { this.recipe = recipe; world.setBlockState(pos, ModBlocks.brewery.getDefaultState().with(BotaniaStateProps.POWERED, true)); } + } } return true; @@ -93,52 +95,55 @@ public class TileBrewery extends TileSimpleInventory implements IManaReceiver, I @Override public void tick() { - if(mana > 0 && recipe == null) { - for(RecipeBrew recipe : BotaniaAPI.brewRecipes.values()) - if(recipe.matches(itemHandler)) { + if (mana > 0 && recipe == null) { + for (RecipeBrew recipe : BotaniaAPI.brewRecipes.values()) { + if (recipe.matches(itemHandler)) { this.recipe = recipe; world.setBlockState(pos, ModBlocks.brewery.getDefaultState().with(BotaniaStateProps.POWERED, true)); } + } - if(recipe == null) + if (recipe == null) { mana = 0; + } } // Update every tick. recieveMana(0); - if(!world.isRemote && recipe == null) { + if (!world.isRemote && recipe == null) { List items = world.getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1)); - for(ItemEntity item : items) - if(item.isAlive() && !item.getItem().isEmpty()) { + for (ItemEntity item : items) { + if (item.isAlive() && !item.getItem().isEmpty()) { ItemStack stack = item.getItem(); addItem(null, stack, null); } + } } - if(recipe != null) { - if(!recipe.matches(itemHandler)) { + if (recipe != null) { + if (!recipe.matches(itemHandler)) { recipe = null; world.setBlockState(pos, ModBlocks.brewery.getDefaultState()); } - if(recipe != null) { - if(mana != manaLastTick) { + if (recipe != null) { + if (mana != manaLastTick) { int color = recipe.getBrew().getColor(itemHandler.getStackInSlot(0)); float r = (color >> 16 & 0xFF) / 255F; float g = (color >> 8 & 0xFF) / 255F; float b = (color & 0xFF) / 255F; - for(int i = 0; i < 5; i++) { - WispParticleData data1 = WispParticleData.wisp(0.1F + (float) Math.random() * 0.05F, r, g, b); - world.addParticle(data1, pos.getX() + 0.7 - Math.random() * 0.4, pos.getY() + 0.9 - Math.random() * 0.2, pos.getZ() + 0.7 - Math.random() * 0.4, 0.03F - (float) Math.random() * 0.06F, 0.03F + (float) Math.random() * 0.015F, 0.03F - (float) Math.random() * 0.06F); - for(int j = 0; j < 2; j++) { - WispParticleData data = WispParticleData.wisp(0.1F + (float) Math.random() * 0.2F, 0.2F, 0.2F, 0.2F); - world.addParticle(data, pos.getX() + 0.7 - Math.random() * 0.4, pos.getY() + 0.9 - Math.random() * 0.2, pos.getZ() + 0.7 - Math.random() * 0.4, 0.03F - (float) Math.random() * 0.06F, 0.03F + (float) Math.random() * 0.015F, 0.03F - (float) Math.random() * 0.06F); - } + for (int i = 0; i < 5; i++) { + WispParticleData data1 = WispParticleData.wisp(0.1F + (float) Math.random() * 0.05F, r, g, b); + world.addParticle(data1, pos.getX() + 0.7 - Math.random() * 0.4, pos.getY() + 0.9 - Math.random() * 0.2, pos.getZ() + 0.7 - Math.random() * 0.4, 0.03F - (float) Math.random() * 0.06F, 0.03F + (float) Math.random() * 0.015F, 0.03F - (float) Math.random() * 0.06F); + for (int j = 0; j < 2; j++) { + WispParticleData data = WispParticleData.wisp(0.1F + (float) Math.random() * 0.2F, 0.2F, 0.2F, 0.2F); + world.addParticle(data, pos.getX() + 0.7 - Math.random() * 0.4, pos.getY() + 0.9 - Math.random() * 0.2, pos.getZ() + 0.7 - Math.random() * 0.4, 0.03F - (float) Math.random() * 0.06F, 0.03F + (float) Math.random() * 0.015F, 0.03F - (float) Math.random() * 0.06F); + } } } - if(mana >= getManaCost() && !world.isRemote) { + if (mana >= getManaCost() && !world.isRemote) { int mana = getManaCost(); recieveMana(-mana); @@ -147,17 +152,19 @@ public class TileBrewery extends TileSimpleInventory implements IManaReceiver, I world.addEntity(outputItem); world.addBlockEvent(getPos(), ModBlocks.brewery, CRAFT_EFFECT_EVENT, recipe.getBrew().getColor(output)); - for(int i = 0; i < getSizeInventory(); i++) + for (int i = 0; i < getSizeInventory(); i++) { itemHandler.setStackInSlot(i, ItemStack.EMPTY); + } } } } int newSignal = 0; - if(recipe != null) + if (recipe != null) { newSignal++; + } - if(newSignal != signal) { + if (newSignal != signal) { signal = newSignal; world.updateComparatorOutputLevel(pos, getBlockState().getBlock()); } @@ -167,18 +174,18 @@ public class TileBrewery extends TileSimpleInventory implements IManaReceiver, I @Override public boolean receiveClientEvent(int event, int param) { - if(event == CRAFT_EFFECT_EVENT) { - if(world.isRemote) { - for(int i = 0; i < 25; i++) { + if (event == CRAFT_EFFECT_EVENT) { + if (world.isRemote) { + for (int i = 0; i < 25; i++) { float r = (param >> 16 & 0xFF) / 255F; float g = (param >> 8 & 0xFF) / 255F; float b = (param & 0xFF) / 255F; - SparkleParticleData data1 = SparkleParticleData.sparkle((float) Math.random() * 2F + 0.5F, r, g, b, 10); - world.addParticle(data1, pos.getX() + 0.5 + Math.random() * 0.4 - 0.2, pos.getY() + 1, pos.getZ() + 0.5 + Math.random() * 0.4 - 0.2, 0, 0, 0); - for(int j = 0; j < 2; j++) { - WispParticleData data = WispParticleData.wisp(0.1F + (float) Math.random() * 0.2F, 0.2F, 0.2F, 0.2F); - world.addParticle(data, pos.getX() + 0.7 - Math.random() * 0.4, pos.getY() + 0.9 - Math.random() * 0.2, pos.getZ() + 0.7 - Math.random() * 0.4, 0.05F - (float) Math.random() * 0.1F, 0.05F + (float) Math.random() * 0.03F, 0.05F - (float) Math.random() * 0.1F); - } + SparkleParticleData data1 = SparkleParticleData.sparkle((float) Math.random() * 2F + 0.5F, r, g, b, 10); + world.addParticle(data1, pos.getX() + 0.5 + Math.random() * 0.4 - 0.2, pos.getY() + 1, pos.getZ() + 0.5 + Math.random() * 0.4 - 0.2, 0, 0, 0); + for (int j = 0; j < 2; j++) { + WispParticleData data = WispParticleData.wisp(0.1F + (float) Math.random() * 0.2F, 0.2F, 0.2F, 0.2F); + world.addParticle(data, pos.getX() + 0.7 - Math.random() * 0.4, pos.getY() + 0.9 - Math.random() * 0.2, pos.getZ() + 0.7 - Math.random() * 0.4, 0.05F - (float) Math.random() * 0.1F, 0.05F + (float) Math.random() * 0.03F, 0.05F - (float) Math.random() * 0.1F); + } } world.playSound(pos.getX(), pos.getY(), pos.getZ(), ModSounds.potionCreate, SoundCategory.BLOCKS, 1F, 1.5F + (float) Math.random() * 0.25F, false); } @@ -190,8 +197,9 @@ public class TileBrewery extends TileSimpleInventory implements IManaReceiver, I public int getManaCost() { ItemStack stack = itemHandler.getStackInSlot(0); - if(recipe == null || stack.isEmpty() || !(stack.getItem() instanceof IBrewContainer)) + if (recipe == null || stack.isEmpty() || !(stack.getItem() instanceof IBrewContainer)) { return 0; + } IBrewContainer container = (IBrewContainer) stack.getItem(); return container.getManaCost(recipe.getBrew(), stack); } @@ -253,12 +261,13 @@ public class TileBrewery extends TileSimpleInventory implements IManaReceiver, I public void renderHUD(Minecraft mc) { int manaToGet = getManaCost(); - if(manaToGet > 0) { + if (manaToGet > 0) { int x = mc.getWindow().getScaledWidth() / 2 + 20; int y = mc.getWindow().getScaledHeight() / 2 - 8; - if(recipe == null) + if (recipe == null) { return; + } RenderHelper.renderProgressPie(x, y, (float) mana / (float) manaToGet, recipe.getOutput(itemHandler.getStackInSlot(0))); } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileCacophonium.java b/src/main/java/vazkii/botania/common/block/tile/TileCacophonium.java index 5cb9ab6df..a937cc7c6 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileCacophonium.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileCacophonium.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 23, 2015, 7:25:38 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -15,14 +13,14 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.SoundCategory; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.common.item.ItemCacophonium; import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; public class TileCacophonium extends TileMod { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.CACOPHONIUM) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.CACOPHONIUM) public static TileEntityType TYPE; private static final String TAG_STACK = "stack"; public ItemStack stack = ItemStack.EMPTY; @@ -40,8 +38,9 @@ public class TileCacophonium extends TileMod { super.writePacketNBT(cmp); CompoundNBT cmp1 = new CompoundNBT(); - if(!stack.isEmpty()) + if (!stack.isEmpty()) { cmp1 = stack.write(cmp1); + } cmp.put(TAG_STACK, cmp1); } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileCell.java b/src/main/java/vazkii/botania/common/block/tile/TileCell.java index cea5e580c..5f016583f 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileCell.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileCell.java @@ -1,28 +1,25 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 6, 2015, 4:07:16 PM (GMT)] */ package vazkii.botania.common.block.tile; import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.BlockPos; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.common.block.subtile.generating.SubTileDandelifeon; import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; public class TileCell extends TileMod { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.CELL_BLOCK) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.CELL_BLOCK) public static TileEntityType TYPE; private static final String TAG_GENERATION = "generation"; private static final String TAG_TICKED = "ticked"; private static final String TAG_FLOWER_X = "flowerX"; @@ -43,12 +40,13 @@ public class TileCell extends TileMod { public void setGeneration(SubTileDandelifeon flower, int gen) { generation = gen; - if(!ticked) { + if (!ticked) { flowerCoords = flower.getEffectivePos(); validCoords = getPos(); ticked = true; - } else if(!validCoords.equals(getPos()) || !flowerCoords.equals(flower.getEffectivePos())) + } else if (!validCoords.equals(getPos()) || !flowerCoords.equals(flower.getEffectivePos())) { world.removeBlock(pos, false); + } } public boolean isSameFlower(SubTileDandelifeon flower) { @@ -63,7 +61,7 @@ public class TileCell extends TileMod { public void writePacketNBT(CompoundNBT cmp) { cmp.putInt(TAG_GENERATION, generation); cmp.putBoolean(TAG_TICKED, ticked); - if(ticked) { + if (ticked) { cmp.putInt(TAG_FLOWER_X, flowerCoords.getX()); cmp.putInt(TAG_FLOWER_Y, flowerCoords.getY()); cmp.putInt(TAG_FLOWER_Z, flowerCoords.getZ()); @@ -77,17 +75,17 @@ public class TileCell extends TileMod { public void readPacketNBT(CompoundNBT cmp) { generation = cmp.getInt(TAG_GENERATION); ticked = cmp.getBoolean(TAG_TICKED); - if(ticked) { + if (ticked) { flowerCoords = new BlockPos( cmp.getInt(TAG_FLOWER_X), cmp.getInt(TAG_FLOWER_Y), cmp.getInt(TAG_FLOWER_Z) - ); + ); validCoords = new BlockPos( cmp.getInt(TAG_VALID_X), cmp.getInt(TAG_VALID_Y), cmp.getInt(TAG_VALID_Z) - ); + ); } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileCocoon.java b/src/main/java/vazkii/botania/common/block/tile/TileCocoon.java index eb3205e27..4e92c5436 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileCocoon.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileCocoon.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 8, 2015, 4:32:34 PM (GMT)] */ package vazkii.botania.common.block.tile; import com.google.common.collect.ImmutableList; + import net.minecraft.block.Blocks; import net.minecraft.entity.AgeableEntity; import net.minecraft.entity.EntityType; @@ -24,16 +23,16 @@ import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; import java.util.ArrayList; import java.util.List; -public class TileCocoon extends TileMod implements ITickableTileEntity{ +public class TileCocoon extends TileMod implements ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.COCOON) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.COCOON) public static TileEntityType TYPE; private static final String TAG_TIME_PASSED = "timePassed"; private static final String TAG_EMERALDS_GIVEN = "emeraldsGiven"; @@ -66,12 +65,13 @@ public class TileCocoon extends TileMod implements ITickableTileEntity{ @Override public void tick() { timePassed++; - if(timePassed >= TOTAL_TIME) + if (timePassed >= TOTAL_TIME) { hatch(); + } } private void hatch() { - if(!world.isRemote) { + if (!world.isRemote) { timePassed = 0; world.destroyBlock(pos, false); @@ -92,11 +92,11 @@ public class TileCocoon extends TileMod implements ITickableTileEntity{ } } - if(Math.random() < shulkerChance) { + if (Math.random() < shulkerChance) { entity = EntityType.SHULKER.create(world); - } else if(Math.random() < villagerChance) { + } else if (Math.random() < villagerChance) { VillagerEntity villager = EntityType.VILLAGER.create(world); - if(villager != null) { + if (villager != null) { IVillagerType type = IVillagerType.byBiome(world.getBiome(pos)); villager.setVillagerData(villager.getVillagerData().withType(type)); } @@ -109,20 +109,22 @@ public class TileCocoon extends TileMod implements ITickableTileEntity{ entity = AQUATIC.get(world.rand.nextInt(AQUATIC.size())).create(world); } } else { - if(Math.random() < SPECIAL_CHANCE) { + if (Math.random() < SPECIAL_CHANCE) { entity = SPECIALS.get(world.rand.nextInt(SPECIALS.size())).create(world); } else { EntityType type = NORMALS.get(world.rand.nextInt(NORMALS.size())); - if (type == EntityType.COW && Math.random() < 0.01) + if (type == EntityType.COW && Math.random() < 0.01) { type = EntityType.MOOSHROOM; + } entity = type.create(world); } } - if(entity != null) { + if (entity != null) { entity.setPosition(placePos.getX() + 0.5, placePos.getY() + 0.5, placePos.getZ() + 0.5); - if(entity instanceof AgeableEntity) + if (entity instanceof AgeableEntity) { ((AgeableEntity) entity).setGrowingAge(-24000); + } entity.onInitialSpawn(world, world.getDifficultyForLocation(getPos()), SpawnReason.EVENT, null, null); entity.enablePersistence(); world.addEntity(entity); diff --git a/src/main/java/vazkii/botania/common/block/tile/TileCraftCrate.java b/src/main/java/vazkii/botania/common/block/tile/TileCraftCrate.java index 2b3ca0fdb..505b3dc4a 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileCraftCrate.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileCraftCrate.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 26, 2014, 4:50:20 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -21,6 +19,7 @@ import net.minecraft.item.crafting.IRecipeType; import net.minecraft.tileentity.TileEntityType; import net.minecraft.world.World; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.api.state.enums.CratePattern; @@ -30,12 +29,12 @@ import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.List; import java.util.Optional; public class TileCraftCrate extends TileOpenCrate { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.CRAFT_CRATE) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.CRAFT_CRATE) public static TileEntityType TYPE; private static final String TAG_PATTERN = "pattern"; private int signal = 0; @@ -60,17 +59,20 @@ public class TileCraftCrate extends TileOpenCrate { @Nonnull @Override public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { - if(slot != 9 && !isLocked(slot)) + if (slot != 9 && !isLocked(slot)) { return super.insertItem(slot, stack, simulate); - else return stack; + } else { + return stack; + } } }; } public CratePattern getPattern() { BlockState state = getBlockState(); - if(state.getBlock() != ModBlocks.craftCrate) + if (state.getBlock() != ModBlocks.craftCrate) { return CratePattern.NONE; + } return state.get(BotaniaStateProps.CRATE_PATTERN); } @@ -80,26 +82,32 @@ public class TileCraftCrate extends TileOpenCrate { @Override public void tick() { - if (world.isRemote) + if (world.isRemote) { return; + } - if(canEject() && isFull() && craft(true)) + if (canEject() && isFull() && craft(true)) { ejectAll(); + } int newSignal = 0; - for(; newSignal < 9; newSignal++) // dis for loop be derpy - if(!isLocked(newSignal) && itemHandler.getStackInSlot(newSignal).isEmpty()) + for (; newSignal < 9; newSignal++) // dis for loop be derpy + { + if (!isLocked(newSignal) && itemHandler.getStackInSlot(newSignal).isEmpty()) { break; + } + } - if(newSignal != signal) { + if (newSignal != signal) { signal = newSignal; world.updateComparatorOutputLevel(pos, getBlockState().getBlock()); } } private boolean craft(boolean fullCheck) { - if(fullCheck && !isFull()) + if (fullCheck && !isFull()) { return false; + } CraftingInventory craft = new CraftingInventory(new Container(ContainerType.CRAFTING, -1) { @Override @@ -107,11 +115,12 @@ public class TileCraftCrate extends TileOpenCrate { return false; } }, 3, 3); - for(int i = 0; i < craft.getSizeInventory(); i++) { + for (int i = 0; i < craft.getSizeInventory(); i++) { ItemStack stack = itemHandler.getStackInSlot(i); - if(stack.isEmpty() || isLocked(i) || stack.getItem() == ModItems.placeholder) + if (stack.isEmpty() || isLocked(i) || stack.getItem() == ModItems.placeholder) { continue; + } craft.setInventorySlotContents(i, stack); } @@ -121,11 +130,12 @@ public class TileCraftCrate extends TileOpenCrate { itemHandler.setStackInSlot(9, recipe.getCraftingResult(craft)); List remainders = recipe.getRemainingItems(craft); - for(int i = 0; i < craft.getSizeInventory(); i++) { + for (int i = 0; i < craft.getSizeInventory(); i++) { ItemStack s = remainders.get(i); - if(!itemHandler.getStackInSlot(i).isEmpty() - && itemHandler.getStackInSlot(i).getItem() == ModItems.placeholder) + if (!itemHandler.getStackInSlot(i).isEmpty() + && itemHandler.getStackInSlot(i).getItem() == ModItems.placeholder) { continue; + } itemHandler.setStackInSlot(i, s); } }); @@ -134,18 +144,21 @@ public class TileCraftCrate extends TileOpenCrate { } boolean isFull() { - for(int i = 0; i < 9; i++) - if(!isLocked(i) && itemHandler.getStackInSlot(i).isEmpty()) + for (int i = 0; i < 9; i++) { + if (!isLocked(i) && itemHandler.getStackInSlot(i).isEmpty()) { return false; + } + } return true; } private void ejectAll() { - for(int i = 0; i < getSizeInventory(); ++i) { + for (int i = 0; i < getSizeInventory(); ++i) { ItemStack stack = itemHandler.getStackInSlot(i); - if(!stack.isEmpty()) + if (!stack.isEmpty()) { eject(stack, false); + } itemHandler.setStackInSlot(i, ItemStack.EMPTY); } markDirty(); @@ -153,7 +166,7 @@ public class TileCraftCrate extends TileOpenCrate { @Override public boolean onWanded(World world, PlayerEntity player, ItemStack stack) { - if(!world.isRemote && canEject()) { + if (!world.isRemote && canEject()) { craft(false); ejectAll(); } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileEnchanter.java b/src/main/java/vazkii/botania/common/block/tile/TileEnchanter.java index b0673a2a7..452e4d12d 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileEnchanter.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileEnchanter.java @@ -1,17 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 15, 2014, 4:57:52 PM (GMT)] */ package vazkii.botania.common.block.tile; import com.google.common.base.Predicates; -import net.minecraft.block.Block; + import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.client.Minecraft; @@ -40,7 +38,7 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ObjectHolder; -import vazkii.botania.api.BotaniaAPI; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.mana.IManaPool; import vazkii.botania.api.mana.spark.ISparkAttachable; @@ -62,6 +60,7 @@ import vazkii.patchouli.common.multiblock.StateMatcher; import javax.annotation.Nonnull; import javax.annotation.Nullable; + import java.util.ArrayList; import java.util.EnumMap; import java.util.List; @@ -70,8 +69,7 @@ import java.util.stream.Collectors; public class TileEnchanter extends TileMod implements ISparkAttachable, ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.ENCHANTER) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.ENCHANTER) public static TileEntityType TYPE; private static final String TAG_STAGE = "stage"; private static final String TAG_STAGE_TICKS = "stageTicks"; private static final String TAG_STAGE_3_END_TICKS = "stage3EndTicks"; @@ -143,8 +141,8 @@ public class TileEnchanter extends TileMod implements ISparkAttachable, ITickabl private static final Map PYLON_LOCATIONS = new EnumMap<>(Direction.Axis.class); static { - PYLON_LOCATIONS.put(Direction.Axis.X, new BlockPos[] { new BlockPos(-5, 1, 0), new BlockPos(5, 1, 0), new BlockPos(-4, 1, 3), new BlockPos(4, 1, 3), new BlockPos(-4, 1, -3 ), new BlockPos(4, 1, -3) }); - PYLON_LOCATIONS.put(Direction.Axis.Z, new BlockPos[] { new BlockPos(0, 1, -5), new BlockPos(0, 1, 5), new BlockPos(3, 1, -4), new BlockPos(3, 1, 4), new BlockPos(-3, 1, -4 ), new BlockPos(-3, 1, 4) }); + PYLON_LOCATIONS.put(Direction.Axis.X, new BlockPos[] { new BlockPos(-5, 1, 0), new BlockPos(5, 1, 0), new BlockPos(-4, 1, 3), new BlockPos(4, 1, 3), new BlockPos(-4, 1, -3), new BlockPos(4, 1, -3) }); + PYLON_LOCATIONS.put(Direction.Axis.Z, new BlockPos[] { new BlockPos(0, 1, -5), new BlockPos(0, 1, 5), new BlockPos(3, 1, -4), new BlockPos(3, 1, 4), new BlockPos(-3, 1, -4), new BlockPos(-3, 1, 4) }); } public TileEnchanter() { @@ -152,20 +150,21 @@ public class TileEnchanter extends TileMod implements ISparkAttachable, ITickabl } public void onWanded(PlayerEntity player, ItemStack wand) { - if(stage != State.IDLE || itemToEnchant.isEmpty() || !itemToEnchant.isEnchantable()) + if (stage != State.IDLE || itemToEnchant.isEmpty() || !itemToEnchant.isEnchantable()) { return; + } List items = world.getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(pos.getX() - 2, pos.getY(), pos.getZ() - 2, pos.getX() + 3, pos.getY() + 1, pos.getZ() + 3)); int count = items.size(); - if(count > 0 && !world.isRemote) { - for(ItemEntity entity : items) { + if (count > 0 && !world.isRemote) { + for (ItemEntity entity : items) { ItemStack item = entity.getItem(); - if(item.getItem() == Items.ENCHANTED_BOOK) { + if (item.getItem() == Items.ENCHANTED_BOOK) { Map enchants = EnchantmentHelper.getEnchantments(item); - if(enchants.size() > 0) { + if (enchants.size() > 0) { Enchantment enchant = enchants.keySet().iterator().next(); - if(isEnchantmentValid(enchant)) { + if (isEnchantmentValid(enchant)) { advanceStage(); return; } @@ -176,19 +175,19 @@ public class TileEnchanter extends TileMod implements ISparkAttachable, ITickabl } private void gatherEnchants() { - if(!world.isRemote && stageTicks % 20 == 0) { + if (!world.isRemote && stageTicks % 20 == 0) { List items = world.getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(pos.getX() - 2, pos.getY(), pos.getZ() - 2, pos.getX() + 3, pos.getY() + 1, pos.getZ() + 3)); boolean addedEnch = false; - for(ItemEntity entity : items) { + for (ItemEntity entity : items) { ItemStack item = entity.getItem(); - if(item.getItem() == Items.ENCHANTED_BOOK) { + if (item.getItem() == Items.ENCHANTED_BOOK) { Map enchants = EnchantmentHelper.getEnchantments(item); - if(enchants.size() > 0) { + if (enchants.size() > 0) { Map.Entry e = enchants.entrySet().iterator().next(); Enchantment ench = e.getKey(); int enchantLvl = e.getValue(); - if(!hasEnchantAlready(ench) && isEnchantmentValid(ench)) { + if (!hasEnchantAlready(ench) && isEnchantmentValid(ench)) { this.enchants.add(new EnchantmentData(ench, enchantLvl)); world.playSound(null, pos, ModSounds.ding, SoundCategory.BLOCKS, 1F, 1F); addedEnch = true; @@ -198,44 +197,47 @@ public class TileEnchanter extends TileMod implements ISparkAttachable, ITickabl } } - if(!addedEnch) { - if(enchants.isEmpty()) + if (!addedEnch) { + if (enchants.isEmpty()) { stage = State.IDLE; - else advanceStage(); + } else { + advanceStage(); + } } } } private void gatherMana(Direction.Axis axis) { - if(manaRequired == -1) { + if (manaRequired == -1) { manaRequired = 0; - for(EnchantmentData data : enchants) { - manaRequired += (int) - (5000F * ((15 - Math.min(15, data.enchantment.getRarity().getWeight())) - * 1.05F) - * ((3F + data.enchantmentLevel * data.enchantmentLevel) - * 0.25F) - * (0.9F + enchants.size() * 0.05F) - * (data.enchantment.isTreasureEnchantment() ? 1.25F : 1F)); + for (EnchantmentData data : enchants) { + manaRequired += (int) (5000F * ((15 - Math.min(15, data.enchantment.getRarity().getWeight())) + * 1.05F) + * ((3F + data.enchantmentLevel * data.enchantmentLevel) + * 0.25F) + * (0.9F + enchants.size() * 0.05F) + * (data.enchantment.isTreasureEnchantment() ? 1.25F : 1F)); } - } else if(mana >= manaRequired) { + } else if (mana >= manaRequired) { manaRequired = 0; - for(BlockPos pylon : PYLON_LOCATIONS.get(axis)) { + for (BlockPos pylon : PYLON_LOCATIONS.get(axis)) { TileEntity te = world.getTileEntity(pos.add(pylon)); - if(te instanceof TilePylon) + if (te instanceof TilePylon) { ((TilePylon) te).activated = false; + } } advanceStage(); } else { ISparkEntity spark = getAttachedSpark(); - if(spark != null) { + if (spark != null) { SparkHelper.getSparksAround(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, spark.getNetwork()) .filter(otherSpark -> spark != otherSpark && otherSpark.getAttachedTile() instanceof IManaPool) .forEach(os -> os.registerTransfer(spark)); } - if(stageTicks % 5 == 0) + if (stageTicks % 5 == 0) { sync(); + } } } @@ -244,36 +246,45 @@ public class TileEnchanter extends TileMod implements ISparkAttachable, ITickabl BlockState state = getBlockState(); Direction.Axis axis = state.get(BotaniaStateProps.ENCHANTER_DIRECTION); - for(BlockPos pylon : PYLON_LOCATIONS.get(axis)) { + for (BlockPos pylon : PYLON_LOCATIONS.get(axis)) { TileEntity tile = world.getTileEntity(pos.add(pylon)); - if(tile instanceof TilePylon) { + if (tile instanceof TilePylon) { ((TilePylon) tile).activated = stage == State.GATHER_MANA; - if(stage == State.GATHER_MANA) + if (stage == State.GATHER_MANA) { ((TilePylon) tile).centerPos = pos; + } } } - if(stage != State.IDLE) + if (stage != State.IDLE) { stageTicks++; + } - if(world.isRemote) + if (world.isRemote) { return; + } - if(FORMED_MULTIBLOCK.getValue().validate(world, pos.down()) == null) { + if (FORMED_MULTIBLOCK.getValue().validate(world, pos.down()) == null) { world.setBlockState(pos, Blocks.LAPIS_BLOCK.getDefaultState()); PacketHandler.sendToNearby(world, pos, new PacketBotaniaEffect(PacketBotaniaEffect.EffectType.ENCHANTER_DESTROY, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5)); world.playSound(null, pos, ModSounds.enchanterFade, SoundCategory.BLOCKS, 0.5F, 10F); } - switch(stage) { - case GATHER_ENCHANTS : gatherEnchants(); break; - case GATHER_MANA : gatherMana(axis); break; - case DO_ENCHANT : { // Enchant - if(stageTicks >= 100) { - for(EnchantmentData data : enchants) - if(EnchantmentHelper.getEnchantmentLevel(data.enchantment, itemToEnchant) == 0) + switch (stage) { + case GATHER_ENCHANTS: + gatherEnchants(); + break; + case GATHER_MANA: + gatherMana(axis); + break; + case DO_ENCHANT: { // Enchant + if (stageTicks >= 100) { + for (EnchantmentData data : enchants) { + if (EnchantmentHelper.getEnchantmentLevel(data.enchantment, itemToEnchant) == 0) { itemToEnchant.addEnchantment(data.enchantment, data.enchantmentLevel); + } + } enchants.clear(); manaRequired = -1; @@ -285,20 +296,28 @@ public class TileEnchanter extends TileMod implements ISparkAttachable, ITickabl break; } case RESET: { // Reset - if(stageTicks >= 20) + if (stageTicks >= 20) { advanceStage(); + } break; } - default: break; + default: + break; } } private void advanceStage() { - switch(stage) { - case IDLE: stage = State.GATHER_ENCHANTS; break; - case GATHER_ENCHANTS: stage = State.GATHER_MANA; break; - case GATHER_MANA: stage = State.DO_ENCHANT; break; + switch (stage) { + case IDLE: + stage = State.GATHER_ENCHANTS; + break; + case GATHER_ENCHANTS: + stage = State.GATHER_MANA; + break; + case GATHER_MANA: + stage = State.DO_ENCHANT; + break; case DO_ENCHANT: { stage = State.RESET; stage3EndTicks = stageTicks; @@ -317,21 +336,22 @@ public class TileEnchanter extends TileMod implements ISparkAttachable, ITickabl @Override public boolean receiveClientEvent(int event, int param) { - switch(event) { - case CRAFT_EFFECT_EVENT: { - if(world.isRemote) { - for(int i = 0; i < 25; i++) { - float red = (float) Math.random(); - float green = (float) Math.random(); - float blue = (float) Math.random(); - SparkleParticleData data = SparkleParticleData.sparkle((float) Math.random(), red, green, blue, 10); - world.addParticle(data, getPos().getX() + Math.random() * 0.4 - 0.2, getPos().getY(), getPos().getZ() + Math.random() * 0.4 - 0.2, 0, 0, 0); - } - world.playSound(pos.getX(), pos.getY(), pos.getZ(), ModSounds.enchanterEnchant, SoundCategory.BLOCKS, 1F, 1F, false); + switch (event) { + case CRAFT_EFFECT_EVENT: { + if (world.isRemote) { + for (int i = 0; i < 25; i++) { + float red = (float) Math.random(); + float green = (float) Math.random(); + float blue = (float) Math.random(); + SparkleParticleData data = SparkleParticleData.sparkle((float) Math.random(), red, green, blue, 10); + world.addParticle(data, getPos().getX() + Math.random() * 0.4 - 0.2, getPos().getY(), getPos().getZ() + Math.random() * 0.4 - 0.2, 0, 0, 0); } - return true; + world.playSound(pos.getX(), pos.getY(), pos.getZ(), ModSounds.enchanterEnchant, SoundCategory.BLOCKS, 1F, 1F, false); } - default: return super.receiveClientEvent(event, param); + return true; + } + default: + return super.receiveClientEvent(event, param); } } @@ -374,8 +394,9 @@ public class TileEnchanter extends TileMod implements ISparkAttachable, ITickabl cmp.putInt(TAG_STAGE_3_END_TICKS, stage3EndTicks); CompoundNBT itemCmp = new CompoundNBT(); - if(!itemToEnchant.isEmpty()) + if (!itemToEnchant.isEmpty()) { cmp.put(TAG_ITEM, itemToEnchant.write(itemCmp)); + } String enchStr = enchants.stream() .map(e -> ForgeRegistries.ENCHANTMENTS.getKey(e.enchantment) + "=" + e.enchantmentLevel) @@ -396,36 +417,41 @@ public class TileEnchanter extends TileMod implements ISparkAttachable, ITickabl enchants.clear(); String enchStr = cmp.getString(TAG_ENCHANTS); - if(!enchStr.isEmpty()) { + if (!enchStr.isEmpty()) { String[] enchTokens = enchStr.split(","); - for(String token : enchTokens) { + for (String token : enchTokens) { try { String[] entryTokens = token.split("="); Enchantment ench = ForgeRegistries.ENCHANTMENTS.getValue(new ResourceLocation(entryTokens[0])); int lvl = Integer.parseInt(entryTokens[1]); - if(ench != null) + if (ench != null) { enchants.add(new EnchantmentData(ench, lvl)); + } } catch (ResourceLocationException ignored) {} } } } private boolean hasEnchantAlready(Enchantment enchant) { - for(EnchantmentData data : enchants) - if(data.enchantment == enchant) + for (EnchantmentData data : enchants) { + if (data.enchantment == enchant) { return true; + } + } return false; } private boolean isEnchantmentValid(@Nullable Enchantment ench) { - if(ench == null || !ench.canApply(itemToEnchant)) + if (ench == null || !ench.canApply(itemToEnchant)) { return false; + } - for(EnchantmentData data : enchants) { + for (EnchantmentData data : enchants) { Enchantment otherEnch = data.enchantment; - if (!ench.isCompatibleWith(otherEnch)) + if (!ench.isCompatibleWith(otherEnch)) { return false; + } } return true; @@ -434,15 +460,18 @@ public class TileEnchanter extends TileMod implements ISparkAttachable, ITickabl @Nullable public static Direction.Axis canEnchanterExist(World world, BlockPos pos) { Rotation rot = MULTIBLOCK.getValue().validate(world, pos.down()); - if (rot == null) + if (rot == null) { return null; + } switch (rot) { - default: - case NONE: - case CLOCKWISE_180: return Direction.Axis.Z; - case CLOCKWISE_90: - case COUNTERCLOCKWISE_90: return Direction.Axis.X; + default: + case NONE: + case CLOCKWISE_180: + return Direction.Axis.Z; + case CLOCKWISE_90: + case COUNTERCLOCKWISE_90: + return Direction.Axis.X; } } @@ -457,7 +486,7 @@ public class TileEnchanter extends TileMod implements ISparkAttachable, ITickabl @Override public ISparkEntity getAttachedSpark() { List sparks = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos.getX(), pos.getY() + 1, pos.getZ(), pos.getX() + 1, pos.getY() + 2, pos.getZ() + 1), Predicates.instanceOf(ISparkEntity.class)); - if(sparks.size() == 1) { + if (sparks.size() == 1) { Entity e = sparks.get(0); return (ISparkEntity) e; } @@ -477,7 +506,7 @@ public class TileEnchanter extends TileMod implements ISparkAttachable, ITickabl @OnlyIn(Dist.CLIENT) public void renderHUD() { - if(manaRequired > 0 && !itemToEnchant.isEmpty()) { + if (manaRequired > 0 && !itemToEnchant.isEmpty()) { int x = Minecraft.getInstance().getWindow().getScaledWidth() / 2 + 20; int y = Minecraft.getInstance().getWindow().getScaledHeight() / 2 - 8; diff --git a/src/main/java/vazkii/botania/common/block/tile/TileEnderEye.java b/src/main/java/vazkii/botania/common/block/tile/TileEnderEye.java index 0ba788d83..b57a5a828 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileEnderEye.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileEnderEye.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 30, 2014, 1:10:34 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -19,9 +17,9 @@ import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceContext; import net.minecraft.util.math.RayTraceResult; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.lib.LibBlockNames; @@ -30,8 +28,7 @@ import vazkii.botania.common.lib.LibMisc; import java.util.List; public class TileEnderEye extends TileMod implements ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.ENDER_EYE_BLOCK) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.ENDER_EYE_BLOCK) public static TileEntityType TYPE; public TileEnderEye() { super(TYPE); @@ -39,28 +36,31 @@ public class TileEnderEye extends TileMod implements ITickableTileEntity { @Override public void tick() { - if (world.isRemote) + if (world.isRemote) { return; + } boolean wasLooking = getBlockState().get(BotaniaStateProps.POWERED); int range = 80; List players = world.getEntitiesWithinAABB(PlayerEntity.class, new AxisAlignedBB(pos.add(-range, -range, -range), pos.add(range, range, range))); boolean looking = false; - for(PlayerEntity player : players) { + for (PlayerEntity player : players) { ItemStack helm = player.getItemStackFromSlot(EquipmentSlotType.HEAD); - if(!helm.isEmpty() && helm.getItem() == Item.getItemFromBlock(Blocks.PUMPKIN)) + if (!helm.isEmpty() && helm.getItem() == Item.getItemFromBlock(Blocks.PUMPKIN)) { continue; + } BlockRayTraceResult hit = ToolCommons.raytraceFromEntity(player, 64, false); - if(hit.getType() == RayTraceResult.Type.BLOCK && hit.getPos().equals(getPos())) { + if (hit.getType() == RayTraceResult.Type.BLOCK && hit.getPos().equals(getPos())) { looking = true; break; } } - if(looking != wasLooking) + if (looking != wasLooking) { world.setBlockState(getPos(), getBlockState().with(BotaniaStateProps.POWERED, looking)); + } } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileFakeAir.java b/src/main/java/vazkii/botania/common/block/tile/TileFakeAir.java index 7b15aa3bb..d11a75007 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileFakeAir.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileFakeAir.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 10, 2015, 10:24:48 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -15,6 +13,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.BlockPos; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.common.block.subtile.functional.SubTileBubbell; import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; @@ -23,8 +22,7 @@ import javax.annotation.Nonnull; public class TileFakeAir extends TileMod { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.FAKE_AIR) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.FAKE_AIR) public static TileEntityType TYPE; private static final String TAG_FLOWER_X = "flowerX"; private static final String TAG_FLOWER_Y = "flowerY"; private static final String TAG_FLOWER_Z = "flowerZ"; @@ -61,7 +59,7 @@ public class TileFakeAir extends TileMod { tag.getInt(TAG_FLOWER_X), tag.getInt(TAG_FLOWER_Y), tag.getInt(TAG_FLOWER_Z) - ); + ); } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileFloatingFlower.java b/src/main/java/vazkii/botania/common/block/tile/TileFloatingFlower.java index 296b5e302..dc876ab4f 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileFloatingFlower.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileFloatingFlower.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 8, 2014, 10:17:28 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -23,6 +21,7 @@ import net.minecraftforge.client.model.data.ModelDataMap; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.capability.FloatingFlowerImpl; import vazkii.botania.api.item.IFloatingFlower; @@ -36,15 +35,14 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class TileFloatingFlower extends TileMod { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.MINI_ISLAND) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.MINI_ISLAND) public static TileEntityType TYPE; private static final String TAG_FLOATING_DATA = "floating"; private final IFloatingFlower floatingData = new FloatingFlowerImpl() { @Override public ItemStack getDisplayStack() { Block b = getBlockState().getBlock(); - if(b instanceof BlockFloatingFlower) { + if (b instanceof BlockFloatingFlower) { return new ItemStack(ModBlocks.getShinyFlower(((BlockFloatingFlower) b).color)); } else { return ItemStack.EMPTY; @@ -60,7 +58,7 @@ public class TileFloatingFlower extends TileMod { @Nonnull @Override public LazyOptional getCapability(@Nonnull Capability cap, @Nullable Direction side) { - if(cap == BotaniaAPI.FLOATING_FLOWER_CAP) { + if (cap == BotaniaAPI.FLOATING_FLOWER_CAP) { return floatingDataCap.cast(); } return super.getCapability(cap, side); @@ -70,7 +68,7 @@ public class TileFloatingFlower extends TileMod { public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket packet) { IFloatingFlower.IslandType oldType = floatingData.getIslandType(); super.onDataPacket(net, packet); - if(oldType != floatingData.getIslandType()) { + if (oldType != floatingData.getIslandType()) { ModelDataManager.requestModelDataRefresh(this); world.notifyBlockUpdate(getPos(), getBlockState(), getBlockState(), 0); } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileForestEye.java b/src/main/java/vazkii/botania/common/block/tile/TileForestEye.java index ac7fa623a..ff456305a 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileForestEye.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileForestEye.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 10, 2014, 5:50:01 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -15,12 +13,12 @@ import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; public class TileForestEye extends TileMod implements ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.FOREST_EYE) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.FOREST_EYE) public static TileEntityType TYPE; public int entities = 0; @@ -30,11 +28,12 @@ public class TileForestEye extends TileMod implements ITickableTileEntity { @Override public void tick() { - if (world.isRemote) + if (world.isRemote) { return; + } int range = 6; int entityCount = world.getEntitiesWithinAABB(AnimalEntity.class, new AxisAlignedBB(pos.add(-range, -range, -range), pos.add(range + 1, range + 1, range + 1))).size(); - if(entityCount != entities) { + if (entityCount != entities) { entities = entityCount; world.updateComparatorOutputLevel(pos, getBlockState().getBlock()); } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileGaiaHead.java b/src/main/java/vazkii/botania/common/block/tile/TileGaiaHead.java index 6f48c214b..5286bb165 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileGaiaHead.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileGaiaHead.java @@ -1,26 +1,24 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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, 2015, 11:47:40 PM (GMT)] */ package vazkii.botania.common.block.tile; import net.minecraft.tileentity.SkullTileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; public class TileGaiaHead extends SkullTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.GAIA_HEAD) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.GAIA_HEAD) public static TileEntityType TYPE; @Nonnull @Override diff --git a/src/main/java/vazkii/botania/common/block/tile/TileHourglass.java b/src/main/java/vazkii/botania/common/block/tile/TileHourglass.java index e4aaa440a..53024eea3 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileHourglass.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileHourglass.java @@ -1,20 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 29, 2015, 8:21:17 PM (GMT)] */ package vazkii.botania.common.block.tile; -import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; @@ -26,6 +22,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.item.IHourglassTrigger; import vazkii.botania.api.state.BotaniaStateProps; @@ -36,8 +33,7 @@ import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; public class TileHourglass extends TileSimpleInventory implements ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.HOURGLASS) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.HOURGLASS) public static TileEntityType TYPE; private static final String TAG_TIME = "time"; private static final String TAG_TIME_FRACTION = "timeFraction"; private static final String TAG_FLIP = "flip"; @@ -67,24 +63,26 @@ public class TileHourglass extends TileSimpleInventory implements ITickableTileE int totalTime = getTotalTime(); boolean dust = isDust(); - if(totalTime > 0 || dust) { - if(move && !dust) + if (totalTime > 0 || dust) { + if (move && !dust) { time++; + } - if(time >= totalTime) { + if (time >= totalTime) { time = 0; flip = !flip; flipTicks = 4; - if(!world.isRemote) { + if (!world.isRemote) { world.setBlockState(getPos(), getBlockState().with(BotaniaStateProps.POWERED, true), 1); world.getPendingBlockTicks().scheduleTick(pos, getBlockState().getBlock(), getBlockState().getBlock().tickRate(world)); } - for(Direction facing : Direction.values()) { + for (Direction facing : Direction.values()) { BlockPos pos = getPos().offset(facing); BlockState state = world.getBlockState(pos); - if(state.getBlock() instanceof IHourglassTrigger) + if (state.getBlock() instanceof IHourglassTrigger) { ((IHourglassTrigger) state.getBlock()).onTriggeredByHourglass(world, pos, this); + } } } @@ -96,53 +94,67 @@ public class TileHourglass extends TileSimpleInventory implements ITickableTileE timeFraction = 0F; } - if(flipTicks > 0) + if (flipTicks > 0) { flipTicks--; + } } public void onManaCollide() { - if(!world.isRemote) { - if(isDust()) + if (!world.isRemote) { + if (isDust()) { time++; - else move = !move; + } else { + move = !move; + } VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); } } public int getTotalTime() { ItemStack stack = itemHandler.getStackInSlot(0); - if(stack.isEmpty()) + if (stack.isEmpty()) { return 0; + } return getStackItemTime(stack) * stack.getCount(); } public static int getStackItemTime(ItemStack stack) { - if(stack.isEmpty()) + if (stack.isEmpty()) { return 0; - if(stack.getItem() == Blocks.SAND.asItem()) + } + if (stack.getItem() == Blocks.SAND.asItem()) { return 20; - if(stack.getItem() == Blocks.RED_SAND.asItem()) + } + if (stack.getItem() == Blocks.RED_SAND.asItem()) { return 200; - if(stack.getItem() == Blocks.SOUL_SAND.asItem()) + } + if (stack.getItem() == Blocks.SOUL_SAND.asItem()) { return 1200; - if(stack.getItem() == ModItems.manaPowder) + } + if (stack.getItem() == ModItems.manaPowder) { return 1; + } return 0; } public int getColor() { ItemStack stack = itemHandler.getStackInSlot(0); - if(stack.isEmpty()) + if (stack.isEmpty()) { return 0; - if(stack.getItem() == Blocks.SAND.asItem()) + } + if (stack.getItem() == Blocks.SAND.asItem()) { return 0xFFEC49; - if(stack.getItem() == Blocks.RED_SAND.asItem()) + } + if (stack.getItem() == Blocks.RED_SAND.asItem()) { return 0xE95800; - if(stack.getItem() == Blocks.SOUL_SAND.asItem()) + } + if (stack.getItem() == Blocks.SOUL_SAND.asItem()) { return 0x5A412f; - if(stack.getItem() == ModItems.manaPowder) + } + if (stack.getItem() == ModItems.manaPowder) { return 0x03abff; + } return 0; } @@ -153,18 +165,20 @@ public class TileHourglass extends TileSimpleInventory implements ITickableTileE @Nonnull @Override public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { - if(!stack.isEmpty() && (stack.getItem() == Blocks.SAND.asItem() + if (!stack.isEmpty() && (stack.getItem() == Blocks.SAND.asItem() || stack.getItem() == Blocks.RED_SAND.asItem() || stack.getItem() == Blocks.SOUL_SAND.asItem() - || stack.getItem() == ModItems.manaPowder)) + || stack.getItem() == ModItems.manaPowder)) { return super.insertItem(slot, stack, simulate); - else return stack; + } else { + return stack; + } } @Override public void onContentsChanged(int slot) { super.onContentsChanged(slot); - if(!TileHourglass.this.world.isRemote) { + if (!TileHourglass.this.world.isRemote) { time = 0; timeFraction = 0F; VanillaPacketDispatcher.dispatchTEToNearbyPlayers(TileHourglass.this); @@ -207,7 +221,7 @@ public class TileHourglass extends TileSimpleInventory implements ITickableTileE int y = mc.getWindow().getScaledHeight() / 2 - 10; ItemStack stack = itemHandler.getStackInSlot(0); - if(!stack.isEmpty()) { + if (!stack.isEmpty()) { mc.getItemRenderer().renderItemIntoGUI(stack, x, y); mc.getItemRenderer().renderItemOverlays(mc.fontRenderer, stack, x, y); @@ -216,12 +230,15 @@ public class TileHourglass extends TileSimpleInventory implements ITickableTileE mc.fontRenderer.drawStringWithShadow(timeStr, x + 20, y, getColor()); String status = ""; - if(lock) + if (lock) { status = "locked"; - if(!move) + } + if (!move) { status = status.isEmpty() ? "stopped" : "lockedStopped"; - if(!status.isEmpty()) + } + if (!status.isEmpty()) { mc.fontRenderer.drawStringWithShadow(I18n.format("botaniamisc." + status), x + 20, y + 12, getColor()); + } } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileIncensePlate.java b/src/main/java/vazkii/botania/common/block/tile/TileIncensePlate.java index 11b35aa01..a230d6f4b 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileIncensePlate.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileIncensePlate.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 15, 2015, 4:09:07 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -21,6 +19,7 @@ import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.brew.Brew; import vazkii.botania.api.internal.VanillaPacketDispatcher; @@ -31,12 +30,11 @@ import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; -import java.awt.*; + import java.util.List; public class TileIncensePlate extends TileSimpleInventory implements ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.INCENSE_PLATE) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.INCENSE_PLATE) public static TileEntityType TYPE; private static final String TAG_TIME_LEFT = "timeLeft"; private static final String TAG_BURNING = "burning"; private static final int RANGE = 32; @@ -52,24 +50,25 @@ public class TileIncensePlate extends TileSimpleInventory implements ITickableTi @Override public void tick() { ItemStack stack = itemHandler.getStackInSlot(0); - if(!stack.isEmpty() && burning) { + if (!stack.isEmpty() && burning) { Brew brew = ((ItemIncenseStick) ModItems.incenseStick).getBrew(stack); EffectInstance effect = brew.getPotionEffects(stack).get(0); - if(timeLeft > 0) { + if (timeLeft > 0) { timeLeft--; - if(!world.isRemote) { + if (!world.isRemote) { List players = world.getEntitiesWithinAABB(PlayerEntity.class, new AxisAlignedBB(pos.getX() + 0.5 - RANGE, pos.getY() + 0.5 - RANGE, pos.getZ() + 0.5 - RANGE, pos.getX() + 0.5 + RANGE, pos.getY() + 0.5 + RANGE, pos.getZ() + 0.5 + RANGE)); - for(PlayerEntity player : players) { + for (PlayerEntity player : players) { EffectInstance currentEffect = player.getActivePotionEffect(effect.getPotion()); boolean nightVision = effect.getPotion() == Effects.NIGHT_VISION; - if(currentEffect == null || currentEffect.getDuration() < (nightVision ? 205 : 3)) { + if (currentEffect == null || currentEffect.getDuration() < (nightVision ? 205 : 3)) { EffectInstance applyEffect = new EffectInstance(effect.getPotion(), nightVision ? 285 : 80, effect.getAmplifier(), true, true); player.addPotionEffect(applyEffect); } } - if(world.rand.nextInt(20) == 0) + if (world.rand.nextInt(20) == 0) { world.playSound(null, pos, SoundEvents.BLOCK_FIRE_AMBIENT, SoundCategory.BLOCKS, 0.1F, 1); + } } else { double x = pos.getX() + 0.5; double y = pos.getY() + 0.5; @@ -80,24 +79,28 @@ public class TileIncensePlate extends TileSimpleInventory implements ITickableTi float g = (color >> 8 & 0xFF) / 255F; float b = (color & 0xFF) / 255F; - WispParticleData data1 = WispParticleData.wisp(0.05F + (float) Math.random() * 0.02F, r, g, b); - world.addParticle(data1, x - (Math.random() - 0.5) * 0.2, y - (Math.random() - 0.5) * 0.2, z - (Math.random() - 0.5) * 0.2, 0.005F - (float) Math.random() * 0.01F, 0.01F + (float) Math.random() * 0.005F, 0.005F - (float) Math.random() * 0.01F); - WispParticleData data = WispParticleData.wisp(0.05F + (float) Math.random() * 0.02F, 0.2F, 0.2F, 0.2F); - world.addParticle(data, x - (Math.random() - 0.5) * 0.2, y - (Math.random() - 0.5) * 0.2, z - (Math.random() - 0.5) * 0.2, 0.005F - (float) Math.random() * 0.01F, 0.01F + (float) Math.random() * 0.001F, 0.005F - (float) Math.random() * 0.01F); - } + WispParticleData data1 = WispParticleData.wisp(0.05F + (float) Math.random() * 0.02F, r, g, b); + world.addParticle(data1, x - (Math.random() - 0.5) * 0.2, y - (Math.random() - 0.5) * 0.2, z - (Math.random() - 0.5) * 0.2, 0.005F - (float) Math.random() * 0.01F, 0.01F + (float) Math.random() * 0.005F, 0.005F - (float) Math.random() * 0.01F); + WispParticleData data = WispParticleData.wisp(0.05F + (float) Math.random() * 0.02F, 0.2F, 0.2F, 0.2F); + world.addParticle(data, x - (Math.random() - 0.5) * 0.2, y - (Math.random() - 0.5) * 0.2, z - (Math.random() - 0.5) * 0.2, 0.005F - (float) Math.random() * 0.01F, 0.01F + (float) Math.random() * 0.001F, 0.005F - (float) Math.random() * 0.01F); + } } else { itemHandler.setStackInSlot(0, ItemStack.EMPTY); burning = false; VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); } - } else timeLeft = 0; + } else { + timeLeft = 0; + } int newComparator = 0; - if(!stack.isEmpty()) + if (!stack.isEmpty()) { newComparator = 1; - if(burning) + } + if (burning) { newComparator = 2; - if(comparatorOutput != newComparator) { + } + if (comparatorOutput != newComparator) { comparatorOutput = newComparator; world.updateComparatorOutputLevel(pos, world.getBlockState(pos).getBlock()); } @@ -105,8 +108,9 @@ public class TileIncensePlate extends TileSimpleInventory implements ITickableTi public void ignite() { ItemStack stack = itemHandler.getStackInSlot(0); - if(stack.isEmpty() || burning) + if (stack.isEmpty() || burning) { return; + } burning = true; Brew brew = ((ItemIncenseStick) ModItems.incenseStick).getBrew(stack); @@ -142,9 +146,11 @@ public class TileIncensePlate extends TileSimpleInventory implements ITickableTi @Nonnull @Override public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { - if(acceptsItem(stack)) + if (acceptsItem(stack)) { return super.insertItem(slot, stack, simulate); - else return stack; + } else { + return stack; + } } @Nonnull @@ -158,8 +164,9 @@ public class TileIncensePlate extends TileSimpleInventory implements ITickableTi @Override public void markDirty() { super.markDirty(); - if(!world.isRemote) + if (!world.isRemote) { VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + } } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileLightRelay.java b/src/main/java/vazkii/botania/common/block/tile/TileLightRelay.java index 9538c04ec..4a8ea1208 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileLightRelay.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileLightRelay.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 15, 2015, 8:32:04 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -36,6 +34,7 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.api.wand.IWandBindable; import vazkii.botania.client.fx.SparkleParticleData; @@ -49,12 +48,12 @@ import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.ArrayList; import java.util.List; public class TileLightRelay extends TileMod implements ITickableTileEntity, IWandBindable { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.LIGHT_RELAY) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.LIGHT_RELAY) public static TileEntityType TYPE; private static final int MAX_DIST = 20; private static final String TAG_BIND_X = "bindX"; @@ -70,16 +69,17 @@ public class TileLightRelay extends TileMod implements ITickableTileEntity, IWan public void mountEntity(Entity e) { BlockPos nextDest = getNextDestination(); - if(e.isPassenger()|| world.isRemote || nextDest == null || !isValidBinding()) + if (e.isPassenger() || world.isRemote || nextDest == null || !isValidBinding()) { return; + } EntityPlayerMover mover = new EntityPlayerMover(world, pos, nextDest); world.addEntity(mover); e.startRiding(mover); - if(!(e instanceof ItemEntity)) { + if (!(e instanceof ItemEntity)) { mover.playSound(ModSounds.lightRelay, 0.2F, (float) Math.random() * 0.3F + 0.7F); } - if(e instanceof ServerPlayerEntity) { + if (e instanceof ServerPlayerEntity) { PlayerHelper.grantCriterion((ServerPlayerEntity) e, new ResourceLocation(LibMisc.MOD_ID, "main/luminizer_ride"), "code_triggered"); } } @@ -89,10 +89,10 @@ public class TileLightRelay extends TileMod implements ITickableTileEntity, IWan ticksElapsed++; BlockPos nextDest = getNextDestination(); - if(nextDest != null && nextDest.getY() > -1 && isValidBinding()) { - if(world.isRemote) { + if (nextDest != null && nextDest.getY() > -1 && isValidBinding()) { + if (world.isRemote) { Vector3 vec = getMovementVector(); - if(vec != null) { + if (vec != null) { double dist = 0.1; int size = (int) (vec.mag() / dist); int count = 10; @@ -106,7 +106,7 @@ public class TileLightRelay extends TileMod implements ITickableTileEntity, IWan float mulPer = 0.4F; float maxMul = 2; WispParticleData data = WispParticleData.wisp(0.1F, 0.4F, 0.4F, 1F, 1); - for(int i = start; i < start + count; i++) { + for (int i = start; i < start + count; i++) { mul = Math.min(maxMul, mul + mulPer); double rad = radPer * (i + ticksElapsed * 0.4); Vector3 vecRot = vecMag.crossProduct(Vector3.ONE).multiply(mul).rotate(rad, vecMag).add(vecTip); @@ -117,16 +117,16 @@ public class TileLightRelay extends TileMod implements ITickableTileEntity, IWan } else { BlockPos endpoint = getEndpoint(); - if(endpoint != null) { + if (endpoint != null) { AxisAlignedBB aabb = getBlockState().getShape(world, pos).getBoundingBox().offset(pos); float range = 0.5F; List enderPearls = world.getEntitiesWithinAABB(EnderPearlEntity.class, aabb.grow(range)); - for(EnderPearlEntity pearl : enderPearls) { + for (EnderPearlEntity pearl : enderPearls) { pearl.setPositionAndUpdate( endpoint.getX() + pearl.getX() - pos.getX(), endpoint.getY() + pearl.getY() - pos.getY(), endpoint.getZ() + pearl.getZ() - pos.getZ() - ); + ); } } } @@ -135,8 +135,9 @@ public class TileLightRelay extends TileMod implements ITickableTileEntity, IWan private boolean isValidBinding() { BlockPos nextDest = getNextDestination(); - if(nextDest == null) + if (nextDest == null) { return false; + } Block block = world.getBlockState(nextDest).getBlock(); return block instanceof BlockLightRelay; @@ -149,19 +150,23 @@ public class TileLightRelay extends TileMod implements ITickableTileEntity, IWan // Doing while(true) gives an unreachable code error boolean run = true; - while(run) { - if(pointsPassed.contains(relay)) + while (run) { + if (pointsPassed.contains(relay)) { return null; // Circular path + } pointsPassed.add(relay); BlockPos coords = relay.getNextDestination(); - if(coords == null) + if (coords == null) { return lastCoords; + } TileEntity tile = world.getTileEntity(coords); - if(tile != null && tile instanceof TileLightRelay) + if (tile != null && tile instanceof TileLightRelay) { relay = (TileLightRelay) tile; - else return lastCoords; + } else { + return lastCoords; + } lastCoords = coords; } @@ -171,8 +176,9 @@ public class TileLightRelay extends TileMod implements ITickableTileEntity, IWan public Vector3 getMovementVector() { BlockPos dest = getNextDestination(); - if(dest == null) + if (dest == null) { return null; + } return new Vector3(dest.getX() - pos.getX(), dest.getY() - pos.getY(), dest.getZ() - pos.getZ()); } @@ -184,28 +190,29 @@ public class TileLightRelay extends TileMod implements ITickableTileEntity, IWan public BlockPos getNextDestination() { BlockState state = getBlockState(); - if(state.getBlock() == ModBlocks.lightRelayToggle && state.get(BotaniaStateProps.POWERED)) + if (state.getBlock() == ModBlocks.lightRelayToggle && state.get(BotaniaStateProps.POWERED)) { return null; - else if(state.getBlock() == ModBlocks.lightRelayFork) { + } else if (state.getBlock() == ModBlocks.lightRelayFork) { BlockPos torchPos = null; - for(int i = -2; i < 3; i++) { + for (int i = -2; i < 3; i++) { BlockPos testPos = pos.add(0, i, 0); BlockState testState = world.getBlockState(testPos); - if(testState.getBlock() == ModBlocks.animatedTorch) { + if (testState.getBlock() == ModBlocks.animatedTorch) { torchPos = testPos; break; } } - if(torchPos != null) { + if (torchPos != null) { TileAnimatedTorch torch = (TileAnimatedTorch) world.getTileEntity(torchPos); Direction side = TileAnimatedTorch.SIDES[torch.side].getOpposite(); - for(int i = 1; i < MAX_DIST; i++) { + for (int i = 1; i < MAX_DIST; i++) { BlockPos testPos = pos.offset(side, i); BlockState testState = world.getBlockState(testPos); - if(testState.getBlock() instanceof BlockLightRelay) + if (testState.getBlock() instanceof BlockLightRelay) { return testPos; + } } } } @@ -220,9 +227,10 @@ public class TileLightRelay extends TileMod implements ITickableTileEntity, IWan @Override public boolean bindTo(PlayerEntity player, ItemStack wand, BlockPos pos, Direction side) { - if(!(player.world.getBlockState(pos).getBlock() instanceof BlockLightRelay) - || pos.distanceSq(getPos()) > MAX_DIST * MAX_DIST) + if (!(player.world.getBlockState(pos).getBlock() instanceof BlockLightRelay) + || pos.distanceSq(getPos()) > MAX_DIST * MAX_DIST) { return false; + } bindPos = pos; return true; @@ -234,7 +242,7 @@ public class TileLightRelay extends TileMod implements ITickableTileEntity, IWan cmp.getInt(TAG_BIND_X), cmp.getInt(TAG_BIND_Y), cmp.getInt(TAG_BIND_Z) - ); + ); } @Override @@ -245,14 +253,12 @@ public class TileLightRelay extends TileMod implements ITickableTileEntity, IWan } public static class EntityPlayerMover extends Entity { - @ObjectHolder(LibMisc.MOD_ID + ":player_mover") - public static EntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":player_mover") public static EntityType TYPE; private static final String TAG_EXIT_X = "exitX"; private static final String TAG_EXIT_Y = "exitY"; private static final String TAG_EXIT_Z = "exitZ"; private static final DataParameter EXIT_POS = EntityDataManager.createKey(EntityPlayerMover.class, DataSerializers.BLOCK_POS); - public EntityPlayerMover(EntityType type, World world) { super(type, world); noClip = true; @@ -273,36 +279,37 @@ public class TileLightRelay extends TileMod implements ITickableTileEntity, IWan public void tick() { super.tick(); - if(getPassengers().isEmpty() && !world.isRemote) { + if (getPassengers().isEmpty() && !world.isRemote) { remove(); return; } boolean isItem = getRidingEntity() instanceof ItemEntity; - if(!isItem && ticksExisted % 30 == 0) + if (!isItem && ticksExisted % 30 == 0) { playSound(ModSounds.lightRelay, 0.05F, (float) Math.random() * 0.3F + 0.7F); + } BlockPos pos = new BlockPos(this); BlockPos exitPos = getExitPos(); - if(pos.equals(exitPos)) { + if (pos.equals(exitPos)) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileLightRelay) { + if (tile instanceof TileLightRelay) { BlockState state = world.getBlockState(pos); - if(state.getBlock() == ModBlocks.lightRelayDetector) { + if (state.getBlock() == ModBlocks.lightRelayDetector) { world.setBlockState(pos, state.with(BotaniaStateProps.POWERED, true)); world.getPendingBlockTicks().scheduleTick(pos, state.getBlock(), state.getBlock().tickRate(world)); } TileLightRelay relay = (TileLightRelay) tile; BlockPos bind = relay.getNextDestination(); - if(bind != null && relay.isValidBinding()) { + if (bind != null && relay.isValidBinding()) { setExit(bind); return; } } - for(Entity e : getPassengers()) { + for (Entity e : getPassengers()) { e.stopRiding(); e.setPositionAndUpdate(getX(), getY(), getZ()); } @@ -314,7 +321,7 @@ public class TileLightRelay extends TileMod implements ITickableTileEntity, IWan int color; int count = 4; - for(int i = 0; i < count; i++) { + for (int i = 0; i < count; i++) { color = MathHelper.hsvToRGB(ticksExisted / 36F + 1F / count * i, 1F, 1F); double rad = Math.PI * 2.0 / count * i + ticksExisted / Math.PI; double cos = Math.cos(rad); diff --git a/src/main/java/vazkii/botania/common/block/tile/TileManaFlame.java b/src/main/java/vazkii/botania/common/block/tile/TileManaFlame.java index 8e6f28ac5..4c2fe3d0e 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileManaFlame.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileManaFlame.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Dec 21, 2014, 12:33:12 AM (GMT)] */ package vazkii.botania.common.block.tile; @@ -14,13 +12,13 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.client.fx.WispParticleData; import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; public class TileManaFlame extends TileMod implements ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.MANA_FLAME) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.MANA_FLAME) public static TileEntityType TYPE; private static final String TAG_COLOR = "color"; private int color = 0x20FF20; @@ -42,7 +40,7 @@ public class TileManaFlame extends TileMod implements ITickableTileEntity { public void tick() { float c = 0.3F; - if(world.isRemote && Math.random() < c) { + if (world.isRemote && Math.random() < c) { float v = 0.1F; float r = (float) (color >> 16 & 0xFF) / 0xFF; @@ -66,13 +64,13 @@ public class TileManaFlame extends TileMod implements ITickableTileEntity { float s = 0.2F + (float) Math.random() * 0.1F; float m = 0.03F + (float) Math.random() * 0.015F; - WispParticleData data = WispParticleData.wisp(s, r, g, b, 1); - world.addParticle(data, x, y, z, 0, m, 0); - } + WispParticleData data = WispParticleData.wisp(s, r, g, b, 1); + world.addParticle(data, x, y, z, 0, m, 0); + } } public int getLightColor() { - if(lightColor == -1) { + if (lightColor == -1) { lightColor = 0xFFFFFF; } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileMod.java b/src/main/java/vazkii/botania/common/block/tile/TileMod.java index 665fde94a..fe02fc39a 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileMod.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileMod.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 21, 2014, 9:18:28 PM (GMT)] */ package vazkii.botania.common.block.tile; diff --git a/src/main/java/vazkii/botania/common/block/tile/TileOpenCrate.java b/src/main/java/vazkii/botania/common/block/tile/TileOpenCrate.java index b85d4b320..b4dd94392 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileOpenCrate.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileOpenCrate.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 4, 2014, 12:51:05 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -20,13 +18,13 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; public class TileOpenCrate extends TileSimpleInventory implements ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.OPEN_CRATE) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.OPEN_CRATE) public static TileEntityType TYPE; public TileOpenCrate() { this(TYPE); @@ -43,22 +41,24 @@ public class TileOpenCrate extends TileSimpleInventory implements ITickableTileE @Override public void tick() { - if (world.isRemote) + if (world.isRemote) { return; + } boolean redstone = false; - for(Direction dir : Direction.values()) { + for (Direction dir : Direction.values()) { int redstoneSide = world.getRedstonePower(pos.offset(dir), dir); - if(redstoneSide > 0) { + if (redstoneSide > 0) { redstone = true; break; } } - if(canEject()) { + if (canEject()) { ItemStack stack = itemHandler.getStackInSlot(0); - if(!stack.isEmpty()) + if (!stack.isEmpty()) { eject(stack, redstone); + } } } @@ -69,8 +69,9 @@ public class TileOpenCrate extends TileSimpleInventory implements ITickableTileE public void eject(ItemStack stack, boolean redstone) { ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() - 0.5, pos.getZ() + 0.5, stack); item.setMotion(Vec3d.ZERO); - if (redstone) + if (redstone) { item.age = -200; + } itemHandler.setStackInSlot(0, ItemStack.EMPTY); world.addEntity(item); diff --git a/src/main/java/vazkii/botania/common/block/tile/TilePlatform.java b/src/main/java/vazkii/botania/common/block/tile/TilePlatform.java index c6cf2b6b4..fca1be8f6 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TilePlatform.java +++ b/src/main/java/vazkii/botania/common/block/tile/TilePlatform.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 7, 2014, 2:24:51 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -25,6 +23,7 @@ import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.data.ModelDataMap; import net.minecraftforge.client.model.data.ModelProperty; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; @@ -34,8 +33,7 @@ public class TilePlatform extends TileMod { public static final ModelProperty HELD_STATE = new ModelProperty<>(); public static final ModelProperty HELD_POS = new ModelProperty<>(); - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.PLATFORM) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.PLATFORM) public static TileEntityType TYPE; private static final String TAG_CAMO = "camo"; public BlockState camoState; @@ -45,10 +43,12 @@ public class TilePlatform extends TileMod { } public boolean onWanded(PlayerEntity player) { - if(player != null) { - if(camoState == null || player.isSneaking()) + if (player != null) { + if (camoState == null || player.isSneaking()) { swapSelfAndPass(this, true); - else swapSurroudings(this, false); + } else { + swapSurroudings(this, false); + } return true; } @@ -61,13 +61,14 @@ public class TilePlatform extends TileMod { } private void swapSurroudings(TilePlatform tile, boolean empty) { - for(Direction dir : Direction.values()) { + for (Direction dir : Direction.values()) { BlockPos pos = tile.getPos().offset(dir); TileEntity tileAt = world.getTileEntity(pos); - if(tileAt instanceof TilePlatform) { + if (tileAt instanceof TilePlatform) { TilePlatform platform = (TilePlatform) tileAt; - if(empty == (platform.camoState != null)) + if (empty == (platform.camoState != null)) { swapSelfAndPass(platform, empty); + } } } } @@ -79,7 +80,7 @@ public class TilePlatform extends TileMod { @Override public void writePacketNBT(CompoundNBT cmp) { - if(camoState != null) { + if (camoState != null) { cmp.put(TAG_CAMO, NBTUtil.writeBlockState(camoState)); } } @@ -87,7 +88,7 @@ public class TilePlatform extends TileMod { @Override public void readPacketNBT(CompoundNBT cmp) { camoState = NBTUtil.readBlockState(cmp.getCompound(TAG_CAMO)); - if(camoState.isAir()) { + if (camoState.isAir()) { camoState = null; } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TilePylon.java b/src/main/java/vazkii/botania/common/block/tile/TilePylon.java index beec5339b..b9a0c9f5a 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TilePylon.java +++ b/src/main/java/vazkii/botania/common/block/tile/TilePylon.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 18, 2014, 10:15:50 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -16,6 +14,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.BlockPos; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.api.state.enums.AlfPortalState; import vazkii.botania.client.fx.SparkleParticleData; @@ -32,8 +31,7 @@ import vazkii.botania.common.lib.LibMisc; import java.util.Random; public class TilePylon extends TileEntity implements ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.PYLON) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.PYLON) public static TileEntityType TYPE; boolean activated = false; BlockPos centerPos; private int ticks = 0; @@ -46,13 +44,14 @@ public class TilePylon extends TileEntity implements ITickableTileEntity { public void tick() { ++ticks; - if(!(getBlockState().getBlock() instanceof BlockPylon)) + if (!(getBlockState().getBlock() instanceof BlockPylon)) { return; + } BlockPylon.Variant variant = ((BlockPylon) getBlockState().getBlock()).variant; - if(activated && world.isRemote) { - if(world.getBlockState(centerPos).getBlock() != getBlockForMeta() + if (activated && world.isRemote) { + if (world.getBlockState(centerPos).getBlock() != getBlockForMeta() || variant == BlockPylon.Variant.NATURA && (portalOff() || !(world.getBlockState(getPos().down()).getBlock() instanceof BlockPool))) { activated = false; return; @@ -60,8 +59,8 @@ public class TilePylon extends TileEntity implements ITickableTileEntity { Vector3 centerBlock = new Vector3(centerPos.getX() + 0.5, centerPos.getY() + 0.75 + (Math.random() - 0.5 * 0.25), centerPos.getZ() + 0.5); - if(variant == BlockPylon.Variant.NATURA) { - if(ConfigHandler.CLIENT.elfPortalParticlesEnabled.get()) { + if (variant == BlockPylon.Variant.NATURA) { + if (ConfigHandler.CLIENT.elfPortalParticlesEnabled.get()) { double worldTime = ticks; worldTime += new Random(pos.hashCode()).nextInt(1000); worldTime /= 5; @@ -74,9 +73,9 @@ public class TilePylon extends TileEntity implements ITickableTileEntity { centerBlock = centerBlock.subtract(new Vector3(0, 0.5, 0)); Vector3 movementVector = centerBlock.subtract(ourCoords).normalize().multiply(0.2); - WispParticleData data = WispParticleData.wisp(0.25F + (float) Math.random() * 0.1F, (float) Math.random() * 0.25F, 0.75F + (float) Math.random() * 0.25F, (float) Math.random() * 0.25F, 1); - world.addParticle(data, x, pos.getY() + 0.25, z, 0, -(-0.075F - (float) Math.random() * 0.015F), 0); - if(world.rand.nextInt(3) == 0) { + WispParticleData data = WispParticleData.wisp(0.25F + (float) Math.random() * 0.1F, (float) Math.random() * 0.25F, 0.75F + (float) Math.random() * 0.25F, (float) Math.random() * 0.25F, 1); + world.addParticle(data, x, pos.getY() + 0.25, z, 0, -(-0.075F - (float) Math.random() * 0.015F), 0); + if (world.rand.nextInt(3) == 0) { WispParticleData data1 = WispParticleData.wisp(0.25F + (float) Math.random() * 0.1F, (float) Math.random() * 0.25F, 0.75F + (float) Math.random() * 0.25F, (float) Math.random() * 0.25F); world.addParticle(data1, x, pos.getY() + 0.25, z, (float) movementVector.x, (float) movementVector.y, (float) movementVector.z); } @@ -86,34 +85,34 @@ public class TilePylon extends TileEntity implements ITickableTileEntity { Vector3 movementVector = centerBlock.subtract(ourCoords).normalize().multiply(0.2); Block block = world.getBlockState(pos.down()).getBlock(); - if(block instanceof BlockModFlower) { + if (block instanceof BlockModFlower) { int hex = ((BlockModFlower) block).color.colorValue; int r = (hex & 0xFF0000) >> 16; int g = (hex & 0xFF00) >> 8; int b = hex & 0xFF; - if(world.rand.nextInt(4) == 0) { - SparkleParticleData data = SparkleParticleData.sparkle((float) Math.random(), r / 255F, g / 255F, b / 255F, 8); - world.addParticle(data, centerBlock.x + (Math.random() - 0.5) * 0.5, centerBlock.y, centerBlock.z + (Math.random() - 0.5) * 0.5, 0, 0, 0); - } + if (world.rand.nextInt(4) == 0) { + SparkleParticleData data = SparkleParticleData.sparkle((float) Math.random(), r / 255F, g / 255F, b / 255F, 8); + world.addParticle(data, centerBlock.x + (Math.random() - 0.5) * 0.5, centerBlock.y, centerBlock.z + (Math.random() - 0.5) * 0.5, 0, 0, 0); + } - WispParticleData data1 = WispParticleData.wisp((float) Math.random() / 3F, r / 255F, g / 255F, b / 255F, 1); - world.addParticle(data1, pos.getX() + 0.5 + (Math.random() - 0.5) * 0.25, pos.getY() - 0.5, pos.getZ() + 0.5 + (Math.random() - 0.5) * 0.25, 0, - -0.04F, 0); - WispParticleData data = WispParticleData.wisp((float) Math.random() / 5F, r / 255F, g / 255F, b / 255F, 1); - world.addParticle(data, pos.getX() + 0.5 + (Math.random() - 0.5) * 0.125, pos.getY() + 1.5, pos.getZ() + 0.5 + (Math.random() - 0.5) * 0.125, 0, - -0.001F, 0); + WispParticleData data1 = WispParticleData.wisp((float) Math.random() / 3F, r / 255F, g / 255F, b / 255F, 1); + world.addParticle(data1, pos.getX() + 0.5 + (Math.random() - 0.5) * 0.25, pos.getY() - 0.5, pos.getZ() + 0.5 + (Math.random() - 0.5) * 0.25, 0, - -0.04F, 0); + WispParticleData data = WispParticleData.wisp((float) Math.random() / 5F, r / 255F, g / 255F, b / 255F, 1); + world.addParticle(data, pos.getX() + 0.5 + (Math.random() - 0.5) * 0.125, pos.getY() + 1.5, pos.getZ() + 0.5 + (Math.random() - 0.5) * 0.125, 0, - -0.001F, 0); WispParticleData data2 = WispParticleData.wisp((float) Math.random() / 8F, r / 255F, g / 255F, b / 255F); world.addParticle(data2, pos.getX() + 0.5 + (Math.random() - 0.5) * 0.25, pos.getY() + 1.5, pos.getZ() + 0.5 + (Math.random() - 0.5) * 0.25, (float) movementVector.x, (float) movementVector.y, (float) movementVector.z); } } } - if(world.rand.nextBoolean() && world.isRemote) { - float r = variant == BlockPylon.Variant.GAIA ? 1F : 0.5F; - float g = variant == BlockPylon.Variant.NATURA ? 1F : 0.5F; - float b = variant == BlockPylon.Variant.NATURA ? 0.5F : 1F; - SparkleParticleData data = SparkleParticleData.sparkle((float) Math.random(), r, g, b, 2); - world.addParticle(data, pos.getX() + Math.random(), pos.getY() + Math.random() * 1.5, pos.getZ() + Math.random(), 0, 0, 0); - } + if (world.rand.nextBoolean() && world.isRemote) { + float r = variant == BlockPylon.Variant.GAIA ? 1F : 0.5F; + float g = variant == BlockPylon.Variant.NATURA ? 1F : 0.5F; + float b = variant == BlockPylon.Variant.NATURA ? 0.5F : 1F; + SparkleParticleData data = SparkleParticleData.sparkle((float) Math.random(), r, g, b, 2); + world.addParticle(data, pos.getX() + Math.random(), pos.getY() + Math.random() * 1.5, pos.getZ() + Math.random(), 0, 0, 0); + } } private Block getBlockForMeta() { @@ -125,4 +124,4 @@ public class TilePylon extends TileEntity implements ITickableTileEntity { || world.getBlockState(centerPos).get(BotaniaStateProps.ALFPORTAL_STATE) == AlfPortalState.OFF; } -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/common/block/tile/TileRuneAltar.java b/src/main/java/vazkii/botania/common/block/tile/TileRuneAltar.java index 1ad8028eb..121e1c1c2 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileRuneAltar.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileRuneAltar.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 2, 2014, 6:31:19 PM (GMT)] */ package vazkii.botania.common.block.tile; import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.client.Minecraft; import net.minecraft.client.resources.I18n; import net.minecraft.entity.item.ItemEntity; @@ -25,7 +24,9 @@ import net.minecraft.util.SoundCategory; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.Vec3d; import net.minecraftforge.registries.ObjectHolder; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.mana.IManaReceiver; @@ -45,12 +46,12 @@ import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; import javax.annotation.Nullable; + import java.util.ArrayList; import java.util.List; public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver, ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.RUNE_ALTAR) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.RUNE_ALTAR) public static TileEntityType TYPE; private static final String TAG_MANA = "mana"; private static final String TAG_MANA_TO_GET = "manaToGet"; private static final int SET_KEEP_TICKS_EVENT = 0; @@ -72,11 +73,12 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver, } public boolean addItem(@Nullable PlayerEntity player, ItemStack stack, @Nullable Hand hand) { - if(cooldown > 0 || stack.getItem() == ModItems.twigWand || stack.getItem() == ModItems.lexicon) + if (cooldown > 0 || stack.getItem() == ModItems.twigWand || stack.getItem() == ModItems.lexicon) { return false; + } - if(stack.getItem() == ModBlocks.livingrock.asItem()) { - if(!world.isRemote) { + if (stack.getItem() == ModBlocks.livingrock.asItem()) { + if (!world.isRemote) { ItemStack toSpawn = player != null && player.abilities.isCreativeMode ? stack.copy().split(1) : stack.split(1); ItemEntity item = new ItemEntity(world, getPos().getX() + 0.5, getPos().getY() + 1, getPos().getZ() + 0.5, toSpawn); item.setPickupDelay(40); @@ -87,27 +89,30 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver, return true; } - if(manaToGet != 0) + if (manaToGet != 0) { return false; + } boolean did = false; - for(int i = 0; i < getSizeInventory(); i++) - if(itemHandler.getStackInSlot(i).isEmpty()) { + for (int i = 0; i < getSizeInventory(); i++) { + if (itemHandler.getStackInSlot(i).isEmpty()) { did = true; ItemStack stackToAdd = stack.copy(); stackToAdd.setCount(1); itemHandler.setStackInSlot(i, stackToAdd); - if(player == null || !player.abilities.isCreativeMode) { + if (player == null || !player.abilities.isCreativeMode) { stack.shrink(1); } break; } + } - if(did) + if (did) { VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos); + } return true; } @@ -115,22 +120,27 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver, @Override public boolean receiveClientEvent(int id, int param) { switch (id) { - case SET_KEEP_TICKS_EVENT: recipeKeepTicks = param; return true; - case SET_COOLDOWN_EVENT: cooldown = param; return true; - case CRAFT_EFFECT_EVENT: { - if(world.isRemote) { - for(int i = 0; i < 25; i++) { - float red = (float) Math.random(); - float green = (float) Math.random(); - float blue = (float) Math.random(); - SparkleParticleData data = SparkleParticleData.sparkle((float) Math.random(), red, green, blue, 10); - world.addParticle(data, pos.getX() + 0.5 + Math.random() * 0.4 - 0.2, pos.getY() + 1, pos.getZ() + 0.5 + Math.random() * 0.4 - 0.2, 0, 0, 0); - } - world.playSound(pos.getX(), pos.getY(), pos.getZ(), ModSounds.runeAltarCraft, SoundCategory.BLOCKS, 1, 1, false); + case SET_KEEP_TICKS_EVENT: + recipeKeepTicks = param; + return true; + case SET_COOLDOWN_EVENT: + cooldown = param; + return true; + case CRAFT_EFFECT_EVENT: { + if (world.isRemote) { + for (int i = 0; i < 25; i++) { + float red = (float) Math.random(); + float green = (float) Math.random(); + float blue = (float) Math.random(); + SparkleParticleData data = SparkleParticleData.sparkle((float) Math.random(), red, green, blue, 10); + world.addParticle(data, pos.getX() + 0.5 + Math.random() * 0.4 - 0.2, pos.getY() + 1, pos.getZ() + 0.5 + Math.random() * 0.4 - 0.2, 0, 0, 0); } - return true; + world.playSound(pos.getX(), pos.getY(), pos.getZ(), ModSounds.runeAltarCraft, SoundCategory.BLOCKS, 1, 1, false); } - default: return super.receiveClientEvent(id, param); + return true; + } + default: + return super.receiveClientEvent(id, param); } } @@ -140,24 +150,26 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver, // Update every tick. recieveMana(0); - if(!world.isRemote) { - if(manaToGet == 0) { + if (!world.isRemote) { + if (manaToGet == 0) { List items = world.getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(pos, pos.add(1, 1, 1))); - for(ItemEntity item : items) - if(item.isAlive() && !item.getItem().isEmpty() && item.getItem().getItem() != Item.getItemFromBlock(ModBlocks.livingrock)) { + for (ItemEntity item : items) { + if (item.isAlive() && !item.getItem().isEmpty() && item.getItem().getItem() != Item.getItemFromBlock(ModBlocks.livingrock)) { ItemStack stack = item.getItem(); addItem(null, stack, null); } + } } int newSignal = 0; - if(manaToGet > 0) { + if (manaToGet > 0) { newSignal++; - if(mana >= manaToGet) + if (mana >= manaToGet) { newSignal++; + } } - if(newSignal != signal) { + if (newSignal != signal) { signal = newSignal; world.updateComparatorOutputLevel(pos, getBlockState().getBlock()); } @@ -171,37 +183,40 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver, } if (cooldown > 0) { - WispParticleData data = WispParticleData.wisp(0.2F, 0.2F, 0.2F, 0.2F, 1); - world.addParticle(data, pos.getX() + Math.random(), pos.getY() + 0.8, pos.getZ() + Math.random(), 0, - -0.025F, 0); - } + WispParticleData data = WispParticleData.wisp(0.2F, 0.2F, 0.2F, 0.2F, 1); + world.addParticle(data, pos.getX() + Math.random(), pos.getY() + 0.8, pos.getZ() + Math.random(), 0, - -0.025F, 0); + } } - if(cooldown > 0) { + if (cooldown > 0) { cooldown--; } - if(recipeKeepTicks > 0) + if (recipeKeepTicks > 0) { --recipeKeepTicks; - else lastRecipe = null; + } else { + lastRecipe = null; + } } private void updateRecipe() { int manaToGet = this.manaToGet; - getMana : { - if(currentRecipe != null) + getMana: { + if (currentRecipe != null) { this.manaToGet = currentRecipe.getManaUsage(); - else { - for(RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes.values()) - if(recipe.matches(itemHandler)) { + } else { + for (RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes.values()) { + if (recipe.matches(itemHandler)) { this.manaToGet = recipe.getManaUsage(); break getMana; } + } this.manaToGet = 0; } } - if(manaToGet != this.manaToGet) { + if (manaToGet != this.manaToGet) { world.playSound(null, pos, ModSounds.runeAltarStart, SoundCategory.BLOCKS, 1, 1); VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos); } @@ -209,10 +224,11 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver, private void saveLastRecipe() { lastRecipe = new ArrayList<>(); - for(int i = 0; i < getSizeInventory(); i++) { + for (int i = 0; i < getSizeInventory(); i++) { ItemStack stack = itemHandler.getStackInSlot(i); - if(stack.isEmpty()) + if (stack.isEmpty()) { break; + } lastRecipe.add(stack.copy()); } recipeKeepTicks = 400; @@ -221,43 +237,50 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver, public void trySetLastRecipe(PlayerEntity player) { TileAltar.tryToSetLastRecipe(player, itemHandler, lastRecipe); - if(!isEmpty()) + if (!isEmpty()) { VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos); + } } public boolean hasValidRecipe() { - for(RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes.values()) - if(recipe.matches(itemHandler)) + for (RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes.values()) { + if (recipe.matches(itemHandler)) { return true; + } + } return false; } public void onWanded(PlayerEntity player, ItemStack wand) { - if (world.isRemote) + if (world.isRemote) { return; + } RecipeRuneAltar recipe = null; - if(currentRecipe != null) + if (currentRecipe != null) { recipe = currentRecipe; - else for(RecipeRuneAltar recipe_ : BotaniaAPI.runeAltarRecipes.values()) { - if(recipe_.matches(itemHandler)) { - recipe = recipe_; - break; + } else { + for (RecipeRuneAltar recipe_ : BotaniaAPI.runeAltarRecipes.values()) { + if (recipe_.matches(itemHandler)) { + recipe = recipe_; + break; + } } } - if(manaToGet > 0 && mana >= manaToGet) { + if (manaToGet > 0 && mana >= manaToGet) { List items = world.getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(pos, pos.add(1, 1, 1))); ItemEntity livingrock = null; - for(ItemEntity item : items) - if(item.isAlive() && !item.getItem().isEmpty() && item.getItem().getItem() == ModBlocks.livingrock.asItem()) { + for (ItemEntity item : items) { + if (item.isAlive() && !item.getItem().isEmpty() && item.getItem().getItem() == ModBlocks.livingrock.asItem()) { livingrock = item; break; } + } - if(livingrock != null) { + if (livingrock != null) { int mana = recipe.getManaUsage(); recieveMana(-mana); ItemStack output = recipe.getOutput().copy(); @@ -268,10 +291,10 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver, world.addBlockEvent(getPos(), ModBlocks.runeAltar, CRAFT_EFFECT_EVENT, 0); saveLastRecipe(); - for(int i = 0; i < getSizeInventory(); i++) { + for (int i = 0; i < getSizeInventory(); i++) { ItemStack stack = itemHandler.getStackInSlot(i); - if(!stack.isEmpty()) { - if(stack.getItem() instanceof ItemRune && (player == null || !player.abilities.isCreativeMode)) { + if (!stack.isEmpty()) { + if (stack.getItem() instanceof ItemRune && (player == null || !player.abilities.isCreativeMode)) { ItemEntity outputRune = new ItemEntity(world, getPos().getX() + 0.5, getPos().getY() + 1.5, getPos().getZ() + 0.5, stack.copy()); world.addEntity(outputRune); } @@ -286,9 +309,11 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver, } public boolean isEmpty() { - for(int i = 0; i < getSizeInventory(); i++) - if(!itemHandler.getStackInSlot(i).isEmpty()) + for (int i = 0; i < getSizeInventory(); i++) { + if (!itemHandler.getStackInSlot(i).isEmpty()) { return false; + } + } return true; } @@ -357,16 +382,17 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver, float angle = -90; int radius = 24; int amt = 0; - for(int i = 0; i < getSizeInventory(); i++) { - if(itemHandler.getStackInSlot(i).isEmpty()) + for (int i = 0; i < getSizeInventory(); i++) { + if (itemHandler.getStackInSlot(i).isEmpty()) { break; + } amt++; } - if(amt > 0) { + if (amt > 0) { float anglePer = 360F / amt; - for(RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes.values()) - if(recipe.matches(itemHandler)) { + for (RecipeRuneAltar recipe : BotaniaAPI.runeAltarRecipes.values()) { + if (recipe.matches(itemHandler)) { RenderSystem.enableBlend(); RenderSystem.enableRescaleNormal(); RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); @@ -377,7 +403,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver, RenderSystem.color4f(1F, 1F, 1F, 1F); RenderHelper.drawTexturedModalRect(xc + radius + 9, yc - 8, progress == 1F ? 0 : 22, 8, 22, 15); - if(progress == 1F) { + if (progress == 1F) { mc.getItemRenderer().renderItemIntoGUI(new ItemStack(ModBlocks.livingrock), xc + radius + 16, yc + 8); RenderSystem.translatef(0F, 0F, 100F); mc.getItemRenderer().renderItemIntoGUI(new ItemStack(ModItems.twigWand), xc + radius + 24, yc + 8); @@ -386,11 +412,13 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver, RenderHelper.renderProgressPie(xc + radius + 32, yc - 8, progress, recipe.getOutput()); - if(progress == 1F) + if (progress == 1F) { mc.fontRenderer.drawStringWithShadow("+", xc + radius + 14, yc + 12, 0xFFFFFF); + } } + } - for(int i = 0; i < amt; i++) { + for (int i = 0; i < amt; i++) { double xPos = xc + Math.cos(angle * Math.PI / 180D) * radius - 8; double yPos = yc + Math.sin(angle * Math.PI / 180D) * radius - 8; RenderSystem.translated(xPos, yPos, 0); @@ -399,7 +427,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver, angle += anglePer; } - } else if(recipeKeepTicks > 0) { + } else if (recipeKeepTicks > 0) { String s = I18n.format("botaniamisc.altarRefill0"); mc.fontRenderer.drawStringWithShadow(s, xc - mc.fontRenderer.getStringWidth(s) / 2, yc + 10, 0xFFFFFF); s = I18n.format("botaniamisc.altarRefill1"); diff --git a/src/main/java/vazkii/botania/common/block/tile/TileSimpleInventory.java b/src/main/java/vazkii/botania/common/block/tile/TileSimpleInventory.java index 660e5a03e..654d24d33 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileSimpleInventory.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileSimpleInventory.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 21, 2014, 9:56:24 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -60,7 +58,7 @@ public abstract class TileSimpleInventory extends TileMod { } /* Extension of ItemStackHandler that uses our own slot array, allows for control of writing, - allows control over stack limits, and allows for itemstack-slot validation */ + allows control over stack limits, and allows for itemstack-slot validation */ protected static class SimpleItemStackHandler extends ItemStackHandler { private final boolean allowWrite; @@ -75,17 +73,21 @@ public abstract class TileSimpleInventory extends TileMod { @Nonnull @Override public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { - if(allowWrite) { + if (allowWrite) { return super.insertItem(slot, stack, simulate); - } else return stack; + } else { + return stack; + } } @Nonnull @Override public ItemStack extractItem(int slot, int amount, boolean simulate) { - if(allowWrite) { + if (allowWrite) { return super.extractItem(slot, amount, simulate); - } else return ItemStack.EMPTY; + } else { + return ItemStack.EMPTY; + } } @Override diff --git a/src/main/java/vazkii/botania/common/block/tile/TileSparkChanger.java b/src/main/java/vazkii/botania/common/block/tile/TileSparkChanger.java index 7608c086d..eb7659d0f 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileSparkChanger.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileSparkChanger.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 28, 2015, 10:02:11 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -15,6 +13,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.mana.spark.ISparkAttachable; import vazkii.botania.api.mana.spark.ISparkEntity; @@ -25,39 +24,41 @@ import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.ArrayList; import java.util.Collection; import java.util.List; public class TileSparkChanger extends TileSimpleInventory { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.SPARK_CHANGER) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.SPARK_CHANGER) public static TileEntityType TYPE; public TileSparkChanger() { super(TYPE); } public void doSwap() { - if(world.isRemote) + if (world.isRemote) { return; + } ItemStack changeStack = itemHandler.getStackInSlot(0); List attachables = new ArrayList<>(); - for(Direction dir : MathHelper.HORIZONTALS) { + for (Direction dir : MathHelper.HORIZONTALS) { TileEntity tile = world.getTileEntity(pos.offset(dir)); - if(tile instanceof ISparkAttachable) { + if (tile instanceof ISparkAttachable) { ISparkAttachable attach = (ISparkAttachable) tile; ISparkEntity spark = attach.getAttachedSpark(); - if(spark != null) { + if (spark != null) { SparkUpgradeType upg = spark.getUpgrade(); SparkUpgradeType newUpg = changeStack.isEmpty() ? SparkUpgradeType.NONE : ((ItemSparkUpgrade) changeStack.getItem()).type; - if(upg != newUpg) + if (upg != newUpg) { attachables.add(attach); + } } } } - if(attachables.size() > 0) { + if (attachables.size() > 0) { ISparkAttachable attach = attachables.get(world.rand.nextInt(attachables.size())); ISparkEntity spark = attach.getAttachedSpark(); SparkUpgradeType upg = spark.getUpgrade(); @@ -65,8 +66,9 @@ public class TileSparkChanger extends TileSimpleInventory { SparkUpgradeType newUpg = changeStack.isEmpty() ? SparkUpgradeType.NONE : ((ItemSparkUpgrade) changeStack.getItem()).type; spark.setUpgrade(newUpg); Collection transfers = spark.getTransfers(); - if(transfers != null) + if (transfers != null) { transfers.clear(); + } itemHandler.setStackInSlot(0, sparkStack); world.updateComparatorOutputLevel(pos, getBlockState().getBlock()); markDirty(); @@ -89,9 +91,11 @@ public class TileSparkChanger extends TileSimpleInventory { @Nonnull @Override public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { - if(!stack.isEmpty() && stack.getItem() instanceof ItemSparkUpgrade) + if (!stack.isEmpty() && stack.getItem() instanceof ItemSparkUpgrade) { return super.insertItem(slot, stack, simulate); - else return stack; + } else { + return stack; + } } }; } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileSpawnerClaw.java b/src/main/java/vazkii/botania/common/block/tile/TileSpawnerClaw.java index 026896d4f..f2a24e81e 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileSpawnerClaw.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileSpawnerClaw.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 23, 2014, 5:32:11 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -26,6 +24,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.spawner.AbstractSpawner; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.mana.IManaReceiver; import vazkii.botania.client.fx.WispParticleData; import vazkii.botania.common.lib.LibBlockNames; @@ -34,8 +33,7 @@ import vazkii.botania.common.lib.LibMisc; import java.util.Optional; public class TileSpawnerClaw extends TileMod implements IManaReceiver, ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.SPAWNER_CLAW) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.SPAWNER_CLAW) public static TileEntityType TYPE; private static final String TAG_MANA = "mana"; private int mana = 0; @@ -47,7 +45,7 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver, ITickable @Override public void tick() { TileEntity tileBelow = world.getTileEntity(pos.down()); - if(mana >= 5 && tileBelow instanceof MobSpawnerTileEntity) { + if (mana >= 5 && tileBelow instanceof MobSpawnerTileEntity) { MobSpawnerTileEntity spawner = (MobSpawnerTileEntity) tileBelow; AbstractSpawner logic = spawner.getSpawnerBaseLogic(); @@ -59,7 +57,7 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver, ITickable BlockPos blockpos = logic.getSpawnerPosition(); if (world.isRemote) { // Botania - use own particles - if(Math.random() > 0.5) { + if (Math.random() > 0.5) { WispParticleData data = WispParticleData.wisp((float) Math.random() / 3F, 0.6F - (float) Math.random() * 0.3F, 0.1F, 0.6F - (float) Math.random() * 0.3F, 2F); world.addParticle(data, getPos().getX() + 0.3 + Math.random() * 0.5, getPos().getY() - 0.3 + Math.random() * 0.25, getPos().getZ() + Math.random(), 0, -(-0.025F - 0.005F * (float) Math.random()), 0); } @@ -68,7 +66,7 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver, ITickable } logic.prevMobRotation = logic.mobRotation; - logic.mobRotation = (logic.mobRotation + (double)(1000.0F / ((float)logic.spawnDelay + 200.0F))) % 360.0D; + logic.mobRotation = (logic.mobRotation + (double) (1000.0F / ((float) logic.spawnDelay + 200.0F))) % 360.0D; } else { // Botania - consume mana this.mana -= 6; @@ -84,7 +82,7 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver, ITickable boolean flag = false; - for(int i = 0; i < logic.spawnCount; ++i) { + for (int i = 0; i < logic.spawnCount; ++i) { CompoundNBT compoundnbt = logic.spawnData.getNbt(); Optional> optional = EntityType.readEntityType(compoundnbt); if (!optional.isPresent()) { @@ -94,9 +92,9 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver, ITickable ListNBT listnbt = compoundnbt.getList("Pos", 6); int j = listnbt.size(); - double d0 = j >= 1 ? listnbt.getDouble(0) : (double)blockpos.getX() + (world.rand.nextDouble() - world.rand.nextDouble()) * (double)logic.spawnRange + 0.5D; - double d1 = j >= 2 ? listnbt.getDouble(1) : (double)(blockpos.getY() + world.rand.nextInt(3) - 1); - double d2 = j >= 3 ? listnbt.getDouble(2) : (double)blockpos.getZ() + (world.rand.nextDouble() - world.rand.nextDouble()) * (double)logic.spawnRange + 0.5D; + double d0 = j >= 1 ? listnbt.getDouble(0) : (double) blockpos.getX() + (world.rand.nextDouble() - world.rand.nextDouble()) * (double) logic.spawnRange + 0.5D; + double d1 = j >= 2 ? listnbt.getDouble(1) : (double) (blockpos.getY() + world.rand.nextInt(3) - 1); + double d2 = j >= 3 ? listnbt.getDouble(2) : (double) blockpos.getZ() + (world.rand.nextDouble() - world.rand.nextDouble()) * (double) logic.spawnRange + 0.5D; if (world.doesNotCollide(optional.get().func_220328_a(d0, d1, d2))) { Entity entity = EntityType.func_220335_a(compoundnbt, world, (p_221408_6_) -> { p_221408_6_.setLocationAndAngles(d0, d1, d2, p_221408_6_.rotationYaw, p_221408_6_.rotationPitch); @@ -107,7 +105,7 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver, ITickable return; } - int k = world.getEntitiesWithinAABB(entity.getClass(), (new AxisAlignedBB((double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ(), (double)(blockpos.getX() + 1), (double)(blockpos.getY() + 1), (double)(blockpos.getZ() + 1))).grow((double)logic.spawnRange)).size(); + int k = world.getEntitiesWithinAABB(entity.getClass(), (new AxisAlignedBB((double) blockpos.getX(), (double) blockpos.getY(), (double) blockpos.getZ(), (double) (blockpos.getX() + 1), (double) (blockpos.getY() + 1), (double) (blockpos.getZ() + 1))).grow((double) logic.spawnRange)).size(); if (k >= logic.maxNearbyEntities) { logic.resetTimer(); return; @@ -115,20 +113,20 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver, ITickable entity.setLocationAndAngles(entity.getX(), entity.getY(), entity.getZ(), world.rand.nextFloat() * 360.0F, 0.0F); if (entity instanceof MobEntity) { - MobEntity mobentity = (MobEntity)entity; - if (!net.minecraftforge.event.ForgeEventFactory.canEntitySpawnSpawner(mobentity, world, (float)entity.getX(), (float)entity.getY(), (float)entity.getZ(), logic)) { + MobEntity mobentity = (MobEntity) entity; + if (!net.minecraftforge.event.ForgeEventFactory.canEntitySpawnSpawner(mobentity, world, (float) entity.getX(), (float) entity.getY(), (float) entity.getZ(), logic)) { continue; } if (logic.spawnData.getNbt().size() == 1 && logic.spawnData.getNbt().contains("id", 8)) { - ((MobEntity)entity).onInitialSpawn(world, world.getDifficultyForLocation(new BlockPos(entity)), SpawnReason.SPAWNER, (ILivingEntityData)null, (CompoundNBT)null); + ((MobEntity) entity).onInitialSpawn(world, world.getDifficultyForLocation(new BlockPos(entity)), SpawnReason.SPAWNER, (ILivingEntityData) null, (CompoundNBT) null); } } func_221409_a(entity); world.playEvent(2004, blockpos, 0); if (entity instanceof MobEntity) { - ((MobEntity)entity).spawnExplosionParticle(); + ((MobEntity) entity).spawnExplosionParticle(); } flag = true; @@ -146,7 +144,7 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver, ITickable // [VanillaCopy] AbstractSpawner private void func_221409_a(Entity p_221409_1_) { if (this.getWorld().addEntity(p_221409_1_)) { - for(Entity entity : p_221409_1_.getPassengers()) { + for (Entity entity : p_221409_1_.getPassengers()) { this.func_221409_a(entity); } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileSpiritShrine.java b/src/main/java/vazkii/botania/common/block/tile/TileSpiritShrine.java index 3c2771a17..cdf5ddc7d 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileSpiritShrine.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileSpiritShrine.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 1, 2014, 1:55:57 PM (GMT)] */ package vazkii.botania.common.block.tile; import net.minecraft.tileentity.ITickableTileEntity; + import vazkii.botania.client.fx.WispParticleData; public class TileSpiritShrine extends TileMod implements ITickableTileEntity { @@ -23,15 +22,15 @@ public class TileSpiritShrine extends TileMod implements ITickableTileEntity { @Override public void tick() { - if(world.isRemote) { - if(ticks >= 40) { + if (world.isRemote) { + if (ticks >= 40) { float[][] colors = new float[][] { - { 0F, 0.25F, 1F }, - { 1F, 0F, 0.2F }, - { 0F, 1F, 0.25F }, - { 1F, 1F, 0.25F }, - { 1F, 0.25F, 1F }, - { 0.25F, 1F, 1F } + { 0F, 0.25F, 1F }, + { 1F, 0F, 0.2F }, + { 0F, 1F, 0.25F }, + { 1F, 1F, 0.25F }, + { 1F, 0.25F, 1F }, + { 0.25F, 1F, 1F } }; int totalSpiritCount = 6; @@ -41,20 +40,20 @@ public class TileSpiritShrine extends TileMod implements ITickableTileEntity { int existTicks = liftTicks * 2; int lowerTicks = existTicks + liftTicks; - if(ticks < lowerTicks) { + if (ticks < lowerTicks) { int speed = 5; double wticks = ticks * speed - tickIncrement; - double r = Math.sin((ticks >= liftTicks ? (ticks - liftTicks) * speed - tickIncrement : -tickIncrement) * Math.PI / 180 * 0.75) + 1 * 1.25 + 0.5; + double r = Math.sin((ticks >= liftTicks ? (ticks - liftTicks) * speed - tickIncrement : -tickIncrement) * Math.PI / 180 * 0.75) + 1 * 1.25 + 0.5; double g = Math.sin(wticks * Math.PI / 180 * 0.55); - for(int i = 0; i < totalSpiritCount; i++) { + for (int i = 0; i < totalSpiritCount; i++) { double x = pos.getX() + Math.sin(wticks * Math.PI / 180) * r + 0.5; double y = pos.getY() + (ticks > existTicks ? 40 - (double) (ticks - existTicks) : Math.min(80 + 40 * i, ticks) - 40 * (i + 1)) * 0.1; double z = pos.getZ() + Math.cos(wticks * Math.PI / 180) * r + 0.5; wticks += tickIncrement; float[] colorsfx = colors[i >= colors.length ? 0 : i]; - WispParticleData data = WispParticleData.wisp(0.85F, colorsfx[0], colorsfx[1], colorsfx[2], 0.25F); + WispParticleData data = WispParticleData.wisp(0.85F, colorsfx[0], colorsfx[1], colorsfx[2], 0.25F); world.addParticle(data, x, y, z, 0, (float) (-g * 0.05), 0); data = WispParticleData.wisp((float) Math.random() * 0.1F + 0.1F, colorsfx[0], colorsfx[1], colorsfx[2], 0.9F); diff --git a/src/main/java/vazkii/botania/common/block/tile/TileStarfield.java b/src/main/java/vazkii/botania/common/block/tile/TileStarfield.java index 113c8d355..13b7bc8d5 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileStarfield.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileStarfield.java @@ -1,26 +1,24 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 7, 2014, 6:42:33 PM (GMT)] */ package vazkii.botania.common.block.tile; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.client.fx.SparkleParticleData; import vazkii.botania.common.Botania; import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; public class TileStarfield extends TileMod implements ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.STARFIELD) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.STARFIELD) public static TileEntityType TYPE; public TileStarfield() { super(TYPE); @@ -28,14 +26,15 @@ public class TileStarfield extends TileMod implements ITickableTileEntity { @Override public void tick() { - if(world.isRemote) { + if (world.isRemote) { world.calculateInitialSkylight(); // ensure isDayTime works properly by updating skylightSubtracted - if (world.isDaytime()) + if (world.isDaytime()) { return; + } double radius = 512; int iter = 2; - for(int i = 0; i < iter; i++) { + for (int i = 0; i < iter; i++) { double x = pos.getX() + 0.5 + (Math.random() - 0.5) * radius; double y = Math.min(256, pos.getY() + Botania.proxy.getClientRenderDistance() * 16); double z = pos.getZ() + 0.5 + (Math.random() - 0.5) * radius; diff --git a/src/main/java/vazkii/botania/common/block/tile/TileTerraPlate.java b/src/main/java/vazkii/botania/common/block/tile/TileTerraPlate.java index adc558b5a..df5179174 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileTerraPlate.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileTerraPlate.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 8, 2014, 5:25:32 PM (GMT)] */ package vazkii.botania.common.block.tile; import com.google.common.base.Predicates; + import net.minecraft.entity.Entity; import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.ItemStack; @@ -21,6 +20,7 @@ import net.minecraft.util.LazyValue; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.mana.IManaPool; import vazkii.botania.api.mana.spark.ISparkAttachable; @@ -40,8 +40,7 @@ import vazkii.patchouli.api.PatchouliAPI; import java.util.List; public class TileTerraPlate extends TileMod implements ISparkAttachable, ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.TERRA_PLATE) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.TERRA_PLATE) public static TileEntityType TYPE; public static final int MAX_MANA = TilePool.MAX_MANA / 2; public static final LazyValue MULTIBLOCK = new LazyValue<>(() -> PatchouliAPI.instance.makeMultiblock( @@ -73,33 +72,37 @@ public class TileTerraPlate extends TileMod implements ISparkAttachable, ITickab @Override public void tick() { - if(world.isRemote) + if (world.isRemote) { return; + } boolean removeMana = true; - if(hasValidPlatform()) { + if (hasValidPlatform()) { List items = getItems(); - if(areItemsValid(items)) { + if (areItemsValid(items)) { removeMana = false; ISparkEntity spark = getAttachedSpark(); - if(spark != null) { + if (spark != null) { SparkHelper.getSparksAround(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, spark.getNetwork()) .filter(otherSpark -> spark != otherSpark && otherSpark.getAttachedTile() instanceof IManaPool) .forEach(os -> os.registerTransfer(spark)); } - if(mana > 0) { + if (mana > 0) { VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos); PacketHandler.sendToNearby(world, getPos(), - new PacketBotaniaEffect(PacketBotaniaEffect.EffectType.TERRA_PLATE, getPos().getX(), getPos().getY(), getPos().getZ())); + new PacketBotaniaEffect(PacketBotaniaEffect.EffectType.TERRA_PLATE, getPos().getX(), getPos().getY(), getPos().getZ())); } - if(mana >= MAX_MANA) { + if (mana >= MAX_MANA) { ItemEntity item = items.get(0); - for(ItemEntity otherItem : items) - if(otherItem != item) + for (ItemEntity otherItem : items) { + if (otherItem != item) { otherItem.remove(); - else item.setItem(new ItemStack(ModItems.terrasteel)); + } else { + item.setItem(new ItemStack(ModItems.terrasteel)); + } + } world.playSound(null, item.getX(), item.getY(), item.getZ(), ModSounds.terrasteelCraft, SoundCategory.BLOCKS, 1, 1); mana = 0; world.updateComparatorOutputLevel(pos, getBlockState().getBlock()); @@ -108,8 +111,9 @@ public class TileTerraPlate extends TileMod implements ISparkAttachable, ITickab } } - if(removeMana) + if (removeMana) { recieveMana(-1000); + } } private List getItems() { @@ -117,24 +121,28 @@ public class TileTerraPlate extends TileMod implements ISparkAttachable, ITickab } private boolean areItemsValid(List items) { - if(items.size() != 3) + if (items.size() != 3) { return false; + } ItemStack ingot = ItemStack.EMPTY; ItemStack pearl = ItemStack.EMPTY; ItemStack diamond = ItemStack.EMPTY; - for(ItemEntity item : items) { + for (ItemEntity item : items) { ItemStack stack = item.getItem(); - if(stack.getCount() != 1) + if (stack.getCount() != 1) { return false; + } - if(stack.getItem() == ModItems.manaSteel) + if (stack.getItem() == ModItems.manaSteel) { ingot = stack; - else if(stack.getItem() == ModItems.manaPearl) + } else if (stack.getItem() == ModItems.manaPearl) { pearl = stack; - else if(stack.getItem() == ModItems.manaDiamond) + } else if (stack.getItem() == ModItems.manaDiamond) { diamond = stack; - else return false; + } else { + return false; + } } return !ingot.isEmpty() && !pearl.isEmpty() && !diamond.isEmpty(); @@ -186,7 +194,7 @@ public class TileTerraPlate extends TileMod implements ISparkAttachable, ITickab @Override public ISparkEntity getAttachedSpark() { List sparks = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos.up(), pos.up().add(1, 1, 1)), Predicates.instanceOf(ISparkEntity.class)); - if(sparks.size() == 1) { + if (sparks.size() == 1) { Entity e = sparks.get(0); return (ISparkEntity) e; } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileTeruTeruBozu.java b/src/main/java/vazkii/botania/common/block/tile/TileTeruTeruBozu.java index 4a674ee0f..b664fdec7 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileTeruTeruBozu.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileTeruTeruBozu.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Oct 1, 2015, 1:11:44 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -14,12 +12,12 @@ import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.world.World; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; public class TileTeruTeruBozu extends TileMod implements ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.TERU_TERU_BOZU) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.TERU_TERU_BOZU) public static TileEntityType TYPE; private boolean wasRaining = false; public TileTeruTeruBozu() { @@ -28,21 +26,23 @@ public class TileTeruTeruBozu extends TileMod implements ITickableTileEntity { @Override public void tick() { - if (world.isRemote) + if (world.isRemote) { return; + } boolean isRaining = world.isRaining(); - if(isRaining && world.rand.nextInt(9600) == 0) { + if (isRaining && world.rand.nextInt(9600) == 0) { world.getWorldInfo().setRaining(false); resetRainTime(world); } - if(wasRaining != isRaining) + if (wasRaining != isRaining) { world.updateComparatorOutputLevel(pos, getBlockState().getBlock()); + } wasRaining = isRaining; } - public static void resetRainTime(World w){ - w.getWorldInfo().setRainTime(w.rand.nextInt(w.getWorldInfo().isRaining() ? 12000 : 168000) + 12000); + public static void resetRainTime(World w) { + w.getWorldInfo().setRainTime(w.rand.nextInt(w.getWorldInfo().isRaining() ? 12000 : 168000) + 12000); } } diff --git a/src/main/java/vazkii/botania/common/block/tile/TileTinyPlanet.java b/src/main/java/vazkii/botania/common/block/tile/TileTinyPlanet.java index 920d31d1e..099d13d10 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileTinyPlanet.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileTinyPlanet.java @@ -1,25 +1,23 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 1, 2014, 3:49:53 PM (GMT)] */ package vazkii.botania.common.block.tile; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.common.item.equipment.bauble.ItemTinyPlanet; import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; public class TileTinyPlanet extends TileMod implements ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.TINY_PLANET) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.TINY_PLANET) public static TileEntityType TYPE; public TileTinyPlanet() { super(TYPE); diff --git a/src/main/java/vazkii/botania/common/block/tile/TileTinyPotato.java b/src/main/java/vazkii/botania/common/block/tile/TileTinyPotato.java index 424c804fd..33c8e4fa0 100644 --- a/src/main/java/vazkii/botania/common/block/tile/TileTinyPotato.java +++ b/src/main/java/vazkii/botania/common/block/tile/TileTinyPotato.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 18, 2014, 8:05:08 PM (GMT)] */ package vazkii.botania.common.block.tile; @@ -26,6 +24,7 @@ import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.TranslationTextComponent; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.core.handler.ModSounds; @@ -37,8 +36,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class TileTinyPotato extends TileSimpleInventory implements ITickableTileEntity, INameable { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.TINY_POTATO) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.TINY_POTATO) public static TileEntityType TYPE; private static final String TAG_NAME = "name"; private static final int JUMP_EVENT = 0; @@ -52,17 +50,17 @@ public class TileTinyPotato extends TileSimpleInventory implements ITickableTile public void interact(PlayerEntity player, Hand hand, ItemStack stack, Direction side) { int index = side.getIndex(); - if(index >= 0) { + if (index >= 0) { ItemStack stackAt = getItemHandler().getStackInSlot(index); - if(!stackAt.isEmpty() && stack.isEmpty()) { + if (!stackAt.isEmpty() && stack.isEmpty()) { player.setHeldItem(hand, stackAt); getItemHandler().setStackInSlot(index, ItemStack.EMPTY); - } else if(!stack.isEmpty()) { + } else if (!stack.isEmpty()) { ItemStack copy = stack.split(1); - if(stack.isEmpty()) + if (stack.isEmpty()) { player.setHeldItem(hand, stackAt); - else if(!stackAt.isEmpty()) { + } else if (!stackAt.isEmpty()) { ItemHandlerHelper.giveItemToPlayer(player, stackAt); } @@ -70,17 +68,17 @@ public class TileTinyPotato extends TileSimpleInventory implements ITickableTile } } - if(!world.isRemote) { + if (!world.isRemote) { jump(); - if(name.getString().toLowerCase().trim().endsWith("shia labeouf") && nextDoIt == 0) { + if (name.getString().toLowerCase().trim().endsWith("shia labeouf") && nextDoIt == 0) { nextDoIt = 40; world.playSound(null, pos, ModSounds.doit, SoundCategory.BLOCKS, 1F, 1F); } - for(int i = 0; i < getSizeInventory(); i++) { + for (int i = 0; i < getSizeInventory(); i++) { ItemStack stackAt = getItemHandler().getStackInSlot(i); - if(!stackAt.isEmpty() && stackAt.getItem() == ModBlocks.tinyPotato.asItem()) { + if (!stackAt.isEmpty() && stackAt.getItem() == ModBlocks.tinyPotato.asItem()) { player.sendMessage(new StringTextComponent("Don't talk to me or my son ever again.")); return; } @@ -91,13 +89,14 @@ public class TileTinyPotato extends TileSimpleInventory implements ITickableTile } private void jump() { - if(jumpTicks == 0) + if (jumpTicks == 0) { world.addBlockEvent(getPos(), getBlockState().getBlock(), JUMP_EVENT, 20); + } } @Override public boolean receiveClientEvent(int id, int param) { - if(id == JUMP_EVENT) { + if (id == JUMP_EVENT) { jumpTicks = param; return true; } else { @@ -107,14 +106,17 @@ public class TileTinyPotato extends TileSimpleInventory implements ITickableTile @Override public void tick() { - if(jumpTicks > 0) + if (jumpTicks > 0) { jumpTicks--; + } - if(!world.isRemote) { - if(world.rand.nextInt(100) == 0) + if (!world.isRemote) { + if (world.rand.nextInt(100) == 0) { jump(); - if(nextDoIt > 0) + } + if (nextDoIt > 0) { nextDoIt--; + } } } diff --git a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaBase.java b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaBase.java index ddf05d076..9ba034042 100644 --- a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaBase.java +++ b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaBase.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 15, 2015, 12:25:19 AM (GMT)] */ package vazkii.botania.common.block.tile.corporea; import net.minecraft.tileentity.TileEntityType; + import vazkii.botania.api.corporea.CorporeaHelper; import vazkii.botania.api.corporea.ICorporeaSpark; import vazkii.botania.common.block.tile.TileSimpleInventory; diff --git a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaCrystalCube.java b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaCrystalCube.java index 3fb52a317..1d76e6fb4 100644 --- a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaCrystalCube.java +++ b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaCrystalCube.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 30, 2015, 3:57:57 PM (GMT)] */ package vazkii.botania.common.block.tile.corporea; @@ -16,9 +14,10 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.corporea.CorporeaHelper; -import vazkii.botania.api.corporea.ICorporeaRequestor; import vazkii.botania.api.corporea.ICorporeaRequestMatcher; +import vazkii.botania.api.corporea.ICorporeaRequestor; import vazkii.botania.api.corporea.ICorporeaSpark; import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.common.lib.LibBlockNames; @@ -27,8 +26,7 @@ import vazkii.botania.common.lib.LibMisc; import java.util.List; public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorporeaRequestor, ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.CORPOREA_CRYSTAL_CUBE) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.CORPOREA_CRYSTAL_CUBE) public static TileEntityType TYPE; private static final String TAG_REQUEST_TARGET = "requestTarget"; private static final String TAG_ITEM_COUNT = "itemCount"; private static final String TAG_LOCK = "lock"; @@ -46,18 +44,20 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor @Override public void tick() { ++ticks; - if(ticks % 20 == 0) + if (ticks % 20 == 0) { updateCount(); + } } public void setRequestTarget(ItemStack stack) { - if(!stack.isEmpty() && !locked) { + if (!stack.isEmpty() && !locked) { ItemStack copy = stack.copy(); copy.setCount(1); requestTarget = copy; updateCount(); - if(!world.isRemote) + if (!world.isRemote) { VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + } } } @@ -71,30 +71,33 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor } public void doRequest(boolean fullStack) { - if(world.isRemote) + if (world.isRemote) { return; + } ICorporeaSpark spark = getSpark(); - if(spark != null && spark.getMaster() != null && requestTarget != null) { + if (spark != null && spark.getMaster() != null && requestTarget != null) { int count = fullStack ? requestTarget.getMaxStackSize() : 1; doCorporeaRequest(CorporeaHelper.createMatcher(requestTarget, true), count, spark); } } private void updateCount() { - if(world.isRemote) + if (world.isRemote) { return; + } int oldCount = itemCount; itemCount = 0; ICorporeaSpark spark = getSpark(); - if(spark != null && spark.getMaster() != null && requestTarget != null) { + if (spark != null && spark.getMaster() != null && requestTarget != null) { List stacks = CorporeaHelper.requestItem(CorporeaHelper.createMatcher(requestTarget, true), -1, spark, false); - for(ItemStack stack : stacks) + for (ItemStack stack : stacks) { itemCount += stack.getCount(); + } } - if(itemCount != oldCount) { + if (itemCount != oldCount) { VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); onUpdateCount(); } @@ -103,16 +106,18 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor private void onUpdateCount() { int oldCompValue = compValue; compValue = CorporeaHelper.signalStrengthForRequestSize(itemCount); - if(compValue != oldCompValue) + if (compValue != oldCompValue) { world.updateComparatorOutputLevel(pos, getBlockState().getBlock()); + } } @Override public void writePacketNBT(CompoundNBT tag) { super.writePacketNBT(tag); CompoundNBT cmp = new CompoundNBT(); - if(!requestTarget.isEmpty()) + if (!requestTarget.isEmpty()) { cmp = requestTarget.write(cmp); + } tag.put(TAG_REQUEST_TARGET, cmp); tag.putInt(TAG_ITEM_COUNT, itemCount); tag.putBoolean(TAG_LOCK, locked); @@ -136,15 +141,16 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor List stacks = CorporeaHelper.requestItem(request, count, spark, true); spark.onItemsRequested(stacks); boolean did = false; - for(ItemStack reqStack : stacks) - if(requestTarget != null) { + for (ItemStack reqStack : stacks) { + if (requestTarget != null) { ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, reqStack); world.addEntity(item); itemCount -= reqStack.getCount(); did = true; } + } - if(did) { + if (did) { VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); onUpdateCount(); } diff --git a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaFunnel.java b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaFunnel.java index 07cf429da..58b7fcd3b 100644 --- a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaFunnel.java +++ b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaFunnel.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 16, 2015, 2:18:30 PM (GMT)] */ package vazkii.botania.common.block.tile.corporea; @@ -20,12 +18,12 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.corporea.CorporeaHelper; import vazkii.botania.api.corporea.ICorporeaRequestMatcher; import vazkii.botania.api.corporea.ICorporeaRequestor; import vazkii.botania.api.corporea.ICorporeaSpark; import vazkii.botania.common.core.helper.InventoryHelper; -import vazkii.botania.common.core.helper.MathHelper; import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; @@ -33,8 +31,7 @@ import java.util.ArrayList; import java.util.List; public class TileCorporeaFunnel extends TileCorporeaBase implements ICorporeaRequestor { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.CORPOREA_FUNNEL) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.CORPOREA_FUNNEL) public static TileEntityType TYPE; public TileCorporeaFunnel() { super(TYPE); @@ -42,13 +39,14 @@ public class TileCorporeaFunnel extends TileCorporeaBase implements ICorporeaReq public void doRequest() { ICorporeaSpark spark = getSpark(); - if(spark != null && spark.getMaster() != null) { + if (spark != null && spark.getMaster() != null) { List filter = getFilter(); - if(!filter.isEmpty()) { + if (!filter.isEmpty()) { ItemStack stack = filter.get(world.rand.nextInt(filter.size())); - if(!stack.isEmpty()) + if (!stack.isEmpty()) { doCorporeaRequest(CorporeaHelper.createMatcher(stack, true), stack.getCount(), spark); + } } } } @@ -60,13 +58,13 @@ public class TileCorporeaFunnel extends TileCorporeaBase implements ICorporeaReq 1, 2, 4, 8, 16, 32, 48, 64 }; - for(Direction dir : Direction.values()) { + for (Direction dir : Direction.values()) { List frames = world.getEntitiesWithinAABB(ItemFrameEntity.class, new AxisAlignedBB(pos.offset(dir), pos.offset(dir).add(1, 1, 1))); - for(ItemFrameEntity frame : frames) { + for (ItemFrameEntity frame : frames) { Direction orientation = frame.getHorizontalFacing(); - if(orientation == dir) { + if (orientation == dir) { ItemStack stack = frame.getDisplayedItem(); - if(!stack.isEmpty()) { + if (!stack.isEmpty()) { ItemStack copy = stack.copy(); copy.setCount(rotationToStackSize[frame.getRotation()]); filter.add(copy); @@ -84,10 +82,10 @@ public class TileCorporeaFunnel extends TileCorporeaBase implements ICorporeaReq List stacks = CorporeaHelper.requestItem(request, count, spark, true); spark.onItemsRequested(stacks); - for(ItemStack reqStack : stacks) { - if(inv != null && ItemHandlerHelper.insertItemStacked(inv, reqStack, true).isEmpty()) + for (ItemStack reqStack : stacks) { + if (inv != null && ItemHandlerHelper.insertItemStacked(inv, reqStack, true).isEmpty()) { ItemHandlerHelper.insertItemStacked(inv, reqStack, false); - else { + } else { ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, reqStack); world.addEntity(item); } @@ -97,17 +95,21 @@ public class TileCorporeaFunnel extends TileCorporeaBase implements ICorporeaReq private IItemHandler getInv() { TileEntity te = world.getTileEntity(pos.down()); IItemHandler ret = InventoryHelper.getInventory(world, pos.down(), Direction.UP); - if(ret == null) + if (ret == null) { ret = InventoryHelper.getInventory(world, pos.down(), null); - if(ret != null && !(te instanceof TileCorporeaFunnel)) + } + if (ret != null && !(te instanceof TileCorporeaFunnel)) { return ret; + } te = world.getTileEntity(pos.down(2)); ret = InventoryHelper.getInventory(world, pos.down(2), Direction.UP); - if(ret == null) + if (ret == null) { ret = InventoryHelper.getInventory(world, pos.down(2), null); - if(ret != null && !(te instanceof TileCorporeaFunnel)) + } + if (ret != null && !(te instanceof TileCorporeaFunnel)) { return ret; + } return null; } diff --git a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaIndex.java b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaIndex.java index b28b79c4f..9b5cf2e7d 100644 --- a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaIndex.java +++ b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaIndex.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 15, 2015, 12:42:29 AM (GMT)] */ package vazkii.botania.common.block.tile.corporea; @@ -17,7 +15,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.text.Style; import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TranslationTextComponent; import net.minecraftforge.common.MinecraftForge; @@ -25,6 +22,7 @@ import net.minecraftforge.event.ServerChatEvent; import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.corporea.CorporeaHelper; import vazkii.botania.api.corporea.CorporeaIndexRequestEvent; import vazkii.botania.api.corporea.ICorporeaRequestMatcher; @@ -46,8 +44,7 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; public class TileCorporeaIndex extends TileCorporeaBase implements ICorporeaRequestor, ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.CORPOREA_INDEX) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.CORPOREA_INDEX) public static TileEntityType TYPE; public static final double RADIUS = 2.5; private static InputHandler input; @@ -65,98 +62,210 @@ public class TileCorporeaIndex extends TileCorporeaBase implements ICorporeaRequ static { // (name) = 1 addPattern("(.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return 1; } - @Override public String getName(Matcher m) { return m.group(1); } + @Override + public int getCount(Matcher m) { + return 1; + } + + @Override + public String getName(Matcher m) { + return m.group(1); + } }); // [a][n] (name) = 1 addPattern("a??n?? (.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return 1; } - @Override public String getName(Matcher m) { return m.group(1); } + @Override + public int getCount(Matcher m) { + return 1; + } + + @Override + public String getName(Matcher m) { + return m.group(1); + } }); //(n)[x][ of] (name) = n addPattern("(\\d+)x?(?: of)? (.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return i(m, 1); } - @Override public String getName(Matcher m) { return m.group(2); } + @Override + public int getCount(Matcher m) { + return i(m, 1); + } + + @Override + public String getName(Matcher m) { + return m.group(2); + } }); // [a ]stack[ of] (name) = 64 addPattern("(?:a )?stack(?: of)? (.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return 64; } - @Override public String getName(Matcher m) { return m.group(1); } + @Override + public int getCount(Matcher m) { + return 64; + } + + @Override + public String getName(Matcher m) { + return m.group(1); + } }); // (n)[x] stack[s][ of] (name) = n * 64 addPattern("(\\d+)x?? stacks?(?: of)? (.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return 64 * i(m, 1); } - @Override public String getName(Matcher m) { return m.group(2); } + @Override + public int getCount(Matcher m) { + return 64 * i(m, 1); + } + + @Override + public String getName(Matcher m) { + return m.group(2); + } }); // [a ]stack (n)[x][ of] (name) = 64 + n addPattern("(?:a )?stack (?:(?:and)|(?:\\+)) (\\d+)(?: of)? (.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return 64 + i(m, 1); } - @Override public String getName(Matcher m) { return m.group(2); } + @Override + public int getCount(Matcher m) { + return 64 + i(m, 1); + } + + @Override + public String getName(Matcher m) { + return m.group(2); + } }); // (n1)[x] stack[s] (n2)[x][ of] (name) = n1 * 64 + n2 addPattern("(\\d+)x?? stacks? (?:(?:and)|(?:\\+)) (\\d+)x?(?: of)? (.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return 64 * i(m, 1) + i(m, 2); } - @Override public String getName(Matcher m) { return m.group(3); } + @Override + public int getCount(Matcher m) { + return 64 * i(m, 1) + i(m, 2); + } + + @Override + public String getName(Matcher m) { + return m.group(3); + } }); // [a ]half [of ][a ]stack[ of] (name) = 32 addPattern("(?:a )?half (?:of )?(?:a )?stack(?: of)? (.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return 32; } - @Override public String getName(Matcher m) { return m.group(1); } + @Override + public int getCount(Matcher m) { + return 32; + } + + @Override + public String getName(Matcher m) { + return m.group(1); + } }); // [a ]quarter [of ][a ]stack[ of] (name) = 16 addPattern("(?:a )?quarter (?:of )?(?:a )?stack(?: of)? (.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return 16; } - @Override public String getName(Matcher m) { return m.group(1); } + @Override + public int getCount(Matcher m) { + return 16; + } + + @Override + public String getName(Matcher m) { + return m.group(1); + } }); // [a ]dozen[ of] (name) = 12 addPattern("(?:a )?dozen(?: of)? (.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return 12; } - @Override public String getName(Matcher m) { return m.group(1); } + @Override + public int getCount(Matcher m) { + return 12; + } + + @Override + public String getName(Matcher m) { + return m.group(1); + } }); // (n)[x] dozen[s][ of] (name) = n * 12 addPattern("(\\d+)x?? dozens?(?: of)? (.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return 12 * i(m, 1); } - @Override public String getName(Matcher m) { return m.group(2); } + @Override + public int getCount(Matcher m) { + return 12 * i(m, 1); + } + + @Override + public String getName(Matcher m) { + return m.group(2); + } }); // [ ](name) = 2147483647 addPattern("(?:all|every) (?:(?:of|the) )?(.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return Integer.MAX_VALUE; } - @Override public String getName(Matcher m) { return m.group(1); } + @Override + public int getCount(Matcher m) { + return Integer.MAX_VALUE; + } + + @Override + public String getName(Matcher m) { + return m.group(1); + } }); // [the ]answer to life[,] the universe and everything [of ](name) = 42 addPattern("(?:the )?answer to life,? the universe and everything (?:of )?(.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return 42; } - @Override public String getName(Matcher m) { return m.group(1); } + @Override + public int getCount(Matcher m) { + return 42; + } + + @Override + public String getName(Matcher m) { + return m.group(1); + } }); - + // [a ]nice [of ](name) = 69 addPattern("(?:a )?nice (?:of )?(.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return 69; } - @Override public String getName(Matcher m) { return m.group(1); } + @Override + public int getCount(Matcher m) { + return 69; + } + + @Override + public String getName(Matcher m) { + return m.group(1); + } }); - + // (n)[x] nice[s][ of] (name) = n * 69 addPattern("(\\d+)x?? nices?(?: of)? (.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return 69 * i(m, 1); } - @Override public String getName(Matcher m) { return m.group(2); } + @Override + public int getCount(Matcher m) { + return 69 * i(m, 1); + } + + @Override + public String getName(Matcher m) { + return m.group(2); + } }); // (name) = 0 (display only) addPattern("(?:count|show|display|tell) (.+)", new IRegexStacker() { - @Override public int getCount(Matcher m) { return 0; } - @Override public String getName(Matcher m) { return m.group(1); } + @Override + public int getCount(Matcher m) { + return 0; + } + + @Override + public String getName(Matcher m) { + return m.group(1); + } }); } @@ -177,23 +286,27 @@ public class TileCorporeaIndex extends TileCorporeaBase implements ICorporeaRequ List players = world.getEntitiesWithinAABB(PlayerEntity.class, new AxisAlignedBB(x - RADIUS, y - RADIUS, z - RADIUS, x + RADIUS, y + RADIUS, z + RADIUS)); hasCloseby = false; - for(PlayerEntity player : players) - if(isInRangeOfIndex(player, this)) { + for (PlayerEntity player : players) { + if (isInRangeOfIndex(player, this)) { hasCloseby = true; break; } + } float step = 0.2F; ticks++; - if(hasCloseby) { + if (hasCloseby) { ticksWithCloseby++; - if(closeby < 1F) + if (closeby < 1F) { closeby += step; - } else if(closeby > 0F) + } + } else if (closeby > 0F) { closeby -= step; + } - if(!isRemoved()) + if (!isRemoved()) { addIndex(this); + } } @Override @@ -212,11 +325,12 @@ public class TileCorporeaIndex extends TileCorporeaBase implements ICorporeaRequ public void doCorporeaRequest(ICorporeaRequestMatcher request, int count, ICorporeaSpark spark) { List stacks = CorporeaHelper.requestItem(request, count, spark, true); spark.onItemsRequested(stacks); - for(ItemStack stack : stacks) - if(!stack.isEmpty()) { + for (ItemStack stack : stacks) { + if (!stack.isEmpty()) { ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, stack); world.addEntity(item); } + } } public static boolean isInRangeOfIndex(PlayerEntity player, TileCorporeaIndex index) { @@ -231,14 +345,15 @@ public class TileCorporeaIndex extends TileCorporeaBase implements ICorporeaRequ try { int i = Math.abs(Integer.parseInt(m.group(g))); return i; - } catch(NumberFormatException e) { + } catch (NumberFormatException e) { return 0; } } public static InputHandler getInputHandler() { - if(input == null) + if (input == null) { input = new InputHandler(); + } return input; } @@ -254,7 +369,7 @@ public class TileCorporeaIndex extends TileCorporeaBase implements ICorporeaRequ public void performPlayerRequest(ServerPlayerEntity player, ICorporeaRequestMatcher request, int count) { CorporeaIndexRequestEvent indexReqEvent = new CorporeaIndexRequestEvent(player, request, count, this.getSpark()); - if(!MinecraftForge.EVENT_BUS.post(indexReqEvent)) { + if (!MinecraftForge.EVENT_BUS.post(indexReqEvent)) { this.doCorporeaRequest(request, count, this.getSpark()); player.sendMessage(new TranslationTextComponent("botaniamisc.requestMsg", count, request.getRequestName(), CorporeaHelper.lastRequestMatches, CorporeaHelper.lastRequestExtractions).applyTextStyle(TextFormatting.LIGHT_PURPLE)); @@ -265,30 +380,32 @@ public class TileCorporeaIndex extends TileCorporeaBase implements ICorporeaRequ public static final class InputHandler { @SubscribeEvent(priority = EventPriority.HIGHEST) public void onChatMessage(ServerChatEvent event) { - if(event.getPlayer().isSpectator()) + if (event.getPlayer().isSpectator()) { return; + } List nearbyIndexes = getNearbyIndexes(event.getPlayer()); - if(!nearbyIndexes.isEmpty()) { + if (!nearbyIndexes.isEmpty()) { String msg = event.getMessage().toLowerCase().trim(); - for(TileCorporeaIndex index : nearbyIndexes) { + for (TileCorporeaIndex index : nearbyIndexes) { ICorporeaSpark spark = index.getSpark(); - if(spark != null) { + if (spark != null) { String name = ""; int count = 0; - for(Pattern pattern : patterns.keySet()) { + for (Pattern pattern : patterns.keySet()) { Matcher matcher = pattern.matcher(msg); - if(matcher.matches()) { + if (matcher.matches()) { IRegexStacker stacker = patterns.get(pattern); count = stacker.getCount(matcher); name = stacker.getName(matcher).toLowerCase().trim(); } } - if(name.equals("this")) { + if (name.equals("this")) { ItemStack stack = event.getPlayer().getHeldItemMainhand(); - if(!stack.isEmpty()) + if (!stack.isEmpty()) { name = stack.getDisplayName().getString().toLowerCase().trim(); + } } index.performPlayerRequest(event.getPlayer(), CorporeaHelper.createMatcher(name), count); diff --git a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaInterceptor.java b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaInterceptor.java index 4d57ce67c..a512621de 100644 --- a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaInterceptor.java +++ b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaInterceptor.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 19, 2015, 6:21:08 PM (GMT)] */ package vazkii.botania.common.block.tile.corporea; @@ -17,7 +15,7 @@ import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.registries.ObjectHolder; -import vazkii.botania.api.corporea.CorporeaHelper; + import vazkii.botania.api.corporea.ICorporeaInterceptor; import vazkii.botania.api.corporea.ICorporeaRequestMatcher; import vazkii.botania.api.corporea.ICorporeaSpark; @@ -30,8 +28,7 @@ import java.util.ArrayList; import java.util.List; public class TileCorporeaInterceptor extends TileCorporeaBase implements ICorporeaInterceptor { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.CORPOREA_INTERCEPTOR) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.CORPOREA_INTERCEPTOR) public static TileEntityType TYPE; public TileCorporeaInterceptor() { super(TYPE); @@ -43,43 +40,46 @@ public class TileCorporeaInterceptor extends TileCorporeaBase implements ICorpor @Override public void interceptRequestLast(ICorporeaRequestMatcher request, int count, ICorporeaSpark spark, ICorporeaSpark source, List stacks, List inventories, boolean doit) { List filter = getFilter(); - for(ItemStack stack : filter) - if(request.isStackValid(stack)) { + for (ItemStack stack : filter) { + if (request.isStackValid(stack)) { int missing = count; - for(ItemStack stack_ : stacks) + for (ItemStack stack_ : stacks) { missing -= stack_.getCount(); + } - if(missing > 0 && !getBlockState().get(BotaniaStateProps.POWERED)) { + if (missing > 0 && !getBlockState().get(BotaniaStateProps.POWERED)) { world.setBlockState(getPos(), getBlockState().with(BotaniaStateProps.POWERED, true)); world.getPendingBlockTicks().scheduleTick(getPos(), getBlockState().getBlock(), getBlockState().getBlock().tickRate(world)); TileEntity requestor = source.getSparkInventory().world.getTileEntity(source.getSparkInventory().pos); - for(Direction dir : Direction.values()) { + for (Direction dir : Direction.values()) { TileEntity tile = world.getTileEntity(pos.offset(dir)); - if(tile instanceof TileCorporeaRetainer) + if (tile instanceof TileCorporeaRetainer) { ((TileCorporeaRetainer) tile).setPendingRequest(requestor.getPos(), request, count); + } } return; } } + } } private List getFilter() { List filter = new ArrayList<>(); - for(Direction dir : Direction.values()) { + for (Direction dir : Direction.values()) { List frames = world.getEntitiesWithinAABB(ItemFrameEntity.class, new AxisAlignedBB(pos.offset(dir), pos.offset(dir).add(1, 1, 1))); - for(ItemFrameEntity frame : frames) { + for (ItemFrameEntity frame : frames) { Direction orientation = frame.getHorizontalFacing(); - if(orientation == dir) + if (orientation == dir) { filter.add(frame.getDisplayedItem()); + } } } return filter; } - } diff --git a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaRetainer.java b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaRetainer.java index 13633ea13..1c804a6e3 100644 --- a/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaRetainer.java +++ b/src/main/java/vazkii/botania/common/block/tile/corporea/TileCorporeaRetainer.java @@ -1,21 +1,18 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 28, 2015, 11:55:56 AM (GMT)] */ package vazkii.botania.common.block.tile.corporea; -import com.google.common.collect.HashBiMap; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.BlockPos; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.corporea.CorporeaHelper; import vazkii.botania.api.corporea.ICorporeaRequestMatcher; import vazkii.botania.api.corporea.ICorporeaRequestor; @@ -26,6 +23,7 @@ import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nullable; + import java.util.HashMap; import java.util.Map; import java.util.function.Function; @@ -33,8 +31,7 @@ import java.util.function.Function; import static vazkii.botania.api.corporea.CorporeaRequestDefaultMatchers.*; public class TileCorporeaRetainer extends TileMod { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.CORPOREA_RETAINER) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.CORPOREA_RETAINER) public static TileEntityType TYPE; private static final String TAG_REQUEST_X = "requestX"; private static final String TAG_REQUEST_Y = "requestY"; private static final String TAG_REQUEST_Z = "requestZ"; @@ -45,8 +42,7 @@ public class TileCorporeaRetainer extends TileMod { public static final Map, String> corporeaMatcherSerializers = new HashMap<>(); private BlockPos requestPos = BlockPos.ZERO; - @Nullable - private ICorporeaRequestMatcher request; + @Nullable private ICorporeaRequestMatcher request; private int requestCount; private int compValue; @@ -60,8 +56,9 @@ public class TileCorporeaRetainer extends TileMod { } public void setPendingRequest(BlockPos pos, ICorporeaRequestMatcher request, int requestCount) { - if(hasPendingRequest()) + if (hasPendingRequest()) { return; + } this.requestPos = pos; this.request = request; @@ -70,23 +67,24 @@ public class TileCorporeaRetainer extends TileMod { compValue = CorporeaHelper.signalStrengthForRequestSize(requestCount); world.updateComparatorOutputLevel(getPos(), getBlockState().getBlock()); } - + public int getComparatorValue() { return compValue; } - + public boolean hasPendingRequest() { return request != null; } public void fulfilRequest() { - if(!hasPendingRequest()) + if (!hasPendingRequest()) { return; + } ICorporeaSpark spark = CorporeaHelper.getSparkForBlock(world, requestPos); - if(spark != null) { + if (spark != null) { InvWithLocation inv = spark.getSparkInventory(); - if(inv != null && inv.world.getTileEntity(inv.pos) instanceof ICorporeaRequestor) { + if (inv != null && inv.world.getTileEntity(inv.pos) instanceof ICorporeaRequestor) { ICorporeaRequestor requestor = (ICorporeaRequestor) inv.world.getTileEntity(inv.pos); requestor.doCorporeaRequest(request, requestCount, spark); @@ -110,8 +108,9 @@ public class TileCorporeaRetainer extends TileMod { cmp.putString(TAG_REQUEST_TYPE, reqType); - if(reqType.length() > 0) + if (reqType.length() > 0) { request.writeToNBT(cmp); + } cmp.putInt(TAG_REQUEST_COUNT, requestCount); } @@ -125,16 +124,17 @@ public class TileCorporeaRetainer extends TileMod { requestPos = new BlockPos(x, y, z); String reqType = cmp.getString(TAG_REQUEST_TYPE); - if(corporeaMatcherDeserializers.containsKey(reqType)) + if (corporeaMatcherDeserializers.containsKey(reqType)) { request = corporeaMatcherDeserializers.get(reqType).apply(cmp); - else + } else { request = null; + } requestCount = cmp.getInt(TAG_REQUEST_COUNT); } - + public static void addCorporeaRequestMatcher(String type, Class clazz, Function deserializer) { corporeaMatcherSerializers.put(clazz, type); corporeaMatcherDeserializers.put(type, deserializer); - } + } } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TileBellows.java b/src/main/java/vazkii/botania/common/block/tile/mana/TileBellows.java index 5537b5678..92ec5df23 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TileBellows.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TileBellows.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 28, 2015, 5:27:43 PM (GMT)] */ package vazkii.botania.common.block.tile.mana; import com.mojang.datafixers.util.Pair; + import net.minecraft.block.FurnaceBlock; import net.minecraft.item.crafting.AbstractCookingRecipe; import net.minecraft.item.crafting.IRecipeType; @@ -25,6 +24,7 @@ import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraft.util.SoundCategory; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.common.Botania; import vazkii.botania.common.block.tile.TileMod; @@ -36,8 +36,7 @@ import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nullable; public class TileBellows extends TileMod implements ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.BELLOWS) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.BELLOWS) public static TileEntityType TYPE; private static final String TAG_ACTIVE = "active"; public float movePos; @@ -49,20 +48,22 @@ public class TileBellows extends TileMod implements ITickableTileEntity { } public void interact() { - if(moving == 0F) + if (moving == 0F) { setActive(true); + } } @Override public void tick() { boolean disable = true; TileEntity tile = getLinkedTile(); - if(!active && tile instanceof TilePool) { + if (!active && tile instanceof TilePool) { TilePool pool = (TilePool) tile; boolean transfer = pool.isDoingTransfer; - if(transfer) { - if(pool.ticksDoingTransfer > 0) + if (transfer) { + if (pool.ticksDoingTransfer > 0) { setActive(true); + } disable = false; } } @@ -72,35 +73,36 @@ public class TileBellows extends TileMod implements ITickableTileEntity { float incr = max / 20F; - if(movePos < max && active && moving >= 0F) { - if(moving == 0F) + if (movePos < max && active && moving >= 0F) { + if (moving == 0F) { world.playSound(null, pos, ModSounds.bellows, SoundCategory.BLOCKS, 0.1F, 3F); + } - if(tile instanceof AbstractFurnaceTileEntity) { + if (tile instanceof AbstractFurnaceTileEntity) { AbstractFurnaceTileEntity furnace = (AbstractFurnaceTileEntity) tile; Pair p = canSmelt(furnace); - if(p != null) { + if (p != null) { AbstractCookingRecipe recipe = p.getFirst(); boolean canSmelt = p.getSecond(); - if(canSmelt) { + if (canSmelt) { furnace.cookTime = Math.min(recipe.getCookTime() - 1, furnace.cookTime + 20); furnace.burnTime = Math.max(0, furnace.burnTime - 10); } - if(furnace instanceof FurnaceTileEntity + if (furnace instanceof FurnaceTileEntity && furnace.hasWorld() && furnace.getBlockState().get(FurnaceBlock.LIT)) { // [VanillaCopy] BlockFurnace - double d0 = (double)pos.getX() + 0.5D; - double d1 = (double)pos.getY(); - double d2 = (double)pos.getZ() + 0.5D; + double d0 = (double) pos.getX() + 0.5D; + double d1 = (double) pos.getY(); + double d2 = (double) pos.getZ() + 0.5D; Direction enumfacing = furnace.getBlockState().get(FurnaceBlock.FACING); Direction.Axis enumfacing$axis = enumfacing.getAxis(); double d3 = 0.52D; double d4 = world.rand.nextDouble() * 0.6D - 0.3D; - double d5 = enumfacing$axis == Direction.Axis.X ? (double)enumfacing.getXOffset() * 0.52D : d4; + double d5 = enumfacing$axis == Direction.Axis.X ? (double) enumfacing.getXOffset() * 0.52D : d4; double d6 = world.rand.nextDouble() * 6.0D / 16.0D; - double d7 = enumfacing$axis == Direction.Axis.Z ? (double)enumfacing.getZOffset() * 0.52D : d4; + double d7 = enumfacing$axis == Direction.Axis.Z ? (double) enumfacing.getZOffset() * 0.52D : d4; world.addParticle(ParticleTypes.SMOKE, d0 + d5, d1 + d6, d2 + d7, 0.0D, 0.0D, 0.0D); world.addParticle(ParticleTypes.FLAME, d0 + d5, d1 + d6, d2 + d7, 0.0D, 0.0D, 0.0D); } @@ -109,16 +111,17 @@ public class TileBellows extends TileMod implements ITickableTileEntity { movePos += incr * 3; moving = incr * 3; - if(movePos >= max) { + if (movePos >= max) { movePos = Math.min(max, movePos); moving = 0F; - if(disable) + if (disable) { setActive(false); + } } - } else if(movePos > min) { + } else if (movePos > min) { movePos -= incr; moving = -incr; - if(movePos <= min) { + if (movePos <= min) { movePos = Math.max(min, movePos); moving = 0F; } @@ -142,11 +145,12 @@ public class TileBellows extends TileMod implements ITickableTileEntity { } public void setActive(boolean active) { - if(!world.isRemote) { + if (!world.isRemote) { boolean diff = this.active != active; this.active = active; - if(diff) + if (diff) { VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos); + } } } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TileDistributor.java b/src/main/java/vazkii/botania/common/block/tile/mana/TileDistributor.java index 986bd9808..e1b0912bd 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TileDistributor.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TileDistributor.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 3, 2014, 1:51:34 AM (GMT)] */ package vazkii.botania.common.block.tile.mana; @@ -16,6 +14,7 @@ import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.mana.IManaPool; import vazkii.botania.api.mana.IManaReceiver; @@ -28,8 +27,7 @@ import java.util.ArrayList; import java.util.List; public class TileDistributor extends TileMod implements IManaReceiver, ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.DISTRIBUTOR) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.DISTRIBUTOR) public static TileEntityType TYPE; private final List validPools = new ArrayList<>(); public TileDistributor() { @@ -38,17 +36,19 @@ public class TileDistributor extends TileMod implements IManaReceiver, ITickable @Override public void tick() { - if (world.isRemote) + if (world.isRemote) { return; + } validPools.clear(); - for(Direction dir : MathHelper.HORIZONTALS) { + for (Direction dir : MathHelper.HORIZONTALS) { BlockPos pos = this.pos.offset(dir); - if(world.isBlockLoaded(pos)) { + if (world.isBlockLoaded(pos)) { TileEntity tileAt = world.getTileEntity(pos); - if(tileAt instanceof IManaPool && !tileAt.isRemoved()) { + if (tileAt instanceof IManaPool && !tileAt.isRemoved()) { IManaReceiver receiver = (IManaReceiver) tileAt; - if(!receiver.isFull()) + if (!receiver.isFull()) { validPools.add(receiver); + } } } } @@ -67,9 +67,9 @@ public class TileDistributor extends TileMod implements IManaReceiver, ITickable @Override public void recieveMana(int mana) { int tiles = validPools.size(); - if(tiles != 0) { + if (tiles != 0) { int manaForEach = mana / tiles; - for(IManaReceiver pool : validPools) { + for (IManaReceiver pool : validPools) { pool.recieveMana(manaForEach); TileEntity tile = (TileEntity) pool; VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, tile.getPos()); diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TileManaDetector.java b/src/main/java/vazkii/botania/common/block/tile/mana/TileManaDetector.java index 2f7a74923..ce74a8b76 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TileManaDetector.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TileManaDetector.java @@ -1,21 +1,21 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 10, 2014, 7:55:12 PM (GMT)] */ package vazkii.botania.common.block.tile.mana; import com.google.common.base.Predicates; + import net.minecraft.entity.projectile.ThrowableEntity; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.client.fx.SparkleParticleData; @@ -24,8 +24,7 @@ import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; public class TileManaDetector extends TileMod implements ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.MANA_DETECTOR) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.MANA_DETECTOR) public static TileEntityType TYPE; public TileManaDetector() { super(TYPE); @@ -35,14 +34,16 @@ public class TileManaDetector extends TileMod implements ITickableTileEntity { public void tick() { boolean state = getBlockState().get(BotaniaStateProps.POWERED); boolean expectedState = world.getEntitiesWithinAABB(ThrowableEntity.class, new AxisAlignedBB(pos, pos.add(1, 1, 1)), Predicates.instanceOf(IManaBurst.class)).size() != 0; - if(state != expectedState && !world.isRemote) + if (state != expectedState && !world.isRemote) { world.setBlockState(getPos(), getBlockState().with(BotaniaStateProps.POWERED, expectedState)); + } - if(expectedState) - for(int i = 0; i < 4; i++) { - SparkleParticleData data = SparkleParticleData.sparkle(0.7F + 0.5F * (float) Math.random(), 1F, 0.2F, 0.2F, 5); - world.addParticle(data, pos.getX() + Math.random(), pos.getY() + Math.random(), pos.getZ() + Math.random(), 0, 0, 0); - } + if (expectedState) { + for (int i = 0; i < 4; i++) { + SparkleParticleData data = SparkleParticleData.sparkle(0.7F + 0.5F * (float) Math.random(), 1F, 0.2F, 0.2F, 5); + world.addParticle(data, pos.getX() + Math.random(), pos.getY() + Math.random(), pos.getZ() + Math.random(), 0, 0, 0); + } + } } } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TileManaVoid.java b/src/main/java/vazkii/botania/common/block/tile/mana/TileManaVoid.java index 81c3c5a26..240b39d84 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TileManaVoid.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TileManaVoid.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 5, 2014, 12:59:27 AM (GMT)] */ package vazkii.botania.common.block.tile.mana; import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.mana.IClientManaHandler; import vazkii.botania.client.fx.SparkleParticleData; import vazkii.botania.common.block.tile.TileMod; @@ -19,8 +18,7 @@ import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; public class TileManaVoid extends TileMod implements IClientManaHandler { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.MANA_VOID) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.MANA_VOID) public static TileEntityType TYPE; public TileManaVoid() { super(TYPE); @@ -38,11 +36,12 @@ public class TileManaVoid extends TileMod implements IClientManaHandler { @Override public void recieveMana(int mana) { - if(mana > 0) - for(int i = 0; i < 10; i++) { - SparkleParticleData data = SparkleParticleData.sparkle(0.7F + 0.5F * (float) Math.random(), 0.2F, 0.2F, 0.2F, 5); - world.addParticle(data, pos.getX() + Math.random(), pos.getY() + Math.random(), pos.getZ() + Math.random(), 0, 0, 0); - } + if (mana > 0) { + for (int i = 0; i < 10; i++) { + SparkleParticleData data = SparkleParticleData.sparkle(0.7F + 0.5F * (float) Math.random(), 0.2F, 0.2F, 0.2F, 5); + world.addParticle(data, pos.getX() + Math.random(), pos.getY() + Math.random(), pos.getZ() + Math.random(), 0, 0, 0); + } + } } @Override diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TilePool.java b/src/main/java/vazkii/botania/common/block/tile/mana/TilePool.java index af53d3210..e24cb1dc2 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TilePool.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TilePool.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 26, 2014, 12:23:55 AM (GMT)] */ package vazkii.botania.common.block.tile.mana; import com.google.common.base.Predicates; import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; @@ -32,7 +31,9 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.registries.ObjectHolder; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.item.IManaDissolvable; @@ -63,12 +64,12 @@ import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.ArrayList; import java.util.List; public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAttachable, IThrottledPacket, ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.POOL) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.POOL) public static TileEntityType TYPE; public static final int PARTICLE_COLOR = 0x00C6FF; public static final int MAX_MANA = 1000000; private static final int MAX_MANA_DILLUTED = 10000; @@ -120,7 +121,7 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt public void recieveMana(int mana) { int old = this.mana; this.mana = Math.max(0, Math.min(getCurrentMana() + mana, manaCap)); - if(old != this.mana) { + if (old != this.mana) { markDirty(); world.updateComparatorOutputLevel(pos, getBlockState().getBlock()); markDispatchable(); @@ -141,8 +142,9 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt public static int calculateComparatorLevel(int mana, int max) { int val = (int) ((double) mana / (double) max * 15.0); - if(mana > 0) + if (mana > 0) { val = Math.max(val, 1); + } return val; } @@ -152,37 +154,38 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt for (RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes.values()) { if (recipe.matches(stack)) { - if(recipe.getCatalyst() == null) + if (recipe.getCatalyst() == null) { matchingNonCatRecipes.add(recipe); - else if (recipe.getCatalyst() == state) + } else if (recipe.getCatalyst() == state) { matchingCatRecipes.add(recipe); + } } } // Recipes with matching catalyst take priority above recipes with no catalyst specified - return !matchingCatRecipes.isEmpty() ? matchingCatRecipes.get(0) : - !matchingNonCatRecipes.isEmpty() ? matchingNonCatRecipes.get(0) : - null; + return !matchingCatRecipes.isEmpty() ? matchingCatRecipes.get(0) : !matchingNonCatRecipes.isEmpty() ? matchingNonCatRecipes.get(0) : null; } public boolean collideEntityItem(ItemEntity item) { - if(world.isRemote || !item.isAlive() || item.getItem().isEmpty()) + if (world.isRemote || !item.isAlive() || item.getItem().isEmpty()) { return false; + } ItemStack stack = item.getItem(); - if(stack.getItem() instanceof IManaDissolvable) { + if (stack.getItem() instanceof IManaDissolvable) { ((IManaDissolvable) stack.getItem()).onDissolveTick(this, stack, item); } - if(item.age > 100 && item.age < 130) + if (item.age > 100 && item.age < 130) { return false; + } RecipeManaInfusion recipe = getMatchingRecipe(stack, world.getBlockState(pos.down())); - if(recipe != null) { + if (recipe != null) { int mana = recipe.getManaToConsume(); - if(getCurrentMana() >= mana) { + if (getCurrentMana() >= mana) { recieveMana(-mana); stack.shrink(1); @@ -202,7 +205,7 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt } private void craftingFanciness() { - if(soundTicks == 0) { + if (soundTicks == 0) { world.playSound(null, pos, ModSounds.manaPoolCraft, SoundCategory.BLOCKS, 0.4F, 4F); soundTicks = 6; } @@ -212,47 +215,50 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt @Override public boolean receiveClientEvent(int event, int param) { - switch(event) { - case CRAFT_EFFECT_EVENT: { - if(world.isRemote) { - for(int i = 0; i < 25; i++) { - float red = (float) Math.random(); - float green = (float) Math.random(); - float blue = (float) Math.random(); - SparkleParticleData data = SparkleParticleData.sparkle((float) Math.random(), red, green, blue, 10); - world.addParticle(data, pos.getX() + 0.5 + Math.random() * 0.4 - 0.2, pos.getY() + 0.75, pos.getZ() + 0.5 + Math.random() * 0.4 - 0.2, 0, 0, 0); - } + switch (event) { + case CRAFT_EFFECT_EVENT: { + if (world.isRemote) { + for (int i = 0; i < 25; i++) { + float red = (float) Math.random(); + float green = (float) Math.random(); + float blue = (float) Math.random(); + SparkleParticleData data = SparkleParticleData.sparkle((float) Math.random(), red, green, blue, 10); + world.addParticle(data, pos.getX() + 0.5 + Math.random() * 0.4 - 0.2, pos.getY() + 0.75, pos.getZ() + 0.5 + Math.random() * 0.4 - 0.2, 0, 0, 0); } + } - return true; - } - case CHARGE_EFFECT_EVENT: { - if(world.isRemote) { - if(ConfigHandler.COMMON.chargingAnimationEnabled.get()) { - boolean outputting = param == 1; - Vector3 itemVec = Vector3.fromBlockPos(pos).add(0.5, 0.5 + Math.random() * 0.3, 0.5); - Vector3 tileVec = Vector3.fromBlockPos(pos).add(0.2 + Math.random() * 0.6, 0, 0.2 + Math.random() * 0.6); - Botania.proxy.lightningFX(outputting ? tileVec : itemVec, - outputting ? itemVec : tileVec, 80, world.rand.nextLong(), 0x4400799c, 0x4400C6FF); - } + return true; + } + case CHARGE_EFFECT_EVENT: { + if (world.isRemote) { + if (ConfigHandler.COMMON.chargingAnimationEnabled.get()) { + boolean outputting = param == 1; + Vector3 itemVec = Vector3.fromBlockPos(pos).add(0.5, 0.5 + Math.random() * 0.3, 0.5); + Vector3 tileVec = Vector3.fromBlockPos(pos).add(0.2 + Math.random() * 0.6, 0, 0.2 + Math.random() * 0.6); + Botania.proxy.lightningFX(outputting ? tileVec : itemVec, + outputting ? itemVec : tileVec, 80, world.rand.nextLong(), 0x4400799c, 0x4400C6FF); } - return true; } - default: return super.receiveClientEvent(event, param); + return true; + } + default: + return super.receiveClientEvent(event, param); } } @Override public void tick() { - if(manaCap == -1) + if (manaCap == -1) { manaCap = ((BlockPool) getBlockState().getBlock()).variant == BlockPool.Variant.DILUTED ? MAX_MANA_DILLUTED : MAX_MANA; + } - if(!ManaNetworkHandler.instance.isPoolIn(this) && !isRemoved()) + if (!ManaNetworkHandler.instance.isPoolIn(this) && !isRemoved()) { ManaNetworkEvent.addPool(this); + } - if(world.isRemote) { + if (world.isRemote) { double particleChance = 1F - (double) getCurrentMana() / (double) manaCap * 0.1; - if(Math.random() > particleChance) { + if (Math.random() > particleChance) { float red = (PARTICLE_COLOR >> 16 & 0xFF) / 255F; float green = (PARTICLE_COLOR >> 8 & 0xFF) / 255F; float blue = (PARTICLE_COLOR & 0xFF) / 255F; @@ -265,48 +271,53 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt boolean wasDoingTransfer = isDoingTransfer; isDoingTransfer = false; - if(soundTicks > 0) { + if (soundTicks > 0) { soundTicks--; } - if(sendPacket && ticks % 10 == 0) { + if (sendPacket && ticks % 10 == 0) { VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); sendPacket = false; } List items = world.getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(pos, pos.add(1, 1, 1))); - for(ItemEntity item : items) { - if(!item.isAlive()) + for (ItemEntity item : items) { + if (!item.isAlive()) { continue; + } ItemStack stack = item.getItem(); - if(!stack.isEmpty() && stack.getItem() instanceof IManaItem) { + if (!stack.isEmpty() && stack.getItem() instanceof IManaItem) { IManaItem mana = (IManaItem) stack.getItem(); - if(outputting && mana.canReceiveManaFromPool(stack, this) || !outputting && mana.canExportManaToPool(stack, this)) { + if (outputting && mana.canReceiveManaFromPool(stack, this) || !outputting && mana.canExportManaToPool(stack, this)) { boolean didSomething = false; int bellowCount = 0; - if(outputting) - for(Direction dir : MathHelper.HORIZONTALS) { + if (outputting) { + for (Direction dir : MathHelper.HORIZONTALS) { TileEntity tile = world.getTileEntity(pos.offset(dir)); - if(tile instanceof TileBellows && ((TileBellows) tile).getLinkedTile() == this) + if (tile instanceof TileBellows && ((TileBellows) tile).getLinkedTile() == this) { bellowCount++; + } } + } int transfRate = 1000 * (bellowCount + 1); - if(outputting) { - if(canSpare) { - if(getCurrentMana() > 0 && mana.getMana(stack) < mana.getMaxMana(stack)) + if (outputting) { + if (canSpare) { + if (getCurrentMana() > 0 && mana.getMana(stack) < mana.getMaxMana(stack)) { didSomething = true; + } int manaVal = Math.min(transfRate, Math.min(getCurrentMana(), mana.getMaxMana(stack) - mana.getMana(stack))); mana.addMana(stack, manaVal); recieveMana(-manaVal); } } else { - if(canAccept) { - if(mana.getMana(stack) > 0 && !isFull()) + if (canAccept) { + if (mana.getMana(stack) > 0 && !isFull()) { didSomething = true; + } int manaVal = Math.min(transfRate, Math.min(manaCap - getCurrentMana(), mana.getMana(stack))); mana.addMana(stack, -manaVal); @@ -314,8 +325,8 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt } } - if(didSomething) { - if(ConfigHandler.COMMON.chargingAnimationEnabled.get() && world.rand.nextInt(20) == 0) { + if (didSomething) { + if (ConfigHandler.COMMON.chargingAnimationEnabled.get() && world.rand.nextInt(20) == 0) { world.addBlockEvent(getPos(), getBlockState().getBlock(), CHARGE_EFFECT_EVENT, outputting ? 1 : 0); } isDoingTransfer = outputting; @@ -324,12 +335,13 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt } } - if(isDoingTransfer) + if (isDoingTransfer) { ticksDoingTransfer++; - else { + } else { ticksDoingTransfer = 0; - if(wasDoingTransfer) + if (wasDoingTransfer) { VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + } } ticks++; @@ -356,38 +368,45 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt outputting = cmp.getBoolean(TAG_OUTPUTTING); color = DyeColor.byId(cmp.getInt(TAG_COLOR)); - if(cmp.contains(TAG_MANA_CAP)) + if (cmp.contains(TAG_MANA_CAP)) { manaCap = cmp.getInt(TAG_MANA_CAP); - if(cmp.contains(TAG_CAN_ACCEPT)) + } + if (cmp.contains(TAG_CAN_ACCEPT)) { canAccept = cmp.getBoolean(TAG_CAN_ACCEPT); - if(cmp.contains(TAG_CAN_SPARE)) + } + if (cmp.contains(TAG_CAN_SPARE)) { canSpare = cmp.getBoolean(TAG_CAN_SPARE); + } fragile = cmp.getBoolean(TAG_FRAGILE); - if(cmp.contains(TAG_INPUT_KEY)) + if (cmp.contains(TAG_INPUT_KEY)) { inputKey = cmp.getString(TAG_INPUT_KEY); - if(cmp.contains(TAG_OUTPUT_KEY)) + } + if (cmp.contains(TAG_OUTPUT_KEY)) { inputKey = cmp.getString(TAG_OUTPUT_KEY); + } - if(cmp.contains(TAG_KNOWN_MANA)) + if (cmp.contains(TAG_KNOWN_MANA)) { knownMana = cmp.getInt(TAG_KNOWN_MANA); + } } public void onWanded(PlayerEntity player, ItemStack wand) { - if(player == null || player.isSneaking()) { + if (player == null || player.isSneaking()) { outputting = !outputting; VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos); } - if(!world.isRemote) { + if (!world.isRemote) { CompoundNBT nbttagcompound = new CompoundNBT(); writePacketNBT(nbttagcompound); nbttagcompound.putInt(TAG_KNOWN_MANA, getCurrentMana()); - if(player instanceof ServerPlayerEntity) + if (player instanceof ServerPlayerEntity) { ((ServerPlayerEntity) player).connection.sendPacket(new SUpdateTileEntityPacket(pos, -999, nbttagcompound)); + } } - if(player == null) { + if (player == null) { world.playSound(null, getPos(), ModSounds.ding, SoundCategory.PLAYERS, 0.11F, 1F); } else { world.playSound(null, player.getX(), player.getY(), player.getZ(), ModSounds.ding, SoundCategory.PLAYERS, 0.11F, 1F); @@ -463,7 +482,7 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt @Override public ISparkEntity getAttachedSpark() { List sparks = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos.up(), pos.up().add(1, 1, 1)), Predicates.instanceOf(ISparkEntity.class)); - if(sparks.size() == 1) { + if (sparks.size() == 1) { Entity e = (Entity) sparks.get(0); return (ISparkEntity) e; } @@ -479,11 +498,13 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt @Override public int getAvailableSpaceForMana() { int space = Math.max(0, manaCap - getCurrentMana()); - if(space > 0) + if (space > 0) { return space; - else if(world.getBlockState(pos.down()).getBlock() == ModBlocks.manaVoid) + } else if (world.getBlockState(pos.down()).getBlock() == ModBlocks.manaVoid) { return manaCap; - else return 0; + } else { + return 0; + } } @Override diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TilePrism.java b/src/main/java/vazkii/botania/common/block/tile/mana/TilePrism.java index 986bf7d8a..39a2ae4ef 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TilePrism.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TilePrism.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 17, 2015, 7:27:04 PM (GMT)] */ package vazkii.botania.common.block.tile.mana; @@ -15,6 +13,7 @@ import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntityType; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.mana.BurstProperties; @@ -29,8 +28,7 @@ import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; public class TilePrism extends TileSimpleInventory { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.PRISM) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.PRISM) public static TileEntityType TYPE; public TilePrism() { super(TYPE); @@ -41,12 +39,12 @@ public class TilePrism extends TileSimpleInventory { boolean active = !getBlockState().get(BotaniaStateProps.POWERED); boolean valid = !lens.isEmpty() && lens.getItem() instanceof ILens && (!(lens.getItem() instanceof ITinyPlanetExcempt) || ((ITinyPlanetExcempt) lens.getItem()).shouldPull(lens)); - if(active) { + if (active) { burst.setSourceLens(valid ? lens.copy() : ItemStack.EMPTY); burst.setColor(0xFFFFFF); burst.setGravity(0F); - if(valid) { + if (valid) { Entity burstEntity = (Entity) burst; BurstProperties properties = new BurstProperties(burst.getStartingMana(), burst.getMinManaLoss(), burst.getManaLossPerTick(), burst.getGravity(), 1F, burst.getColor()); @@ -75,9 +73,11 @@ public class TilePrism extends TileSimpleInventory { @Nonnull @Override public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { - if(!stack.isEmpty() && stack.getItem() instanceof ILens) + if (!stack.isEmpty() && stack.getItem() instanceof ILens) { return super.insertItem(slot, stack, simulate); - else return stack; + } else { + return stack; + } } }; } @@ -86,7 +86,7 @@ public class TilePrism extends TileSimpleInventory { public void markDirty() { super.markDirty(); VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); - if(world != null && !world.isRemote) { + if (world != null && !world.isRemote) { BlockState state = getBlockState(); boolean hasLens = !itemHandler.getStackInSlot(0).isEmpty(); if (state.getBlock() != ModBlocks.prism || state.get(BotaniaStateProps.HAS_LENS) != hasLens) { diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TilePump.java b/src/main/java/vazkii/botania/common/block/tile/mana/TilePump.java index 23183e405..5df66ede9 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TilePump.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TilePump.java @@ -1,41 +1,27 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 18, 2015, 3:16:57 PM (GMT)] */ package vazkii.botania.common.block.tile.mana; -import com.google.common.collect.ImmutableMap; import net.minecraft.nbt.CompoundNBT; import net.minecraft.particles.ParticleTypes; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.client.model.ModelLoaderRegistry; -import net.minecraftforge.common.animation.TimeValues; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.model.animation.CapabilityAnimation; -import net.minecraftforge.common.model.animation.IAnimationStateMachine; -import net.minecraftforge.common.util.LazyOptional; -import net.minecraftforge.fml.loading.FMLEnvironment; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.common.block.tile.TileMod; import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; -import javax.annotation.Nonnull; - public class TilePump extends TileMod implements ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.PUMP) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.PUMP) public static TileEntityType TYPE; private static final String TAG_ACTIVE = "active"; public float innerRingPos; @@ -55,9 +41,9 @@ public class TilePump extends TileMod implements ITickableTileEntity { @Override public void tick() { hasRedstone = false; - for(Direction dir : Direction.values()) { + for (Direction dir : Direction.values()) { int redstoneSide = world.getRedstonePower(pos.offset(dir), dir); - if(redstoneSide > 0) { + if (redstoneSide > 0) { hasRedstone = true; break; } @@ -68,36 +54,41 @@ public class TilePump extends TileMod implements ITickableTileEntity { float incr = max / 10F; - if(innerRingPos < max && active && moving >= 0F) { + if (innerRingPos < max && active && moving >= 0F) { innerRingPos += incr; moving = incr; - if(innerRingPos >= max) { + if (innerRingPos >= max) { innerRingPos = Math.min(max, innerRingPos); moving = 0F; - for(int x = 0; x < 2; x++) + for (int x = 0; x < 2; x++) { world.addParticle(ParticleTypes.SMOKE, getPos().getX() + Math.random(), getPos().getY() + Math.random(), getPos().getZ() + Math.random(), 0, 0, 0); + } } - } else if(innerRingPos > min) { + } else if (innerRingPos > min) { innerRingPos -= incr * 2; moving = -incr * 2; - if(innerRingPos <= min) { + if (innerRingPos <= min) { innerRingPos = Math.max(min, innerRingPos); moving = 0F; } } - if(!hasCartOnTop) + if (!hasCartOnTop) { comparator = 0; - if(!hasCart && active) + } + if (!hasCart && active) { setActive(false); - if(active && hasRedstone) + } + if (active && hasRedstone) { setActive(false); + } hasCart = false; hasCartOnTop = false; - if(comparator != lastComparator) + if (comparator != lastComparator) { world.updateComparatorOutputLevel(pos, getBlockState().getBlock()); + } lastComparator = comparator; } @@ -112,11 +103,12 @@ public class TilePump extends TileMod implements ITickableTileEntity { } public void setActive(boolean active) { - if(!world.isRemote) { + if (!world.isRemote) { boolean diff = this.active != active; this.active = active; - if(diff) + if (diff) { VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos); + } } } } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TileRFGenerator.java b/src/main/java/vazkii/botania/common/block/tile/mana/TileRFGenerator.java index f12d7acda..2a1c70386 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TileRFGenerator.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TileRFGenerator.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 29, 2014, 10:01:32 PM (GMT)] */ package vazkii.botania.common.block.tile.mana; @@ -21,6 +19,7 @@ import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.energy.IEnergyStorage; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.mana.IManaReceiver; import vazkii.botania.common.block.tile.TileMod; import vazkii.botania.common.lib.LibBlockNames; @@ -30,8 +29,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; public class TileRFGenerator extends TileMod implements IManaReceiver, ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.FLUXFIELD) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.FLUXFIELD) public static TileEntityType TYPE; private static final int MANA_TO_FE = 10; private static final int MAX_ENERGY = 1280 * MANA_TO_FE; @@ -50,11 +48,25 @@ public class TileRFGenerator extends TileMod implements IManaReceiver, ITickable } // todo allow pulling? - @Override public boolean canExtract() { return false; } - @Override public int extractEnergy(int maxExtract, boolean simulate) { return 0; } + @Override + public boolean canExtract() { + return false; + } - @Override public int receiveEnergy(int maxReceive, boolean simulate) { return 0; } - @Override public boolean canReceive() { return false; } + @Override + public int extractEnergy(int maxExtract, boolean simulate) { + return 0; + } + + @Override + public int receiveEnergy(int maxReceive, boolean simulate) { + return 0; + } + + @Override + public boolean canReceive() { + return false; + } }; private final LazyOptional energyCap = LazyOptional.of(() -> energyHandler); @@ -65,14 +77,16 @@ public class TileRFGenerator extends TileMod implements IManaReceiver, ITickable @Override @Nonnull public LazyOptional getCapability(@Nonnull Capability cap, @Nullable Direction side) { - if(cap == CapabilityEnergy.ENERGY) { + if (cap == CapabilityEnergy.ENERGY) { return energyCap.cast(); - } else return super.getCapability(cap, side); + } else { + return super.getCapability(cap, side); + } } @Override public void tick() { - if(!world.isRemote) { + if (!world.isRemote) { int transfer = Math.min(energy, 160 * MANA_TO_FE); energy -= transfer; energy += transmitEnergy(transfer); @@ -80,29 +94,31 @@ public class TileRFGenerator extends TileMod implements IManaReceiver, ITickable } private int transmitEnergy(int energy) { - for(Direction e : Direction.values()) { + for (Direction e : Direction.values()) { BlockPos neighbor = getPos().offset(e); - if(!world.isBlockLoaded(neighbor)) + if (!world.isBlockLoaded(neighbor)) { continue; + } TileEntity te = world.getTileEntity(neighbor); - if(te == null) + if (te == null) { continue; + } LazyOptional storage = LazyOptional.empty(); - if(te.getCapability(CapabilityEnergy.ENERGY, e.getOpposite()).isPresent()) { + if (te.getCapability(CapabilityEnergy.ENERGY, e.getOpposite()).isPresent()) { storage = te.getCapability(CapabilityEnergy.ENERGY, e.getOpposite()); - } else if(te.getCapability(CapabilityEnergy.ENERGY, null).isPresent()) { + } else if (te.getCapability(CapabilityEnergy.ENERGY, null).isPresent()) { storage = te.getCapability(CapabilityEnergy.ENERGY, null); } - - if(storage.isPresent()) { + if (storage.isPresent()) { energy -= storage.orElseThrow(NullPointerException::new).receiveEnergy(energy, false); - if (energy <= 0) + if (energy <= 0) { return 0; + } } } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TileSpreader.java b/src/main/java/vazkii/botania/common/block/tile/mana/TileSpreader.java index dd6e3cf72..e86482200 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TileSpreader.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TileSpreader.java @@ -1,21 +1,18 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 25, 2014, 9:40:57 PM (GMT)] */ package vazkii.botania.common.block.tile.mana; import com.google.common.base.Predicates; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.RenderHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity; @@ -41,7 +38,7 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.registries.ObjectHolder; -import org.lwjgl.opengl.GL11; + import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.mana.BurstProperties; @@ -58,7 +55,6 @@ import vazkii.botania.api.mana.IThrottledPacket; import vazkii.botania.api.mana.ManaNetworkEvent; import vazkii.botania.api.wand.IWandBindable; import vazkii.botania.client.core.handler.HUDHandler; -import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.mana.BlockSpreader; import vazkii.botania.common.block.tile.TileSimpleInventory; import vazkii.botania.common.core.handler.ConfigHandler; @@ -72,12 +68,12 @@ import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; import javax.annotation.Nullable; + import java.util.List; import java.util.UUID; public class TileSpreader extends TileSimpleInventory implements IManaCollector, IWandBindable, IKeyLocked, IThrottledPacket, IManaSpreader, IDirectioned, ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.SPREADER) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.SPREADER) public static TileEntityType TYPE; private static final int TICKS_ALLOWED_WITHOUT_PINGBACK = 20; private static final double PINGBACK_EXPIRED_SEARCH_DISTANCE = 0.5; @@ -132,8 +128,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, private int knownMana = -1; public float rotationX, rotationY; - @Nullable - public DyeColor paddingColor = null; + @Nullable public DyeColor paddingColor = null; private boolean requestsClientUpdate = false; private boolean hasReceivedInitialPacket = false; @@ -185,22 +180,23 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, public void tick() { boolean inNetwork = ManaNetworkHandler.instance.isCollectorIn(this); boolean wasInNetwork = inNetwork; - if(!inNetwork && !isRemoved()) { + if (!inNetwork && !isRemoved()) { ManaNetworkEvent.addCollector(this); } boolean redstone = false; - for(Direction dir : Direction.values()) { + for (Direction dir : Direction.values()) { TileEntity tileAt = world.getTileEntity(pos.offset(dir)); - if(world.isBlockLoaded(pos.offset(dir)) && tileAt instanceof IManaPool) { + if (world.isBlockLoaded(pos.offset(dir)) && tileAt instanceof IManaPool) { IManaPool pool = (IManaPool) tileAt; - if(wasInNetwork && (pool != receiver || getVariant() == BlockSpreader.Variant.REDSTONE)) { - if(pool instanceof IKeyLocked && !((IKeyLocked) pool).getOutputKey().equals(getInputKey())) + if (wasInNetwork && (pool != receiver || getVariant() == BlockSpreader.Variant.REDSTONE)) { + if (pool instanceof IKeyLocked && !((IKeyLocked) pool).getOutputKey().equals(getInputKey())) { continue; + } int manaInPool = pool.getCurrentMana(); - if(manaInPool > 0 && !isFull()) { + if (manaInPool > 0 && !isFull()) { int manaMissing = getMaxMana() - mana; int manaToRemove = Math.min(manaInPool, manaMissing); pool.recieveMana(-manaToRemove); @@ -210,15 +206,17 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, } int redstoneSide = world.getRedstonePower(pos.offset(dir), dir); - if(redstoneSide > 0) + if (redstoneSide > 0) { redstone = true; + } } - if(needsNewBurstSimulation()) + if (needsNewBurstSimulation()) { checkForReceiver(); + } - if(!canShootBurst) - if(pingbackTicks <= 0) { + if (!canShootBurst) { + if (pingbackTicks <= 0) { double x = lastPingbackX; double y = lastPingbackY; double z = lastPingbackZ; @@ -226,41 +224,53 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, List bursts = world.getEntitiesWithinAABB(ThrowableEntity.class, aabb, Predicates.instanceOf(IManaBurst.class)); IManaBurst found = null; UUID identity = getIdentifier(); - for(IManaBurst burst : (List) bursts) - if(burst != null && identity.equals(burst.getShooterUUID())) { + for (IManaBurst burst : (List) bursts) { + if (burst != null && identity.equals(burst.getShooterUUID())) { found = burst; break; } + } - if(found != null) + if (found != null) { found.ping(); - else setCanShoot(true); - } else pingbackTicks--; + } else { + setCanShoot(true); + } + } else { + pingbackTicks--; + } + } boolean shouldShoot = !redstone; boolean isredstone = getVariant() == BlockSpreader.Variant.REDSTONE; - if(isredstone) + if (isredstone) { shouldShoot = redstone && !redstoneLastTick; + } - if(shouldShoot && receiver != null && receiver instanceof IKeyLocked) + if (shouldShoot && receiver != null && receiver instanceof IKeyLocked) { shouldShoot = ((IKeyLocked) receiver).getInputKey().equals(getOutputKey()); + } ItemStack lens = itemHandler.getStackInSlot(0); ILensControl control = getLensController(lens); - if(control != null) { - if(isredstone) { - if(shouldShoot) + if (control != null) { + if (isredstone) { + if (shouldShoot) { control.onControlledSpreaderPulse(lens, this, redstone); - } else control.onControlledSpreaderTick(lens, this, redstone); + } + } else { + control.onControlledSpreaderTick(lens, this, redstone); + } shouldShoot &= control.allowBurstShooting(lens, this, redstone); } - if(shouldShoot) + if (shouldShoot) { tryShootBurst(); + } - if(receiverLastTick != receiver && !world.isRemote) { + if (receiverLastTick != receiver && !world.isRemote) { requestsClientUpdate = true; VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos); } @@ -312,23 +322,28 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, public void readPacketNBT(CompoundNBT cmp) { super.readPacketNBT(cmp); - if(cmp.getBoolean(TAG_HAS_IDENTITY)) { + if (cmp.getBoolean(TAG_HAS_IDENTITY)) { long most = cmp.getLong(TAG_UUID_MOST); long least = cmp.getLong(TAG_UUID_LEAST); UUID identity = getIdentifierUnsafe(); - if(identity == null || most != identity.getMostSignificantBits() || least != identity.getLeastSignificantBits()) + if (identity == null || most != identity.getMostSignificantBits() || least != identity.getLeastSignificantBits()) { this.identity = new UUID(most, least); - } else getIdentifier(); + } + } else { + getIdentifier(); + } mana = cmp.getInt(TAG_MANA); rotationX = cmp.getFloat(TAG_ROTATION_X); rotationY = cmp.getFloat(TAG_ROTATION_Y); requestsClientUpdate = cmp.getBoolean(TAG_REQUEST_UPDATE); - if(cmp.contains(TAG_INPUT_KEY)) + if (cmp.contains(TAG_INPUT_KEY)) { inputKey = cmp.getString(TAG_INPUT_KEY); - if(cmp.contains(TAG_OUTPUT_KEY)) + } + if (cmp.contains(TAG_OUTPUT_KEY)) { inputKey = cmp.getString(TAG_OUTPUT_KEY); + } mapmakerOverride = cmp.getBoolean(TAG_MAPMAKER_OVERRIDE); mmForcedColor = cmp.getInt(TAG_FORCED_COLOR); @@ -338,32 +353,40 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, mmForcedGravity = cmp.getFloat(TAG_FORCED_GRAVITY); mmForcedVelocityMultiplier = cmp.getFloat(TAG_FORCED_VELOCITY_MULTIPLIER); - if(cmp.contains(TAG_KNOWN_MANA)) + if (cmp.contains(TAG_KNOWN_MANA)) { knownMana = cmp.getInt(TAG_KNOWN_MANA); - if(cmp.contains(TAG_PADDING_COLOR)) + } + if (cmp.contains(TAG_PADDING_COLOR)) { paddingColor = cmp.getInt(TAG_PADDING_COLOR) == -1 ? null : DyeColor.byId(cmp.getInt(TAG_PADDING_COLOR)); - if(cmp.contains(TAG_CAN_SHOOT_BURST)) + } + if (cmp.contains(TAG_CAN_SHOOT_BURST)) { canShootBurst = cmp.getBoolean(TAG_CAN_SHOOT_BURST); + } pingbackTicks = cmp.getInt(TAG_PINGBACK_TICKS); lastPingbackX = cmp.getDouble(TAG_LAST_PINGBACK_X); lastPingbackY = cmp.getDouble(TAG_LAST_PINGBACK_Y); lastPingbackZ = cmp.getDouble(TAG_LAST_PINGBACK_Z); - if(requestsClientUpdate && world != null) { + if (requestsClientUpdate && world != null) { int x = cmp.getInt(TAG_FORCE_CLIENT_BINDING_X); int y = cmp.getInt(TAG_FORCE_CLIENT_BINDING_Y); int z = cmp.getInt(TAG_FORCE_CLIENT_BINDING_Z); - if(y != -1) { + if (y != -1) { TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); - if(tile instanceof IManaReceiver) + if (tile instanceof IManaReceiver) { receiver = (IManaReceiver) tile; - else receiver = null; - } else receiver = null; + } else { + receiver = null; + } + } else { + receiver = null; + } } - if(world != null && world.isRemote) + if (world != null && world.isRemote) { hasReceivedInitialPacket = true; + } } @Override @@ -377,34 +400,37 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, } public void onWanded(PlayerEntity player, ItemStack wand) { - if(player == null) + if (player == null) { return; + } - if(!player.isSneaking()) { - if(!world.isRemote) { + if (!player.isSneaking()) { + if (!world.isRemote) { CompoundNBT nbttagcompound = new CompoundNBT(); writePacketNBT(nbttagcompound); nbttagcompound.putInt(TAG_KNOWN_MANA, mana); - if(player instanceof ServerPlayerEntity) + if (player instanceof ServerPlayerEntity) { ((ServerPlayerEntity) player).connection.sendPacket(new SUpdateTileEntityPacket(pos, -999, nbttagcompound)); + } } world.playSound(null, player.getX(), player.getY(), player.getZ(), ModSounds.ding, SoundCategory.PLAYERS, 0.1F, 1); } else { RayTraceResult pos = Item.rayTrace(world, player, RayTraceContext.FluidMode.ANY); - if(pos instanceof BlockRayTraceResult && !world.isRemote) { + if (pos instanceof BlockRayTraceResult && !world.isRemote) { double x = pos.getHitVec().x - getPos().getX() - 0.5; double y = pos.getHitVec().y - getPos().getY() - 0.5; double z = pos.getHitVec().z - getPos().getZ() - 0.5; BlockRayTraceResult bpos = (BlockRayTraceResult) pos; - if(bpos.getFace() != Direction.DOWN && bpos.getFace() != Direction.UP) { + if (bpos.getFace() != Direction.DOWN && bpos.getFace() != Direction.UP) { Vector3 clickVector = new Vector3(x, 0, z); Vector3 relative = new Vector3(-0.5, 0, 0); double angle = Math.acos(clickVector.dotProduct(relative) / (relative.mag() * clickVector.mag())) * 180D / Math.PI; rotationX = (float) angle + 180F; - if(clickVector.z < 0) + if (clickVector.z < 0) { rotationX = 360 - rotationX; + } } double angle = y * 180; @@ -418,34 +444,38 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, } private boolean needsNewBurstSimulation() { - if(world.isRemote && !hasReceivedInitialPacket) + if (world.isRemote && !hasReceivedInitialPacket) { return false; + } - if(lastTentativeBurst == null) + if (lastTentativeBurst == null) { return true; + } - for(PositionProperties props : lastTentativeBurst) - if(!props.contentsEqual(world)) { + for (PositionProperties props : lastTentativeBurst) { + if (!props.contentsEqual(world)) { invalidTentativeBurst = props.invalid; return !invalidTentativeBurst; } + } return false; } private void tryShootBurst() { boolean redstone = getVariant() == BlockSpreader.Variant.REDSTONE; - if((receiver != null || redstone) && !invalidTentativeBurst) { - if(canShootBurst && (redstone || receiver.canRecieveManaFromBursts() && !receiver.isFull())) { + if ((receiver != null || redstone) && !invalidTentativeBurst) { + if (canShootBurst && (redstone || receiver.canRecieveManaFromBursts() && !receiver.isFull())) { EntityManaBurst burst = getBurst(false); - if(burst != null) { - if(!world.isRemote) { + if (burst != null) { + if (!world.isRemote) { mana -= burst.getStartingMana(); burst.setShooterUUID(getIdentifier()); world.addEntity(burst); burst.ping(); - if(!ConfigHandler.COMMON.silentSpreaders.get()) + if (!ConfigHandler.COMMON.silentSpreaders.get()) { world.playSound(null, pos, ModSounds.spreaderFire, SoundCategory.BLOCKS, 0.05F * (paddingColor != null ? 0.2F : 1F), 0.7F + 0.3F * (float) Math.random()); + } } } } @@ -464,18 +494,21 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, public void checkForReceiver() { ItemStack stack = itemHandler.getStackInSlot(0); ILensControl control = getLensController(stack); - if(control != null && !control.allowBurstShooting(stack, this, false)) + if (control != null && !control.allowBurstShooting(stack, this, false)) { return; + } EntityManaBurst fakeBurst = getBurst(true); fakeBurst.setScanBeam(); TileEntity receiver = fakeBurst.getCollidedTile(true); - if(receiver instanceof IManaReceiver + if (receiver instanceof IManaReceiver && receiver.hasWorld() - && receiver.getWorld().isBlockLoaded(receiver.getPos())) + && receiver.getWorld().isBlockLoaded(receiver.getPos())) { this.receiver = (IManaReceiver) receiver; - else this.receiver = null; + } else { + this.receiver = null; + } lastTentativeBurst = fakeBurst.propsList; } @@ -493,14 +526,15 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, BurstProperties props = new BurstProperties(variant.burstMana, variant.preLossTicks, variant.lossPerTick, gravity, variant.motionModifier, variant.color); ItemStack lens = itemHandler.getStackInSlot(0); - if(!lens.isEmpty() && lens.getItem() instanceof ILensEffect) + if (!lens.isEmpty() && lens.getItem() instanceof ILensEffect) { ((ILensEffect) lens.getItem()).apply(lens, props); + } - if(getCurrentMana() >= props.maxMana || fake) { + if (getCurrentMana() >= props.maxMana || fake) { EntityManaBurst burst = new EntityManaBurst(this, fake); burst.setSourceLens(lens); - if(mapmakerOverride) { + if (mapmakerOverride) { burst.setColor(mmForcedColor); burst.setMana(mmForcedManaPayload); burst.setStartingMana(mmForcedManaPayload); @@ -524,10 +558,11 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, } public ILensControl getLensController(ItemStack stack) { - if(!stack.isEmpty() && stack.getItem() instanceof ILensControl) { + if (!stack.isEmpty() && stack.getItem() instanceof ILensControl) { ILensControl control = (ILensControl) stack.getItem(); - if(control.isControlLens(stack)) + if (control.isControlLens(stack)) { return control; + } } return null; @@ -540,7 +575,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, HUDHandler.drawSimpleManaHUD(color, knownMana, getMaxMana(), name); ItemStack lens = itemHandler.getStackInSlot(0); - if(!lens.isEmpty()) { + if (!lens.isEmpty()) { String lensName = lens.getDisplayName().getString(); int width = 16 + mc.fontRenderer.getStringWidth(lensName) / 2; int x = mc.getWindow().getScaledWidth() / 2 - width; @@ -551,10 +586,10 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, RenderSystem.disableLighting(); } - if(receiver != null) { + if (receiver != null) { TileEntity receiverTile = (TileEntity) receiver; ItemStack recieverStack = new ItemStack(world.getBlockState(receiverTile.getPos()).getBlock()); - if(!recieverStack.isEmpty()) { + if (!recieverStack.isEmpty()) { String stackName = recieverStack.getDisplayName().getString(); int width = 16 + mc.fontRenderer.getStringWidth(stackName) / 2; int x = mc.getWindow().getScaledWidth() / 2 - width; @@ -572,7 +607,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, @Override public void onClientDisplayTick() { - if(world != null) { + if (world != null) { EntityManaBurst burst = getBurst(true); burst.getCollidedTile(false); } @@ -599,9 +634,11 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, @Nonnull @Override public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { - if(!stack.isEmpty() && stack.getItem() instanceof ILens) + if (!stack.isEmpty() && stack.getItem() instanceof ILens) { return super.insertItem(slot, stack, simulate); - else return stack; + } else { + return stack; + } } }; } @@ -614,8 +651,9 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, @Override public BlockPos getBinding() { - if(receiver == null) + if (receiver == null) { return null; + } TileEntity tile = (TileEntity) receiver; return tile.getPos(); @@ -649,23 +687,26 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, VoxelShape shape = player.world.getBlockState(pos).getShape(player.world, pos); AxisAlignedBB axis = shape.isEmpty() ? new AxisAlignedBB(pos) : shape.getBoundingBox().offset(pos); - if(!blockVec.isInside(axis)) + if (!blockVec.isInside(axis)) { blockVec = new Vector3(axis.minX + (axis.maxX - axis.minX) / 2, axis.minY + (axis.maxY - axis.minY) / 2, axis.minZ + (axis.maxZ - axis.minZ) / 2); + } - Vector3 diffVec = blockVec.subtract(thisVec); + Vector3 diffVec = blockVec.subtract(thisVec); Vector3 diffVec2D = new Vector3(diffVec.x, diffVec.z, 0); Vector3 rotVec = new Vector3(0, 1, 0); double angle = rotVec.angle(diffVec2D) / Math.PI * 180.0; - if(blockVec.x < thisVec.x) + if (blockVec.x < thisVec.x) { angle = -angle; + } rotationX = (float) angle + 90; rotVec = new Vector3(diffVec.x, 0, diffVec.z); angle = diffVec.angle(rotVec) * 180F / Math.PI; - if(blockVec.y < thisVec.y) + if (blockVec.y < thisVec.y) { angle = -angle; + } rotationY = (float) angle; checkForReceiver(); @@ -697,8 +738,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, @Override public void rotate(Rotation rotationIn) { - switch (rotationIn) - { + switch (rotationIn) { case CLOCKWISE_90: rotationX += 270F; break; @@ -708,28 +748,31 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, case COUNTERCLOCKWISE_90: rotationX += 90F; break; - default: break; + default: + break; } - if(rotationX >= 360F) + if (rotationX >= 360F) { rotationX -= 360F; + } } @Override public void mirror(Mirror mirrorIn) { - switch (mirrorIn) - { + switch (mirrorIn) { case LEFT_RIGHT: rotationX = 360F - rotationX; break; case FRONT_BACK: rotationX = 180F - rotationX; break; - default: break; + default: + break; } - if(rotationX < 0F) + if (rotationX < 0F) { rotationX += 360F; + } } @Override @@ -764,7 +807,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, @Override public void pingback(IManaBurst burst, UUID expectedIdentity) { - if(getIdentifier().equals(expectedIdentity)) { + if (getIdentifier().equals(expectedIdentity)) { pingbackTicks = TICKS_ALLOWED_WITHOUT_PINGBACK; Entity e = (Entity) burst; lastPingbackX = e.getX(); @@ -776,8 +819,9 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector, @Override public UUID getIdentifier() { - if(identity == null) + if (identity == null) { identity = UUID.randomUUID(); + } return identity; } diff --git a/src/main/java/vazkii/botania/common/block/tile/mana/TileTurntable.java b/src/main/java/vazkii/botania/common/block/tile/mana/TileTurntable.java index 02623fade..a68470101 100644 --- a/src/main/java/vazkii/botania/common/block/tile/mana/TileTurntable.java +++ b/src/main/java/vazkii/botania/common/block/tile/mana/TileTurntable.java @@ -1,16 +1,13 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 16, 2014, 10:15:05 PM (GMT)] */ package vazkii.botania.common.block.tile.mana; -import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; @@ -23,15 +20,14 @@ import net.minecraft.util.text.TextFormatting; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.registries.ObjectHolder; -import org.lwjgl.opengl.GL11; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.common.block.tile.TileMod; import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; public class TileTurntable extends TileMod implements ITickableTileEntity { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.TURNTABLE) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.TURNTABLE) public static TileEntityType TYPE; private static final String TAG_SPEED = "speed"; private static final String TAG_BACKWARDS = "backwards"; @@ -46,21 +42,24 @@ public class TileTurntable extends TileMod implements ITickableTileEntity { public void tick() { boolean redstone = false; - for(Direction dir : Direction.values()) { + for (Direction dir : Direction.values()) { int redstoneSide = world.getRedstonePower(pos.offset(dir), dir); - if(redstoneSide > 0) + if (redstoneSide > 0) { redstone = true; + } } - if(!redstone) { + if (!redstone) { TileEntity tile = world.getTileEntity(pos.up()); - if(tile instanceof TileSpreader) { + if (tile instanceof TileSpreader) { TileSpreader spreader = (TileSpreader) tile; spreader.rotationX += speed * (backwards ? -1 : 1); - if(spreader.rotationX >= 360F) + if (spreader.rotationX >= 360F) { spreader.rotationX -= 360F; - if(!world.isRemote) + } + if (!world.isRemote) { spreader.checkForReceiver(); + } } } } @@ -78,9 +77,11 @@ public class TileTurntable extends TileMod implements ITickableTileEntity { } public void onWanded(PlayerEntity player, ItemStack wand, Direction side) { - if((player != null && player.isSneaking()) || (player == null && side == Direction.DOWN)) + if ((player != null && player.isSneaking()) || (player == null && side == Direction.DOWN)) { backwards = !backwards; - else speed = speed == 6 ? 1 : speed + 1; + } else { + speed = speed == 6 ? 1 : speed + 1; + } VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos); } @@ -90,8 +91,9 @@ public class TileTurntable extends TileMod implements ITickableTileEntity { char motion = backwards ? '<' : '>'; String speed = TextFormatting.BOLD + ""; - for(int i = 0; i < this.speed; i++) + for (int i = 0; i < this.speed; i++) { speed = speed + motion; + } int x = mc.getWindow().getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(speed) / 2; int y = mc.getWindow().getScaledHeight() / 2 - 15; diff --git a/src/main/java/vazkii/botania/common/block/tile/string/TileRedString.java b/src/main/java/vazkii/botania/common/block/tile/string/TileRedString.java index abd9f15b7..d4d50ec0a 100644 --- a/src/main/java/vazkii/botania/common/block/tile/string/TileRedString.java +++ b/src/main/java/vazkii/botania/common/block/tile/string/TileRedString.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 14, 2014, 5:04:22 PM (GMT)] */ package vazkii.botania.common.block.tile.string; @@ -20,6 +18,7 @@ import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; + import vazkii.botania.api.wand.ITileBound; import vazkii.botania.common.block.tile.TileMod; @@ -42,19 +41,22 @@ public abstract class TileRedString extends TileMod implements ITileBound, ITick BlockPos currBinding = getBinding(); setBinding(null); - for(int i = 0; i < range; i++) { + for (int i = 0; i < range; i++) { pos_ = pos_.offset(dir); - if(world.isAirBlock(pos_)) + if (world.isAirBlock(pos_)) { continue; + } TileEntity tile = world.getTileEntity(pos_); - if(tile instanceof TileRedString) + if (tile instanceof TileRedString) { continue; + } - if(acceptBlock(pos_)) { + if (acceptBlock(pos_)) { setBinding(pos_); - if(currBinding == null || !currBinding.equals(pos_)) + if (currBinding == null || !currBinding.equals(pos_)) { onBound(pos_); + } break; } } diff --git a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringComparator.java b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringComparator.java index c40b4a974..62ab3bc66 100644 --- a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringComparator.java +++ b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringComparator.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 16, 2014, 10:22:01 PM (GMT)] */ package vazkii.botania.common.block.tile.string; @@ -14,12 +12,12 @@ import net.minecraft.block.BlockState; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.BlockPos; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; public class TileRedStringComparator extends TileRedString { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.RED_STRING_COMPARATOR) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.RED_STRING_COMPARATOR) public static TileEntityType TYPE; private int comparatorValue = 0; public TileRedStringComparator() { @@ -33,12 +31,15 @@ public class TileRedStringComparator extends TileRedString { BlockState state = getStateAtBinding(); int origVal = comparatorValue; - if(state.hasComparatorInputOverride()) { + if (state.hasComparatorInputOverride()) { comparatorValue = state.getComparatorInputOverride(world, binding); - } else comparatorValue = 0; + } else { + comparatorValue = 0; + } - if(origVal != comparatorValue) + if (origVal != comparatorValue) { world.updateComparatorOutputLevel(pos, getBlockState().getBlock()); + } } public int getComparatorValue() { diff --git a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringContainer.java b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringContainer.java index 3203ad712..4b8bdbee8 100644 --- a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringContainer.java +++ b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringContainer.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 14, 2014, 5:26:39 PM (GMT)] */ package vazkii.botania.common.block.tile.string; @@ -20,21 +18,20 @@ import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.wrapper.EmptyHandler; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; import javax.annotation.Nullable; + import java.util.Arrays; public class TileRedStringContainer extends TileRedString { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.RED_STRING_CONTAINER) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.RED_STRING_CONTAINER) public static TileEntityType TYPE; private static final LazyOptional EMPTY = LazyOptional.of(EmptyHandler::new); - @Nullable - private LazyOptional lastBoundInv = null; - @Nullable - private LazyOptional proxiedInv = null; + @Nullable private LazyOptional lastBoundInv = null; + @Nullable private LazyOptional proxiedInv = null; public TileRedStringContainer() { this(TYPE); @@ -49,29 +46,29 @@ public class TileRedStringContainer extends TileRedString { TileEntity tile = world.getTileEntity(pos); return tile != null && Arrays.stream(Direction.values()) - .anyMatch(e -> tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, e).isPresent()); + .anyMatch(e -> tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, e).isPresent()); } @Nonnull @Override public LazyOptional getCapability(@Nonnull Capability cap, Direction side) { - if(cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { - if(getTileAtBinding() != null) { + if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + if (getTileAtBinding() != null) { LazyOptional optional = getTileAtBinding().getCapability(cap, side); - if(!optional.isPresent()) { + if (!optional.isPresent()) { invalidateLastCap(); return EMPTY.cast(); } - if(lastBoundInv == optional) { + if (lastBoundInv == optional) { return proxiedInv.cast(); } - if(proxiedInv != null) { + if (proxiedInv != null) { proxiedInv.invalidate(); } lastBoundInv = optional; proxiedInv = createProxyOptional(optional.cast()); return proxiedInv.cast(); - + } else { invalidateLastCap(); return EMPTY.cast(); @@ -81,7 +78,7 @@ public class TileRedStringContainer extends TileRedString { } private void invalidateLastCap() { - if(proxiedInv != null) { + if (proxiedInv != null) { proxiedInv.invalidate(); proxiedInv = null; } @@ -104,8 +101,9 @@ public class TileRedStringContainer extends TileRedString { public void markDirty() { super.markDirty(); TileEntity tile = getTileAtBinding(); - if(tile != null) + if (tile != null) { tile.markDirty(); + } } } diff --git a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringDispenser.java b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringDispenser.java index 5548e97cd..422629081 100644 --- a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringDispenser.java +++ b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringDispenser.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 14, 2014, 11:00:16 PM (GMT)] */ package vazkii.botania.common.block.tile.string; @@ -15,12 +13,12 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.BlockPos; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; public class TileRedStringDispenser extends TileRedStringContainer { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.RED_STRING_DISPENSER) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.RED_STRING_DISPENSER) public static TileEntityType TYPE; public TileRedStringDispenser() { super(TYPE); @@ -33,10 +31,11 @@ public class TileRedStringDispenser extends TileRedStringContainer { public void tickDispenser() { BlockPos bind = getBinding(); - if(bind != null) { + if (bind != null) { TileEntity tile = world.getTileEntity(bind); - if(tile instanceof DispenserTileEntity) + if (tile instanceof DispenserTileEntity) { world.getPendingBlockTicks().scheduleTick(bind, tile.getBlockState().getBlock(), tile.getBlockState().getBlock().tickRate(world)); + } } } diff --git a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringFertilizer.java b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringFertilizer.java index 0b9a9ba91..1c64ecdc1 100644 --- a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringFertilizer.java +++ b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringFertilizer.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 16, 2014, 7:17:16 PM (GMT)] */ package vazkii.botania.common.block.tile.string; @@ -18,14 +16,14 @@ import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; import java.util.Random; public class TileRedStringFertilizer extends TileRedString { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.RED_STRING_FERTILIZER) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.RED_STRING_FERTILIZER) public static TileEntityType TYPE; public TileRedStringFertilizer() { super(TYPE); @@ -47,8 +45,9 @@ public class TileRedStringFertilizer extends TileRedString { public void grow(ServerWorld world, Random rand) { BlockPos binding = getBinding(); Block block = getBlockAtBinding(); - if(block instanceof IGrowable) + if (block instanceof IGrowable) { ((IGrowable) block).grow(world, rand, binding, world.getBlockState(binding)); + } } @Override diff --git a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringInterceptor.java b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringInterceptor.java index d3da8d9da..4feb11432 100644 --- a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringInterceptor.java +++ b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringInterceptor.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 21, 2015, 4:58:20 PM (GMT)] */ package vazkii.botania.common.block.tile.string; @@ -19,6 +17,7 @@ import net.minecraft.util.SoundEvents; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; @@ -29,8 +28,7 @@ import java.util.List; import java.util.Set; public class TileRedStringInterceptor extends TileRedString { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.RED_STRING_INTERCEPTOR) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.RED_STRING_INTERCEPTOR) public static TileEntityType TYPE; private static final Set interceptors = new HashSet<>(); public TileRedStringInterceptor() { @@ -40,8 +38,9 @@ public class TileRedStringInterceptor extends TileRedString { @Override public void tick() { super.tick(); - if(!world.isRemote) + if (!world.isRemote) { interceptors.add(this); + } } @Override @@ -54,22 +53,22 @@ public class TileRedStringInterceptor extends TileRedString { } public static void onInteract(PlayerEntity player, World world, BlockPos pos, Hand hand) { - if(world.isRemote) + if (world.isRemote) { return; + } List remove = new ArrayList<>(); boolean did = false; - - for(TileRedStringInterceptor inter : interceptors) { - if(!inter.saneState()) { + for (TileRedStringInterceptor inter : interceptors) { + if (!inter.saneState()) { remove.add(inter); continue; } - if(inter.world == world) { + if (inter.world == world) { BlockPos coords = inter.getBinding(); - if(coords != null && coords.equals(pos)) { + if (coords != null && coords.equals(pos)) { Block block = inter.getBlockState().getBlock(); world.setBlockState(inter.getPos(), world.getBlockState(inter.getPos()).with(BotaniaStateProps.POWERED, true)); world.getPendingBlockTicks().scheduleTick(inter.getPos(), block, block.tickRate(world)); @@ -79,7 +78,7 @@ public class TileRedStringInterceptor extends TileRedString { } interceptors.removeAll(remove); - if(did) { + if (did) { player.swingArm(hand); world.playSound(null, pos, SoundEvents.BLOCK_DISPENSER_DISPENSE, SoundCategory.BLOCKS, 0.3F, 0.6F); } diff --git a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringRelay.java b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringRelay.java index 224cd3019..a6864ea24 100644 --- a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringRelay.java +++ b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringRelay.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 16, 2014, 10:52:21 PM (GMT)] */ package vazkii.botania.common.block.tile.string; @@ -18,13 +16,13 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.BlockPos; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.subtile.TileEntitySpecialFlower; import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; public class TileRedStringRelay extends TileRedString { - @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.RED_STRING_RELAY) - public static TileEntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.RED_STRING_RELAY) public static TileEntityType TYPE; public TileRedStringRelay() { super(TYPE); @@ -32,8 +30,9 @@ public class TileRedStringRelay extends TileRedString { @Override public boolean acceptBlock(BlockPos pos) { - if(pos.equals(getPos().up())) + if (pos.equals(getPos().up())) { return false; + } Block block = world.getBlockState(pos).getBlock(); TileEntity tile = world.getTileEntity(pos); diff --git a/src/main/java/vazkii/botania/common/brew/BrewMod.java b/src/main/java/vazkii/botania/common/brew/BrewMod.java index 95f9b2cb0..022c93e10 100644 --- a/src/main/java/vazkii/botania/common/brew/BrewMod.java +++ b/src/main/java/vazkii/botania/common/brew/BrewMod.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 1, 2014, 7:02:29 PM (GMT)] */ package vazkii.botania.common.brew; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.PotionUtils; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.brew.Brew; diff --git a/src/main/java/vazkii/botania/common/brew/ModBrews.java b/src/main/java/vazkii/botania/common/brew/ModBrews.java index 033a8a4ce..d3bdb283f 100644 --- a/src/main/java/vazkii/botania/common/brew/ModBrews.java +++ b/src/main/java/vazkii/botania/common/brew/ModBrews.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 1, 2014, 7:00:33 PM (GMT)] */ package vazkii.botania.common.brew; @@ -15,6 +13,7 @@ import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Effects; import net.minecraft.util.ResourceLocation; import net.minecraftforge.registries.ForgeRegistries; + import vazkii.botania.api.brew.Brew; import vazkii.botania.common.lib.LibBrewNames; @@ -71,7 +70,8 @@ public class ModBrews { public static void initTC() { Effect warpWardPotion = ForgeRegistries.POTIONS.getValue(new ResourceLocation("thaumcraft:warpward")); - if(warpWardPotion != null) + if (warpWardPotion != null) { warpWard = new BrewMod(LibBrewNames.WARP_WARD, 0xFBBDFF, 25000, new EffectInstance(warpWardPotion, 12000, 0)).setNotBloodPendantInfusable(); + } } } diff --git a/src/main/java/vazkii/botania/common/brew/ModPotions.java b/src/main/java/vazkii/botania/common/brew/ModPotions.java index 35ab21aa2..b80c3e656 100644 --- a/src/main/java/vazkii/botania/common/brew/ModPotions.java +++ b/src/main/java/vazkii/botania/common/brew/ModPotions.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 1, 2014, 7:00:29 PM (GMT)] */ package vazkii.botania.common.brew; @@ -14,6 +12,7 @@ import net.minecraft.potion.Effect; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.common.brew.potion.PotionAllure; import vazkii.botania.common.brew.potion.PotionBloodthirst; import vazkii.botania.common.brew.potion.PotionClear; @@ -34,8 +33,7 @@ public class ModPotions { public static final Effect clear = new PotionClear().setRegistryName(LibMisc.MOD_ID, LibPotionNames.CLEAR); @SubscribeEvent - public static void registerPotions(RegistryEvent.Register evt) - { + public static void registerPotions(RegistryEvent.Register evt) { evt.getRegistry().register(soulCross); evt.getRegistry().register(featherfeet); evt.getRegistry().register(emptiness); diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionAllure.java b/src/main/java/vazkii/botania/common/brew/potion/PotionAllure.java index 8e26b6ce8..53b2e9e1a 100644 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionAllure.java +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionAllure.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 3, 2014, 12:15:09 AM (GMT)] */ package vazkii.botania.common.brew.potion; @@ -31,10 +29,11 @@ public class PotionAllure extends Effect { @Override public void performEffect(@Nonnull LivingEntity living, int amplified) { - if(living instanceof PlayerEntity) { + if (living instanceof PlayerEntity) { FishingBobberEntity hook = ((PlayerEntity) living).fishingBobber; - if(hook != null) + if (hook != null) { hook.tick(); + } } } diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionBloodthirst.java b/src/main/java/vazkii/botania/common/brew/potion/PotionBloodthirst.java index 79a408e13..8c9852feb 100644 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionBloodthirst.java +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionBloodthirst.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 3, 2014, 12:13:09 AM (GMT)] */ package vazkii.botania.common.brew.potion; @@ -19,6 +17,7 @@ import net.minecraftforge.event.entity.living.LivingSpawnEvent; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.common.brew.ModPotions; import vazkii.botania.common.lib.LibMisc; @@ -33,11 +32,11 @@ public class PotionBloodthirst extends Effect { @SubscribeEvent public static void onSpawn(LivingSpawnEvent.CheckSpawn event) { - if(event.getResult() != Event.Result.ALLOW && event.getEntityLiving() instanceof IMob) { + if (event.getResult() != Event.Result.ALLOW && event.getEntityLiving() instanceof IMob) { AxisAlignedBB aabb = new AxisAlignedBB(event.getX() - RANGE, event.getY() - RANGE, event.getZ() - RANGE, event.getX() + RANGE, event.getY() + RANGE, event.getZ() + RANGE); - for(PlayerEntity player : event.getWorld().getPlayers()) { - if(player.isPotionActive(ModPotions.bloodthrst) + for (PlayerEntity player : event.getWorld().getPlayers()) { + if (player.isPotionActive(ModPotions.bloodthrst) && !player.isPotionActive(ModPotions.emptiness) && player.getBoundingBox().intersects(aabb)) { event.setResult(Event.Result.ALLOW); diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionClear.java b/src/main/java/vazkii/botania/common/brew/potion/PotionClear.java index bd1218070..f1846fbf5 100644 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionClear.java +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionClear.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 25, 2015, 6:08:52 PM (GMT)] */ package vazkii.botania.common.brew.potion; diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionEmptiness.java b/src/main/java/vazkii/botania/common/brew/potion/PotionEmptiness.java index 4b13ddecc..7292a7398 100644 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionEmptiness.java +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionEmptiness.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 3, 2014, 12:12:36 AM (GMT)] */ package vazkii.botania.common.brew.potion; @@ -18,6 +16,7 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.event.entity.living.LivingSpawnEvent; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.SubscribeEvent; + import vazkii.botania.common.brew.ModPotions; public class PotionEmptiness extends Effect { @@ -30,11 +29,11 @@ public class PotionEmptiness extends Effect { @SubscribeEvent public static void onSpawn(LivingSpawnEvent.CheckSpawn event) { - if(event.getResult() != Event.Result.ALLOW && event.getEntityLiving() instanceof IMob) { + if (event.getResult() != Event.Result.ALLOW && event.getEntityLiving() instanceof IMob) { AxisAlignedBB aabb = new AxisAlignedBB(event.getX() - RANGE, event.getY() - RANGE, event.getZ() - RANGE, event.getX() + RANGE, event.getY() + RANGE, event.getZ() + RANGE); - for(PlayerEntity player : event.getWorld().getPlayers()) { - if(player.isPotionActive(ModPotions.emptiness) && player.getBoundingBox().intersects(aabb)) { + for (PlayerEntity player : event.getWorld().getPlayers()) { + if (player.isPotionActive(ModPotions.emptiness) && player.getBoundingBox().intersects(aabb)) { event.setResult(Event.Result.DENY); return; } diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionFeatherfeet.java b/src/main/java/vazkii/botania/common/brew/potion/PotionFeatherfeet.java index 942eeaf79..0974196f3 100644 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionFeatherfeet.java +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionFeatherfeet.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 3, 2014, 12:12:04 AM (GMT)] */ package vazkii.botania.common.brew.potion; @@ -29,8 +27,9 @@ public class PotionFeatherfeet extends Effect { @Override public void performEffect(@Nonnull LivingEntity living, int amplified) { - if(living.fallDistance > 2.5F) + if (living.fallDistance > 2.5F) { living.fallDistance = 2.5F; + } } } diff --git a/src/main/java/vazkii/botania/common/brew/potion/PotionSoulCross.java b/src/main/java/vazkii/botania/common/brew/potion/PotionSoulCross.java index 7e825c120..8b5512351 100644 --- a/src/main/java/vazkii/botania/common/brew/potion/PotionSoulCross.java +++ b/src/main/java/vazkii/botania/common/brew/potion/PotionSoulCross.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 2, 2014, 10:31:48 PM (GMT)] */ package vazkii.botania.common.brew.potion; @@ -17,6 +15,7 @@ import net.minecraft.potion.EffectType; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.common.brew.ModPotions; import vazkii.botania.common.lib.LibMisc; @@ -30,10 +29,11 @@ public class PotionSoulCross extends Effect { @SubscribeEvent public static void onEntityKill(LivingDeathEvent event) { Entity killer = event.getSource().getTrueSource(); - if(killer instanceof LivingEntity) { + if (killer instanceof LivingEntity) { LivingEntity living = (LivingEntity) killer; - if(living.isPotionActive(ModPotions.soulCross)) + if (living.isPotionActive(ModPotions.soulCross)) { living.heal(event.getEntityLiving().getMaxHealth() / 20); + } } } diff --git a/src/main/java/vazkii/botania/common/capability/NoopCapStorage.java b/src/main/java/vazkii/botania/common/capability/NoopCapStorage.java index ae354c048..295f87438 100644 --- a/src/main/java/vazkii/botania/common/capability/NoopCapStorage.java +++ b/src/main/java/vazkii/botania/common/capability/NoopCapStorage.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Dec 23, 2019, 18:50] */ package vazkii.botania.common.capability; @@ -24,6 +22,5 @@ public class NoopCapStorage implements Capability.IStorage { } @Override - public void readNBT(Capability capability, T instance, Direction side, INBT nbt) { - } + public void readNBT(Capability capability, T instance, Direction side, INBT nbt) {} } diff --git a/src/main/java/vazkii/botania/common/capability/NoopExoflameHeatable.java b/src/main/java/vazkii/botania/common/capability/NoopExoflameHeatable.java index f5415d0b0..d1f3bb7ab 100644 --- a/src/main/java/vazkii/botania/common/capability/NoopExoflameHeatable.java +++ b/src/main/java/vazkii/botania/common/capability/NoopExoflameHeatable.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Dec 23, 2019, 18:51] */ package vazkii.botania.common.capability; @@ -24,10 +22,8 @@ public class NoopExoflameHeatable implements IExoflameHeatable { } @Override - public void boostBurnTime() { - } + public void boostBurnTime() {} @Override - public void boostCookTime() { - } + public void boostCookTime() {} } diff --git a/src/main/java/vazkii/botania/common/capability/SimpleCapProvider.java b/src/main/java/vazkii/botania/common/capability/SimpleCapProvider.java index 119e0f28c..8c3c982c8 100644 --- a/src/main/java/vazkii/botania/common/capability/SimpleCapProvider.java +++ b/src/main/java/vazkii/botania/common/capability/SimpleCapProvider.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Dec 23, 2019, 16:41] */ package vazkii.botania.common.capability; @@ -23,9 +21,9 @@ import javax.annotation.Nullable; public class SimpleCapProvider implements ICapabilityProvider { private final C capInstance; private final LazyOptional capOptional; - + private final Capability capability; - + public SimpleCapProvider(Capability capability, C capInstance) { this.capability = capability; this.capInstance = capInstance; diff --git a/src/main/java/vazkii/botania/common/core/BotaniaCreativeTab.java b/src/main/java/vazkii/botania/common/core/BotaniaCreativeTab.java index 29e880e34..86833523a 100644 --- a/src/main/java/vazkii/botania/common/core/BotaniaCreativeTab.java +++ b/src/main/java/vazkii/botania/common/core/BotaniaCreativeTab.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 14, 2014, 5:20:53 PM (GMT)] */ package vazkii.botania.common.core; @@ -18,6 +16,7 @@ import net.minecraft.util.IItemProvider; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraftforge.registries.ForgeRegistryEntry; + import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.Botania; import vazkii.botania.common.block.ModBlocks; @@ -27,6 +26,7 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.Comparator; public final class BotaniaCreativeTab extends ItemGroup { @@ -57,14 +57,17 @@ public final class BotaniaCreativeTab extends ItemGroup { addItem(ModItems.lexicon); - for(DyeColor color : DyeColor.values()) + for (DyeColor color : DyeColor.values()) { addItem(ModBlocks.getFlower(color)); + } addTag(new ResourceLocation(LibMisc.MOD_ID, "special_flowers")); - for(DyeColor color : DyeColor.values()) + for (DyeColor color : DyeColor.values()) { this.addItem(ModItems.getPetal(color)); + } addItem(ModItems.pestleAndMortar); - for(DyeColor color : DyeColor.values()) + for (DyeColor color : DyeColor.values()) { this.addItem(ModItems.getDye(color)); + } addItem(ModItems.fertilizer); addItem(ModItems.flowerBag); addItem(ModItems.blackLotus); @@ -162,8 +165,9 @@ public final class BotaniaCreativeTab extends ItemGroup { addItem(ModBlocks.scorchedGrass); addItem(ModBlocks.infusedGrass); addItem(ModBlocks.mutatedGrass); - if(Botania.thaumcraftLoaded) + if (Botania.thaumcraftLoaded) { addItem(ModItems.manaInkwell); + } addItem(ModBlocks.wildDrum); addItem(ModBlocks.gatheringDrum); addItem(ModBlocks.canopyDrum); @@ -182,7 +186,7 @@ public final class BotaniaCreativeTab extends ItemGroup { addItem(ModItems.astrolabe); addItem(ModItems.blackHoleTalisman); - if(Botania.gardenOfGlassLoaded) { + if (Botania.gardenOfGlassLoaded) { addItem(ModBlocks.root); addItem(ModItems.waterBowl); } @@ -269,8 +273,9 @@ public final class BotaniaCreativeTab extends ItemGroup { addItem(ModItems.enderDagger); addItem(ModItems.livingwoodBow); addItem(ModItems.manasteelHelm); - if(Botania.thaumcraftLoaded) + if (Botania.thaumcraftLoaded) { addItem(ModItems.manasteelHelmRevealing); + } addItem(ModItems.manasteelChest); addItem(ModItems.manasteelLegs); addItem(ModItems.manasteelBoots); @@ -287,8 +292,9 @@ public final class BotaniaCreativeTab extends ItemGroup { addItem(ModItems.thunderSword); addItem(ModItems.crystalBow); addItem(ModItems.elementiumHelm); - if(Botania.thaumcraftLoaded) + if (Botania.thaumcraftLoaded) { addItem(ModItems.elementiumHelmRevealing); + } addItem(ModItems.elementiumChest); addItem(ModItems.elementiumLegs); addItem(ModItems.elementiumBoots); @@ -299,8 +305,9 @@ public final class BotaniaCreativeTab extends ItemGroup { addItem(ModItems.terraAxe); addItem(ModItems.temperanceStone); addItem(ModItems.terrasteelHelm); - if(Botania.thaumcraftLoaded) + if (Botania.thaumcraftLoaded) { addItem(ModItems.terrasteelHelmRevealing); + } addItem(ModItems.terrasteelChest); addItem(ModItems.terrasteelLegs); addItem(ModItems.terrasteelBoots); @@ -316,7 +323,7 @@ public final class BotaniaCreativeTab extends ItemGroup { addItem(ModItems.ancientWillKaril); addItem(ModItems.pinkinator); addItem(ModBlocks.gaiaHead); - if(ConfigHandler.COMMON.relicsEnabled.get()) { + if (ConfigHandler.COMMON.relicsEnabled.get()) { addItem(ModItems.dice); addItem(ModItems.infiniteFruit); addItem(ModItems.kingKey); @@ -433,12 +440,15 @@ public final class BotaniaCreativeTab extends ItemGroup { // FLUFF - for(DyeColor color : DyeColor.values()) + for (DyeColor color : DyeColor.values()) { addItem(ModBlocks.getDoubleFlower(color)); - for(DyeColor color : DyeColor.values()) + } + for (DyeColor color : DyeColor.values()) { addItem(ModBlocks.getShinyFlower(color)); - for(DyeColor color : DyeColor.values()) + } + for (DyeColor color : DyeColor.values()) { addItem(ModBlocks.getFloatingFlower(color)); + } addTag(new ResourceLocation(LibMisc.MOD_ID, "special_floating_flowers")); addItem(ModBlocks.petalBlockWhite); addItem(ModBlocks.petalBlockOrange); @@ -456,8 +466,9 @@ public final class BotaniaCreativeTab extends ItemGroup { addItem(ModBlocks.petalBlockGreen); addItem(ModBlocks.petalBlockRed); addItem(ModBlocks.petalBlockBlack); - for(DyeColor color : DyeColor.values()) + for (DyeColor color : DyeColor.values()) { addItem(ModBlocks.getMushroom(color)); + } addItem(ModBlocks.blazeBlock); @@ -607,7 +618,7 @@ public final class BotaniaCreativeTab extends ItemGroup { addItem(ModFluffBlocks.biomeBrickDesertStairs); addItem(ModFluffBlocks.biomeBrickTaigaStairs); addItem(ModFluffBlocks.biomeBrickMesaStairs); - + addItem(ModFluffBlocks.biomeStoneForestSlab); addItem(ModFluffBlocks.biomeStonePlainsSlab); addItem(ModFluffBlocks.biomeStoneMountainSlab); @@ -632,7 +643,7 @@ public final class BotaniaCreativeTab extends ItemGroup { addItem(ModFluffBlocks.biomeBrickDesertSlab); addItem(ModFluffBlocks.biomeBrickTaigaSlab); addItem(ModFluffBlocks.biomeBrickMesaSlab); - + addItem(ModFluffBlocks.biomeWallForest); addItem(ModFluffBlocks.biomeWallPlains); addItem(ModFluffBlocks.biomeWallMountain); @@ -705,4 +716,4 @@ public final class BotaniaCreativeTab extends ItemGroup { private void addItem(IItemProvider item) { item.asItem().fillItemGroup(this, list); } -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/common/core/command/CommandSkyblockSpread.java b/src/main/java/vazkii/botania/common/core/command/CommandSkyblockSpread.java index 5bbb19433..43d928429 100644 --- a/src/main/java/vazkii/botania/common/core/command/CommandSkyblockSpread.java +++ b/src/main/java/vazkii/botania/common/core/command/CommandSkyblockSpread.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 17, 2015, 5:13:06 PM (GMT)] */ package vazkii.botania.common.core.command; @@ -14,12 +12,13 @@ import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.IntegerArgumentType; 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.command.arguments.EntityArgument; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.util.math.BlockPos; + import vazkii.botania.common.core.helper.MathHelper; import vazkii.botania.common.world.SkyblockWorldEvents; @@ -31,9 +30,9 @@ public class CommandSkyblockSpread { Commands.literal("botania-skyblock-spread") .requires(s -> s.hasPermissionLevel(2)) .then(Commands.argument("player", EntityArgument.player()) - .then(Commands.argument("range", IntegerArgumentType.integer(250, 1000000)) - .executes(ctx -> run(ctx, IntegerArgumentType.getInteger(ctx, "range")))) - .executes(ctx -> run(ctx, DEFAULT_RANGE))) + .then(Commands.argument("range", IntegerArgumentType.integer(250, 1000000)) + .executes(ctx -> run(ctx, IntegerArgumentType.getInteger(ctx, "range")))) + .executes(ctx -> run(ctx, DEFAULT_RANGE))) ); } @@ -46,7 +45,7 @@ public class CommandSkyblockSpread { do { x = player.world.rand.nextInt(range) - range / 2 + spawn.getX(); z = player.world.rand.nextInt(range) - range / 2 + spawn.getZ(); - } while(MathHelper.pointDistancePlane(x, z, spawn.getX(), spawn.getZ()) < minDist); + } while (MathHelper.pointDistancePlane(x, z, spawn.getX(), spawn.getZ()) < minDist); SkyblockWorldEvents.spawnPlayer(player, new BlockPos(x, spawn.getY(), z), true); return 1; diff --git a/src/main/java/vazkii/botania/common/core/handler/CommonTickHandler.java b/src/main/java/vazkii/botania/common/core/handler/CommonTickHandler.java index 98572473e..ac7438d80 100644 --- a/src/main/java/vazkii/botania/common/core/handler/CommonTickHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/CommonTickHandler.java @@ -1,18 +1,17 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 14, 2014, 5:10:16 PM (GMT)] */ package vazkii.botania.common.core.handler; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.api.corporea.CorporeaHelper; import vazkii.botania.common.lib.LibMisc; @@ -23,7 +22,7 @@ public final class CommonTickHandler { @SubscribeEvent public static void onTick(TickEvent.WorldTickEvent event) { - if(event.phase == TickEvent.Phase.END) { + if (event.phase == TickEvent.Phase.END) { CorporeaHelper.clearCache(); } } diff --git a/src/main/java/vazkii/botania/common/core/handler/ConfigHandler.java b/src/main/java/vazkii/botania/common/core/handler/ConfigHandler.java index 9867d92ee..3d170e2f0 100644 --- a/src/main/java/vazkii/botania/common/core/handler/ConfigHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/ConfigHandler.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 13, 2014, 9:01:32 PM (GMT)] */ package vazkii.botania.common.core.handler; import net.minecraftforge.common.ForgeConfigSpec; + import org.apache.commons.lang3.tuple.Pair; public final class ConfigHandler { @@ -134,8 +133,8 @@ public final class ConfigHandler { public final ForgeConfigSpec.IntValue flowerPatchChance; public final ForgeConfigSpec.DoubleValue flowerTallChance; public final ForgeConfigSpec.IntValue mushroomQuantity; - - public final ForgeConfigSpec.BooleanValue gogSpawnWithLexicon; + + public final ForgeConfigSpec.BooleanValue gogSpawnWithLexicon; public Common(ForgeConfigSpec.Builder builder) { blockBreakParticles = builder diff --git a/src/main/java/vazkii/botania/common/core/handler/EquipmentHandler.java b/src/main/java/vazkii/botania/common/core/handler/EquipmentHandler.java index 202d6f052..f8da02067 100644 --- a/src/main/java/vazkii/botania/common/core/handler/EquipmentHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/EquipmentHandler.java @@ -1,14 +1,11 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 30 2019, 16:45:42 (GMT)] */ - package vazkii.botania.common.core.handler; import net.minecraft.entity.LivingEntity; @@ -24,6 +21,7 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.wrapper.InvWrapper; import net.minecraftforge.items.wrapper.RangedWrapper; + import vazkii.botania.api.mana.IManaItem; import vazkii.botania.common.Botania; import vazkii.botania.common.integration.curios.CurioIntegration; @@ -38,7 +36,7 @@ public abstract class EquipmentHandler { public static EquipmentHandler instance; public static void init() { - if(Botania.curiosLoaded) { + if (Botania.curiosLoaded) { instance = new CurioIntegration(); FMLJavaModLoadingContext.get().getModEventBus().register(CurioIntegration.class); MinecraftForge.EVENT_BUS.register(CurioIntegration.class); @@ -62,8 +60,10 @@ public abstract class EquipmentHandler { } public static ICapabilityProvider initBaubleCap(ItemStack stack) { - if(instance != null) // Happens to be called in ModItems class init, which is too early to know about which handler to use + if (instance != null) // Happens to be called in ModItems class init, which is too early to know about which handler to use + { return instance.initCap(stack); + } return null; } @@ -84,8 +84,9 @@ public abstract class EquipmentHandler { private final Map map = new WeakHashMap<>(); public void onPlayerTick(TickEvent.PlayerTickEvent event) { - if(event.phase != TickEvent.Phase.START || event.player.world.isRemote) + if (event.phase != TickEvent.Phase.START || event.player.world.isRemote) { return; + } PlayerEntity player = event.player; player.world.getProfiler().startSection("botania:tick_wearables"); @@ -96,16 +97,16 @@ public abstract class EquipmentHandler { }); PlayerInventory inv = player.inventory; - for(int i = 0; i < 9; i++) { + for (int i = 0; i < 9; i++) { ItemStack old = oldStacks[i]; ItemStack current = inv.getStackInSlot(i); - if(!ItemStack.areItemStacksEqual(old, current)) { - if(old.getItem() instanceof ItemBauble) { + if (!ItemStack.areItemStacksEqual(old, current)) { + if (old.getItem() instanceof ItemBauble) { player.getAttributes().removeAttributeModifiers(((ItemBauble) old.getItem()).getEquippedAttributeModifiers(old)); ((ItemBauble) old.getItem()).onUnequipped(old, player); } - if(canEquip(current, player)) { + if (canEquip(current, player)) { player.getAttributes().applyAttributeModifiers(((ItemBauble) current.getItem()).getEquippedAttributeModifiers(current)); ((ItemBauble) current.getItem()).onEquipped(current, player); } @@ -113,17 +114,16 @@ public abstract class EquipmentHandler { // making it empty and failing the equality check - let's avoid that } - if(canEquip(current, player)) { + if (canEquip(current, player)) { ((ItemBauble) current.getItem()).onWornTick(current, player); } } player.world.getProfiler().endSection(); } - @Override protected LazyOptional getAllWornItems(LivingEntity living) { - if(living instanceof PlayerEntity) { + if (living instanceof PlayerEntity) { return LazyOptional.of(() -> new RangedWrapper(new InvWrapper(((PlayerEntity) living).inventory), 0, 9)); } return LazyOptional.empty(); @@ -131,11 +131,11 @@ public abstract class EquipmentHandler { @Override protected ItemStack findItem(Item item, LivingEntity living) { - if(living instanceof PlayerEntity) { + if (living instanceof PlayerEntity) { PlayerInventory inv = ((PlayerEntity) living).inventory; - for(int i = 0; i < 9; i++) { + for (int i = 0; i < 9; i++) { ItemStack stack = inv.getStackInSlot(i); - if(stack.getItem() == item && canEquip(stack, living)) { + if (stack.getItem() == item && canEquip(stack, living)) { return stack; } } @@ -145,11 +145,11 @@ public abstract class EquipmentHandler { @Override protected ItemStack findItem(Predicate pred, LivingEntity living) { - if(living instanceof PlayerEntity) { + if (living instanceof PlayerEntity) { PlayerInventory inv = ((PlayerEntity) living).inventory; - for(int i = 0; i < 9; i++) { + for (int i = 0; i < 9; i++) { ItemStack stack = inv.getStackInSlot(i); - if(pred.test(stack) && canEquip(stack, living)) { + if (pred.test(stack) && canEquip(stack, living)) { return stack; } } diff --git a/src/main/java/vazkii/botania/common/core/handler/ExoflameFurnaceHandler.java b/src/main/java/vazkii/botania/common/core/handler/ExoflameFurnaceHandler.java index 3d937a82e..ebfbf7933 100644 --- a/src/main/java/vazkii/botania/common/core/handler/ExoflameFurnaceHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/ExoflameFurnaceHandler.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Dec 23, 2019, 15:42] */ package vazkii.botania.common.core.handler; @@ -22,7 +20,7 @@ import net.minecraft.world.World; import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.ObfuscationReflectionHelper; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.item.IExoflameHeatable; import vazkii.botania.common.Botania; @@ -31,9 +29,6 @@ import vazkii.botania.common.lib.LibMisc; import vazkii.botania.common.lib.LibObfuscation; import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.reflect.Field; -import java.lang.reflect.Method; @Mod.EventBusSubscriber(modid = LibMisc.MOD_ID) public class ExoflameFurnaceHandler { @@ -46,7 +41,7 @@ public class ExoflameFurnaceHandler { @SubscribeEvent public static void attachFurnaceCapability(AttachCapabilitiesEvent event) { TileEntity te = event.getObject(); - if(te instanceof AbstractFurnaceTileEntity) { + if (te instanceof AbstractFurnaceTileEntity) { AbstractFurnaceTileEntity furnace = (AbstractFurnaceTileEntity) te; SimpleCapProvider.attach(event, ID, BotaniaAPI.EXOFLAME_HEATABLE_CAP, new FurnaceExoflameHeatable(furnace)); } @@ -73,7 +68,7 @@ public class ExoflameFurnaceHandler { @Override public boolean canSmelt() { - if(furnace.getStackInSlot(0).isEmpty()) { + if (furnace.getStackInSlot(0).isEmpty()) { return false; } try { @@ -81,7 +76,7 @@ public class ExoflameFurnaceHandler { this.recipeType = ExoflameFurnaceHandler.getRecipeType(furnace); } if (currentRecipe != null) { // This is already more caching than Mojang does - if(currentRecipe.matches(furnace, furnace.getWorld()) + if (currentRecipe.matches(furnace, furnace.getWorld()) && ExoflameFurnaceHandler.canSmelt(furnace, currentRecipe)) { return true; } @@ -101,7 +96,7 @@ public class ExoflameFurnaceHandler { @Override public void boostBurnTime() { - if(getBurnTime() == 0) { + if (getBurnTime() == 0) { World world = furnace.getWorld(); BlockPos pos = furnace.getPos(); world.setBlockState(pos, world.getBlockState(pos).with(BlockStateProperties.LIT, true)); diff --git a/src/main/java/vazkii/botania/common/core/handler/IMCHandler.java b/src/main/java/vazkii/botania/common/core/handler/IMCHandler.java index 780270d17..77da6621f 100644 --- a/src/main/java/vazkii/botania/common/core/handler/IMCHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/IMCHandler.java @@ -1,12 +1,22 @@ +/* + * This class is 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 + */ package vazkii.botania.common.core.handler; import com.google.common.collect.ImmutableMap; + import net.minecraft.block.Block; import net.minecraft.item.DyeColor; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.InterModComms; import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; import net.minecraftforge.registries.IRegistryDelegate; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.imc.IMC; import vazkii.botania.api.imc.OreWeightMessage; diff --git a/src/main/java/vazkii/botania/common/core/handler/IMCSender.java b/src/main/java/vazkii/botania/common/core/handler/IMCSender.java index 443b9e501..18465b87f 100644 --- a/src/main/java/vazkii/botania/common/core/handler/IMCSender.java +++ b/src/main/java/vazkii/botania/common/core/handler/IMCSender.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.common.core.handler; import net.minecraft.block.Block; @@ -6,6 +14,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.InterModComms; import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent; import net.minecraftforge.registries.IRegistryDelegate; + import vazkii.botania.api.ColorHelper; import vazkii.botania.api.imc.IMC; import vazkii.botania.api.imc.OreWeightMessage; @@ -67,7 +76,7 @@ public class IMCSender { // Silent Mechanisms addOreWeight("bismuth", 2407); // Thaumcraft - addOreWeight("cinnabar", 2585); + addOreWeight("cinnabar", 2585); // Vanilla addOreWeightNether("quartz", 19600); @@ -108,31 +117,39 @@ public class IMCSender { */ sendToSelf(IMC.REGISTER_PAINTABLE_BLOCK, new PaintableBlockMessage(color -> ColorHelper.STAINED_GLASS_MAP.get(color).get(), Blocks.GLASS)); - for(IRegistryDelegate b : ColorHelper.STAINED_GLASS_MAP.values()) + for (IRegistryDelegate b : ColorHelper.STAINED_GLASS_MAP.values()) { sendToSelf(IMC.REGISTER_PAINTABLE_BLOCK, new PaintableBlockMessage(color -> ColorHelper.STAINED_GLASS_MAP.get(color).get(), b)); + } sendToSelf(IMC.REGISTER_PAINTABLE_BLOCK, new PaintableBlockMessage(color -> ColorHelper.STAINED_GLASS_PANE_MAP.get(color).get(), Blocks.GLASS_PANE)); - for(IRegistryDelegate b : ColorHelper.STAINED_GLASS_PANE_MAP.values()) + for (IRegistryDelegate b : ColorHelper.STAINED_GLASS_PANE_MAP.values()) { sendToSelf(IMC.REGISTER_PAINTABLE_BLOCK, new PaintableBlockMessage(color -> ColorHelper.STAINED_GLASS_PANE_MAP.get(color).get(), b)); + } sendToSelf(IMC.REGISTER_PAINTABLE_BLOCK, new PaintableBlockMessage(color -> ColorHelper.TERRACOTTA_MAP.get(color).get(), Blocks.TERRACOTTA)); - for(IRegistryDelegate b : ColorHelper.TERRACOTTA_MAP.values()) + for (IRegistryDelegate b : ColorHelper.TERRACOTTA_MAP.values()) { sendToSelf(IMC.REGISTER_PAINTABLE_BLOCK, new PaintableBlockMessage(color -> ColorHelper.TERRACOTTA_MAP.get(color).get(), b.get())); + } - for(IRegistryDelegate b : ColorHelper.GLAZED_TERRACOTTA_MAP.values()) + for (IRegistryDelegate b : ColorHelper.GLAZED_TERRACOTTA_MAP.values()) { sendToSelf(IMC.REGISTER_PAINTABLE_BLOCK, new PaintableBlockMessage(color -> ColorHelper.GLAZED_TERRACOTTA_MAP.get(color).get(), b)); + } - for(IRegistryDelegate b : ColorHelper.WOOL_MAP.values()) + for (IRegistryDelegate b : ColorHelper.WOOL_MAP.values()) { sendToSelf(IMC.REGISTER_PAINTABLE_BLOCK, new PaintableBlockMessage(color -> ColorHelper.WOOL_MAP.get(color).get(), b)); + } - for(IRegistryDelegate b : ColorHelper.CARPET_MAP.values()) + for (IRegistryDelegate b : ColorHelper.CARPET_MAP.values()) { sendToSelf(IMC.REGISTER_PAINTABLE_BLOCK, new PaintableBlockMessage(color -> ColorHelper.CARPET_MAP.get(color).get(), b)); - - for(IRegistryDelegate b : ColorHelper.CONCRETE_MAP.values()) + } + + for (IRegistryDelegate b : ColorHelper.CONCRETE_MAP.values()) { sendToSelf(IMC.REGISTER_PAINTABLE_BLOCK, new PaintableBlockMessage(color -> ColorHelper.CONCRETE_MAP.get(color).get(), b)); - - for(IRegistryDelegate b : ColorHelper.CONCRETE_POWDER_MAP.values()) + } + + for (IRegistryDelegate b : ColorHelper.CONCRETE_POWDER_MAP.values()) { sendToSelf(IMC.REGISTER_PAINTABLE_BLOCK, new PaintableBlockMessage(color -> ColorHelper.CONCRETE_POWDER_MAP.get(color).get(), b)); + } } public static void sendToSelf(String method, Object thing) { diff --git a/src/main/java/vazkii/botania/common/core/handler/InternalMethodHandler.java b/src/main/java/vazkii/botania/common/core/handler/InternalMethodHandler.java index 0d3a67200..cc9b3a7c5 100644 --- a/src/main/java/vazkii/botania/common/core/handler/InternalMethodHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/InternalMethodHandler.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 14, 2014, 6:44:59 PM (GMT)] */ package vazkii.botania.common.core.handler; @@ -21,6 +19,7 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.wrapper.EmptyHandler; + import vazkii.botania.api.corporea.CorporeaHelper; import vazkii.botania.api.corporea.ICorporeaSpark; import vazkii.botania.api.corporea.IWrappedInventory; @@ -52,7 +51,7 @@ public class InternalMethodHandler extends DummyMethodHandler { @Override public IItemHandlerModifiable getAccessoriesInventory(PlayerEntity player) { - if(Botania.curiosLoaded) { + if (Botania.curiosLoaded) { LazyOptional cap = EquipmentHandler.getAllWorn(player); return cap.orElseGet(EmptyHandler::new); } @@ -76,9 +75,9 @@ public class InternalMethodHandler extends DummyMethodHandler { @Override public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m) { - SparkleParticleData data = SparkleParticleData.sparkle(size, r, g, b, m); - world.addParticle(data, x, y, z, 0, 0, 0); - } + SparkleParticleData data = SparkleParticleData.sparkle(size, r, g, b, m); + world.addParticle(data, x, y, z, 0, 0, 0); + } @Override public ResourceLocation getDefaultBossBarTexture() { @@ -113,13 +112,13 @@ public class InternalMethodHandler extends DummyMethodHandler { @Override public List wrapInventory(List inventories) { List arrayList = new ArrayList(); - for(InvWithLocation inv : inventories) { + for (InvWithLocation inv : inventories) { ICorporeaSpark spark = CorporeaHelper.getSparkForInventory(inv); IWrappedInventory wrapped = null; // try integrations // last chance - this will always work - if(wrapped == null) { + if (wrapped == null) { wrapped = WrappedIInventory.wrap(inv, spark); } arrayList.add(wrapped); diff --git a/src/main/java/vazkii/botania/common/core/handler/ManaNetworkHandler.java b/src/main/java/vazkii/botania/common/core/handler/ManaNetworkHandler.java index 0a462e335..ac186b69b 100644 --- a/src/main/java/vazkii/botania/common/core/handler/ManaNetworkHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/ManaNetworkHandler.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 22, 2014, 5:35:10 PM (GMT)] */ package vazkii.botania.common.core.handler; @@ -14,6 +12,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.eventbus.api.SubscribeEvent; + import vazkii.botania.api.internal.IManaNetwork; import vazkii.botania.api.mana.ManaNetworkEvent; import vazkii.botania.api.mana.ManaNetworkEvent.Action; @@ -36,9 +35,11 @@ public final class ManaNetworkHandler implements IManaNetwork { @SubscribeEvent public void onNetworkEvent(ManaNetworkEvent event) { Map> map = event.type == ManaBlockType.COLLECTOR ? manaCollectors : manaPools; - if(event.action == Action.ADD) + if (event.action == Action.ADD) { add(map, event.tile); - else remove(map, event.tile); + } else { + remove(map, event.tile); + } } @Override @@ -49,15 +50,17 @@ public final class ManaNetworkHandler implements IManaNetwork { @Override public TileEntity getClosestPool(BlockPos pos, World world, int limit) { - if(manaPools.containsKey(world)) + if (manaPools.containsKey(world)) { return getClosest(manaPools.get(world), pos, world.isRemote, limit); + } return null; } @Override public TileEntity getClosestCollector(BlockPos pos, World world, int limit) { - if(manaCollectors.containsKey(world)) + if (manaCollectors.containsKey(world)) { return getClosest(manaCollectors.get(world), pos, world.isRemote, limit); + } return null; } @@ -85,8 +88,9 @@ public final class ManaNetworkHandler implements IManaNetwork { private void remove(Map> map, TileEntity tile) { World world = tile.getWorld(); - if(!map.containsKey(world)) + if (!map.containsKey(world)) { return; + } map.get(world).remove(tile); } diff --git a/src/main/java/vazkii/botania/common/core/handler/ModSounds.java b/src/main/java/vazkii/botania/common/core/handler/ModSounds.java index fe72bc0a3..b7aab707a 100644 --- a/src/main/java/vazkii/botania/common/core/handler/ModSounds.java +++ b/src/main/java/vazkii/botania/common/core/handler/ModSounds.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.common.core.handler; import net.minecraft.util.ResourceLocation; @@ -6,6 +14,7 @@ import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.registries.IForgeRegistry; + import vazkii.botania.common.lib.LibMisc; @Mod.EventBusSubscriber(modid = LibMisc.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) @@ -54,12 +63,12 @@ public final class ModSounds { public static final SoundEvent gaiaMusic1 = makeSoundEvent("music.gaia1"); public static final SoundEvent gaiaMusic2 = makeSoundEvent("music.gaia2"); - + private static SoundEvent makeSoundEvent(String name) { ResourceLocation loc = new ResourceLocation(LibMisc.MOD_ID, name); return new SoundEvent(loc).setRegistryName(loc); } - + @SubscribeEvent public static void registerSounds(RegistryEvent.Register evt) { IForgeRegistry r = evt.getRegistry(); diff --git a/src/main/java/vazkii/botania/common/core/handler/PixieHandler.java b/src/main/java/vazkii/botania/common/core/handler/PixieHandler.java index 1541ba5c6..f0e6b11ae 100644 --- a/src/main/java/vazkii/botania/common/core/handler/PixieHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/PixieHandler.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.common.core.handler; import net.minecraft.entity.LivingEntity; @@ -16,9 +24,9 @@ import net.minecraft.util.Util; import net.minecraft.util.math.BlockPos; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingHurtEvent; -import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.common.core.helper.PlayerHelper; import vazkii.botania.common.entity.EntityPixie; import vazkii.botania.common.item.ModItems; @@ -67,22 +75,23 @@ public final class PixieHandler { @SubscribeEvent public static void onDamageTaken(LivingHurtEvent event) { - if(!event.getEntityLiving().world.isRemote && event.getEntityLiving() instanceof PlayerEntity && event.getSource().getTrueSource() instanceof LivingEntity) { + if (!event.getEntityLiving().world.isRemote && event.getEntityLiving() instanceof PlayerEntity && event.getSource().getTrueSource() instanceof LivingEntity) { PlayerEntity player = (PlayerEntity) event.getEntityLiving(); double chance = player.getAttribute(PIXIE_SPAWN_CHANCE).getValue(); ItemStack sword = PlayerHelper.getFirstHeldItem(player, s -> s.getItem() == ModItems.elementiumSword); - if(Math.random() < chance) { + if (Math.random() < chance) { EntityPixie pixie = new EntityPixie(player.world); pixie.setPosition(player.getX(), player.getY() + 2, player.getZ()); - if(((ItemElementiumHelm) ModItems.elementiumHelm).hasArmorSet(player)) { + if (((ItemElementiumHelm) ModItems.elementiumHelm).hasArmorSet(player)) { pixie.setApplyPotionEffect(new EffectInstance(potions[event.getEntityLiving().world.rand.nextInt(potions.length)], 40, 0)); } float dmg = 4; - if(!sword.isEmpty()) + if (!sword.isEmpty()) { dmg += 2; + } pixie.setProps((LivingEntity) event.getSource().getTrueSource(), player, 0, dmg); pixie.onInitialSpawn(player.world, player.world.getDifficultyForLocation(new BlockPos(pixie)), diff --git a/src/main/java/vazkii/botania/common/core/handler/SleepingHandler.java b/src/main/java/vazkii/botania/common/core/handler/SleepingHandler.java index 0f9a3830b..44fdd3046 100644 --- a/src/main/java/vazkii/botania/common/core/handler/SleepingHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/SleepingHandler.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.common.core.handler; import net.minecraft.entity.player.PlayerEntity; @@ -6,6 +14,7 @@ import net.minecraft.world.server.ServerWorld; import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.common.entity.EntityDoppleganger; import vazkii.botania.common.lib.LibMisc; @@ -17,12 +26,12 @@ public final class SleepingHandler { @SubscribeEvent public static void trySleep(PlayerSleepInBedEvent event) { World world = event.getPlayer().world; - if(!world.isRemote()) { + if (!world.isRemote()) { boolean nearGuardian = ((ServerWorld) world).getEntities() .filter(e -> e instanceof EntityDoppleganger) .anyMatch(e -> ((EntityDoppleganger) e).getPlayersAround().contains(event.getPlayer())); - if(nearGuardian) { + if (nearGuardian) { event.setResult(PlayerEntity.SleepResult.NOT_SAFE); } } diff --git a/src/main/java/vazkii/botania/common/core/helper/ExperienceHelper.java b/src/main/java/vazkii/botania/common/core/helper/ExperienceHelper.java index 53933a1ae..78ac4b3bb 100644 --- a/src/main/java/vazkii/botania/common/core/helper/ExperienceHelper.java +++ b/src/main/java/vazkii/botania/common/core/helper/ExperienceHelper.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [? (GMT)] */ package vazkii.botania.common.core.helper; @@ -16,7 +14,7 @@ import net.minecraft.entity.player.PlayerEntity; public class ExperienceHelper { public static int getPlayerXP(PlayerEntity player) { - return (int)(getExperienceForLevel(player.experienceLevel) + player.experience * player.xpBarCap()); + return (int) (getExperienceForLevel(player.experienceLevel) + player.experience * player.xpBarCap()); } public static void drainPlayerXP(PlayerEntity player, int amount) { @@ -28,19 +26,21 @@ public class ExperienceHelper { player.experienceTotal = experience; player.experienceLevel = getLevelForExperience(experience); int expForLevel = getExperienceForLevel(player.experienceLevel); - player.experience = (float)(experience - expForLevel) / (float)player.xpBarCap(); + player.experience = (float) (experience - expForLevel) / (float) player.xpBarCap(); } public static int getExperienceForLevel(int level) { - if (level == 0) + if (level == 0) { return 0; + } - if (level > 0 && level < 17) - return (int) (level * level + 6 * level); - else if (level > 16 && level < 32) - return (int) (2.5 * level * level - 40.5 * level + 360); - else - return (int) (4.5 * level * level - 162.5 * level + 2220); + if (level > 0 && level < 17) { + return (int) (level * level + 6 * level); + } else if (level > 16 && level < 32) { + return (int) (2.5 * level * level - 40.5 * level + 360); + } else { + return (int) (4.5 * level * level - 162.5 * level + 2220); + } } public static int getLevelForExperience(int experience) { diff --git a/src/main/java/vazkii/botania/common/core/helper/InventoryHelper.java b/src/main/java/vazkii/botania/common/core/helper/InventoryHelper.java index 12673f801..e7cc4852d 100644 --- a/src/main/java/vazkii/botania/common/core/helper/InventoryHelper.java +++ b/src/main/java/vazkii/botania/common/core/helper/InventoryHelper.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [? (GMT)] */ package vazkii.botania.common.core.helper; @@ -21,6 +19,7 @@ import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemHandlerHelper; + import vazkii.botania.api.corporea.InvWithLocation; import vazkii.botania.common.block.tile.TileSimpleInventory; @@ -28,29 +27,33 @@ public class InventoryHelper { public static InvWithLocation getInventoryWithLocation(World world, BlockPos pos, Direction side) { IItemHandler ret = getInventory(world, pos, side); - if(ret == null) + if (ret == null) { return null; - else return new InvWithLocation(ret, world, pos); + } else { + return new InvWithLocation(ret, world, pos); + } } public static IItemHandler getInventory(World world, BlockPos pos, Direction side) { TileEntity te = world.getTileEntity(pos); - if(te == null) + if (te == null) { return null; + } LazyOptional ret = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side); - if (!ret.isPresent()) + if (!ret.isPresent()) { ret = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); + } return ret.orElse(null); } public static void dropInventory(TileSimpleInventory inv, World world, BlockState state, BlockPos pos) { - if(inv != null) { - for(int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { + if (inv != null) { + for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) { ItemStack itemstack = inv.getItemHandler().getStackInSlot(j1); - if(!itemstack.isEmpty()) { + if (!itemstack.isEmpty()) { net.minecraft.inventory.InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), itemstack); } } @@ -60,9 +63,9 @@ public class InventoryHelper { } public static void withdrawFromInventory(TileSimpleInventory inv, PlayerEntity player) { - for(int i = inv.getSizeInventory() - 1; i >= 0; i--) { + for (int i = inv.getSizeInventory() - 1; i >= 0; i--) { ItemStack stackAt = inv.getItemHandler().getStackInSlot(i); - if(!stackAt.isEmpty()) { + if (!stackAt.isEmpty()) { ItemStack copy = stackAt.copy(); ItemHandlerHelper.giveItemToPlayer(player, copy); inv.getItemHandler().setStackInSlot(i, ItemStack.EMPTY); diff --git a/src/main/java/vazkii/botania/common/core/helper/ItemNBTHelper.java b/src/main/java/vazkii/botania/common/core/helper/ItemNBTHelper.java index 94461c750..7542eb5b4 100644 --- a/src/main/java/vazkii/botania/common/core/helper/ItemNBTHelper.java +++ b/src/main/java/vazkii/botania/common/core/helper/ItemNBTHelper.java @@ -1,15 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the ThaumicTinkerer Mod. +/* + * This class is distributed as part of the Botania Mod. + * Get the Source Code in github: + * https://github.com/Vazkii/Botania * - * ThaumicTinkerer is Open Source and distributed under a + * Botania is Open Source and distributed under the * Botania License: http://botaniamod.net/license.php - * - * ThaumicTinkerer is a Derivative Work on Thaumcraft 4. - * Thaumcraft 4 (c) Azanor 2012 - * (http://www.minecraftforum.net/topic/1585216-) - * - * File Created @ [8 Sep 2013, 19:36:25 (GMT)] */ package vazkii.botania.common.core.helper; @@ -19,6 +14,7 @@ import net.minecraft.nbt.INBT; import net.minecraft.nbt.ListNBT; import javax.annotation.Nullable; + import java.util.UUID; public final class ItemNBTHelper { @@ -64,8 +60,10 @@ public final class ItemNBTHelper { } public static void setCompound(ItemStack stack, String tag, CompoundNBT cmp) { - if(!tag.equalsIgnoreCase("ench")) // not override the enchantments + if (!tag.equalsIgnoreCase("ench")) // not override the enchantments + { stack.getOrCreateTag().put(tag, cmp); + } } public static void setString(ItemStack stack, String tag, String s) { @@ -127,8 +125,10 @@ public final class ItemNBTHelper { return verifyExistance(stack, tag) ? stack.getOrCreateTag().getDouble(tag) : defaultExpected; } - /** If nullifyOnFail is true it'll return null if it doesn't find any - * compounds, otherwise it'll return a new one. **/ + /** + * If nullifyOnFail is true it'll return null if it doesn't find any + * compounds, otherwise it'll return a new one. + **/ public static CompoundNBT getCompound(ItemStack stack, String tag, boolean nullifyOnFail) { return verifyExistance(stack, tag) ? stack.getOrCreateTag().getCompound(tag) : nullifyOnFail ? null : new CompoundNBT(); } @@ -153,9 +153,9 @@ public final class ItemNBTHelper { * any size. */ public static boolean matchTag(@Nullable INBT template, @Nullable INBT target) { - if(template instanceof CompoundNBT && target instanceof CompoundNBT) { + if (template instanceof CompoundNBT && target instanceof CompoundNBT) { return matchTagCompound((CompoundNBT) template, (CompoundNBT) target); - } else if(template instanceof ListNBT && target instanceof ListNBT) { + } else if (template instanceof ListNBT && target instanceof ListNBT) { return matchTagList((ListNBT) template, (ListNBT) target); } else { return template == null || (target != null && target.equals(template)); @@ -163,20 +163,28 @@ public final class ItemNBTHelper { } private static boolean matchTagCompound(CompoundNBT template, CompoundNBT target) { - if(template.size() > target.size()) return false; - - for(String key : template.keySet()) { - if (!matchTag(template.get(key), target.get(key))) return false; + if (template.size() > target.size()) { + return false; } - + + for (String key : template.keySet()) { + if (!matchTag(template.get(key), target.get(key))) { + return false; + } + } + return true; } private static boolean matchTagList(ListNBT template, ListNBT target) { - if (template.size() > target.size()) return false; + if (template.size() > target.size()) { + return false; + } for (int i = 0; i < template.size(); i++) { - if (!matchTag(template.get(i), target.get(i))) return false; + if (!matchTag(template.get(i), target.get(i))) { + return false; + } } return true; diff --git a/src/main/java/vazkii/botania/common/core/helper/MathHelper.java b/src/main/java/vazkii/botania/common/core/helper/MathHelper.java index abdb6df59..7ba422c6e 100644 --- a/src/main/java/vazkii/botania/common/core/helper/MathHelper.java +++ b/src/main/java/vazkii/botania/common/core/helper/MathHelper.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 22, 2014, 5:49:50 PM (GMT)] */ package vazkii.botania.common.core.helper; @@ -15,6 +13,7 @@ import net.minecraft.util.Direction; public final class MathHelper { public static final Direction[] HORIZONTALS = { Direction.SOUTH, Direction.WEST, Direction.NORTH, Direction.EAST }; + public static float pointDistanceSpace(double x1, double y1, double z1, double x2, double y2, double z2) { return (float) Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) + (z1 - z2) * (z1 - z2)); } @@ -27,8 +26,9 @@ public final class MathHelper { Vector3 entityVector = Vector3.fromEntityCenter(entity); Vector3 finalVector = originalPosVector.subtract(entityVector); - if(finalVector.mag() > 1) + if (finalVector.mag() > 1) { finalVector = finalVector.normalize(); + } entity.setMotion(finalVector.multiply(modifier).toVec3D()); } @@ -40,13 +40,14 @@ public final class MathHelper { int g2 = (c2 & 0x00FF00) >> 8; int b1 = (c1 & 0x0000FF); int b2 = (c2 & 0x0000FF); - int r = (int)(r1 * (r2 / 255.0F)); - int g = (int)(g1 * (g2 / 255.0F)); - int b = (int)(b1 * (b2 / 255.0F)); + int r = (int) (r1 * (r2 / 255.0F)); + int g = (int) (g1 * (g2 / 255.0F)); + int b = (int) (b1 * (b2 / 255.0F)); return c1 & ~0xFFFFFF | r << 16 | g << 8 | b; } - private static final String[] ORDINAL_SUFFIXES = new String[]{ "th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th" }; + private static final String[] ORDINAL_SUFFIXES = new String[] { "th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th" }; + public static String numberToOrdinal(int i) { return i % 100 == 11 || i % 100 == 12 || i % 100 == 13 ? i + "th" : i + ORDINAL_SUFFIXES[i % 10]; } diff --git a/src/main/java/vazkii/botania/common/core/helper/PlayerHelper.java b/src/main/java/vazkii/botania/common/core/helper/PlayerHelper.java index 9dea7921a..6a0f2ba11 100644 --- a/src/main/java/vazkii/botania/common/core/helper/PlayerHelper.java +++ b/src/main/java/vazkii/botania/common/core/helper/PlayerHelper.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.common.core.helper; import net.minecraft.advancements.Advancement; @@ -46,11 +54,13 @@ public final class PlayerHelper { public static ItemStack getFirstHeldItem(PlayerEntity player, Predicate pred) { ItemStack main = player.getHeldItemMainhand(); ItemStack offhand = player.getHeldItemOffhand(); - if(!main.isEmpty() && pred.test(main)) { + if (!main.isEmpty() && pred.test(main)) { return main; - } else if(!offhand.isEmpty() && pred.test(offhand)) { + } else if (!offhand.isEmpty() && pred.test(offhand)) { return offhand; - } else return ItemStack.EMPTY; + } else { + return ItemStack.EMPTY; + } } public static ItemStack getFirstHeldItemClass(PlayerEntity player, Class template) { @@ -59,22 +69,15 @@ public final class PlayerHelper { public static ItemStack getAmmo(PlayerEntity player, Predicate ammoFunc) { // Mainly from ItemBow.findAmmo - if (ammoFunc.test(player.getHeldItem(Hand.OFF_HAND))) - { + if (ammoFunc.test(player.getHeldItem(Hand.OFF_HAND))) { return player.getHeldItem(Hand.OFF_HAND); - } - else if (ammoFunc.test(player.getHeldItem(Hand.MAIN_HAND))) - { + } else if (ammoFunc.test(player.getHeldItem(Hand.MAIN_HAND))) { return player.getHeldItem(Hand.MAIN_HAND); - } - else - { - for (int i = 0; i < player.inventory.getSizeInventory(); ++i) - { + } else { + for (int i = 0; i < player.inventory.getSizeInventory(); ++i) { ItemStack itemstack = player.inventory.getStackInSlot(i); - if (ammoFunc.test(itemstack)) - { + if (ammoFunc.test(itemstack)) { return itemstack; } } @@ -89,15 +92,16 @@ public final class PlayerHelper { public static void consumeAmmo(PlayerEntity player, Predicate ammoFunc) { ItemStack ammo = getAmmo(player, ammoFunc); - if(!ammo.isEmpty()) { + if (!ammo.isEmpty()) { ammo.shrink(1); } } public static boolean hasItem(PlayerEntity player, Predicate itemFunc) { for (int i = 0; i < player.inventory.getSizeInventory(); i++) { - if (itemFunc.test(player.inventory.getStackInSlot(i))) + if (itemFunc.test(player.inventory.getStackInSlot(i))) { return true; + } } return false; } @@ -106,7 +110,7 @@ public final class PlayerHelper { PlayerAdvancements advancements = player.getAdvancements(); AdvancementManager manager = player.getServerWorld().getServer().getAdvancementManager(); Advancement advancement = manager.getAdvancement(advancementId); - if(advancement != null) { + if (advancement != null) { advancements.grantCriterion(advancement, criterion); } } @@ -115,7 +119,6 @@ public final class PlayerHelper { * Temporarily swap toUse into the hand of the player, use it, then swap it back out. * This is to ensure that any code in mods' onItemUse that relies on player.getHeldItem(ctx.hand) == ctx.stack * will work as intended. - * * Properly handles null players, as long as the Item's onItemUse also handles them. */ public static ActionResultType substituteUse(ItemUseContext ctx, ItemStack toUse) { @@ -123,7 +126,7 @@ public final class PlayerHelper { BlockRayTraceResult hit = new BlockRayTraceResult(ctx.getHitVec(), ctx.getFace(), ctx.getPos(), ctx.isInside()); ItemUseContext newCtx; - if(ctx.getPlayer() != null) { + if (ctx.getPlayer() != null) { save = ctx.getPlayer().getHeldItem(ctx.getHand()); ctx.getPlayer().setHeldItem(ctx.getHand(), toUse); // Need to construct a new one still to refresh the itemstack @@ -134,7 +137,7 @@ public final class PlayerHelper { ActionResultType result = toUse.onItemUse(newCtx); - if(ctx.getPlayer() != null) { + if (ctx.getPlayer() != null) { ctx.getPlayer().setHeldItem(ctx.getHand(), save); } diff --git a/src/main/java/vazkii/botania/common/core/helper/Quat.java b/src/main/java/vazkii/botania/common/core/helper/Quat.java index 9daeae36b..2c14b5362 100644 --- a/src/main/java/vazkii/botania/common/core/helper/Quat.java +++ b/src/main/java/vazkii/botania/common/core/helper/Quat.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [? (GMT)] */ package vazkii.botania.common.core.helper; @@ -28,7 +26,7 @@ public final class Quat { y = d2; z = d3; s = d; - hashCode = Arrays.hashCode(new double[] { d, d1, d2, d3 } ); + hashCode = Arrays.hashCode(new double[] { d, d1, d2, d3 }); } public static Quat aroundAxis(double ax, double ay, double az, double angle) { @@ -108,4 +106,4 @@ public final class Quat { return aroundAxis(axis.x, axis.y, axis.z, angle); } -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/common/core/helper/StringObfuscator.java b/src/main/java/vazkii/botania/common/core/helper/StringObfuscator.java index 2c95c0565..300461ca9 100644 --- a/src/main/java/vazkii/botania/common/core/helper/StringObfuscator.java +++ b/src/main/java/vazkii/botania/common/core/helper/StringObfuscator.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Oct 30, 2016, 9:53:03 PM (GMT)] */ package vazkii.botania.common.core.helper; import javax.xml.bind.annotation.adapters.HexBinaryAdapter; + import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -23,13 +22,14 @@ public final class StringObfuscator { } private static String getHash(String str) { - if(str != null) + if (str != null) { try { MessageDigest md = MessageDigest.getInstance("SHA-256"); return new HexBinaryAdapter().marshal(md.digest(dontRainbowTableMeOrMySonEverAgain(str).getBytes(StandardCharsets.UTF_8))); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } + } return ""; } @@ -40,12 +40,12 @@ public final class StringObfuscator { int l = str.length(); int steps = rand.nextInt(l); char[] chrs = str.toCharArray(); - for(int i = 0; i < steps; i++) { + for (int i = 0; i < steps; i++) { int indA = rand.nextInt(l); int indB; do { indB = rand.nextInt(l); - } while(indB == indA); + } while (indB == indA); char c = (char) (chrs[indA] ^ chrs[indB]); chrs[indA] = c; } diff --git a/src/main/java/vazkii/botania/common/core/helper/Vector3.java b/src/main/java/vazkii/botania/common/core/helper/Vector3.java index 5e2cba65f..8f5695a0b 100644 --- a/src/main/java/vazkii/botania/common/core/helper/Vector3.java +++ b/src/main/java/vazkii/botania/common/core/helper/Vector3.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [? (GMT)] */ package vazkii.botania.common.core.helper; @@ -19,6 +17,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import org.lwjgl.opengl.GL11; import java.math.BigDecimal; @@ -26,8 +25,7 @@ import java.math.MathContext; import java.math.RoundingMode; import java.util.Objects; -public class Vector3 -{ +public class Vector3 { public static final Vector3 ZERO = new Vector3(0, 0, 0); public static final Vector3 ONE = new Vector3(1, 1, 1); public static final Vector3 CENTER = new Vector3(0.5, 0.5, 0.5); @@ -69,10 +67,11 @@ public class Vector3 public double dotProduct(Vector3 vec) { double d = vec.x * x + vec.y * y + vec.z * z; - if(d > 1 && d < 1.00001) + if (d > 1 && d < 1.00001) { d = 1; - else if(d < -1 && d > -1.00001) + } else if (d < -1 && d > -1.00001) { d = -1; + } return d; } @@ -125,8 +124,9 @@ public class Vector3 public Vector3 normalize() { double d = mag(); - if(d != 0) + if (d != 0) { return multiply(1 / d); + } return this; } @@ -134,12 +134,13 @@ public class Vector3 @Override public String toString() { MathContext cont = new MathContext(4, RoundingMode.HALF_UP); - return "Vector3(" + new BigDecimal(x, cont) + ", " +new BigDecimal(y, cont) + ", " + new BigDecimal(z, cont) + ")"; + return "Vector3(" + new BigDecimal(x, cont) + ", " + new BigDecimal(y, cont) + ", " + new BigDecimal(z, cont) + ")"; } public Vector3 perpendicular() { - if(z == 0) + if (z == 0) { return zCrossProduct(); + } return xCrossProduct(); } @@ -183,12 +184,12 @@ public class Vector3 @OnlyIn(Dist.CLIENT) public Vector3f vector3f() { - return new Vector3f((float)x, (float)y, (float)z); + return new Vector3f((float) x, (float) y, (float) z); } @OnlyIn(Dist.CLIENT) public Vector4f vector4f() { - return new Vector4f((float)x, (float)y, (float)z, 1); + return new Vector4f((float) x, (float) y, (float) z, 1); } @OnlyIn(Dist.CLIENT) @@ -202,16 +203,16 @@ public class Vector3 public double scalarProject(Vector3 b) { double l = b.mag(); - return l == 0 ? 0 : dotProduct(b)/l; + return l == 0 ? 0 : dotProduct(b) / l; } public Vector3 project(Vector3 b) { double l = b.magSquared(); - if(l == 0) { + if (l == 0) { return ZERO; } - double m = dotProduct(b)/l; + double m = dotProduct(b) / l; return b.multiply(m); } @@ -221,10 +222,11 @@ public class Vector3 @Override public boolean equals(Object o) { - if(!(o instanceof Vector3)) + if (!(o instanceof Vector3)) { return false; + } - Vector3 v = (Vector3)o; + Vector3 v = (Vector3) o; return x == v.x && y == v.y && z == v.z; } @@ -232,4 +234,4 @@ public class Vector3 public int hashCode() { return Objects.hash(x, y, z); } -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/common/core/loot/BindUuid.java b/src/main/java/vazkii/botania/common/core/loot/BindUuid.java index 2b5e1a112..ce0ead7d8 100644 --- a/src/main/java/vazkii/botania/common/core/loot/BindUuid.java +++ b/src/main/java/vazkii/botania/common/core/loot/BindUuid.java @@ -1,8 +1,17 @@ +/* + * This class is 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 + */ package vazkii.botania.common.core.loot; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; + import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; @@ -10,6 +19,7 @@ import net.minecraft.world.storage.loot.LootContext; import net.minecraft.world.storage.loot.LootFunction; import net.minecraft.world.storage.loot.LootParameters; import net.minecraft.world.storage.loot.conditions.ILootCondition; + import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.relic.ItemRelic; import vazkii.botania.common.lib.LibMisc; diff --git a/src/main/java/vazkii/botania/common/core/loot/EnableRelics.java b/src/main/java/vazkii/botania/common/core/loot/EnableRelics.java index d5ede7280..a40f8c7dd 100644 --- a/src/main/java/vazkii/botania/common/core/loot/EnableRelics.java +++ b/src/main/java/vazkii/botania/common/core/loot/EnableRelics.java @@ -1,11 +1,21 @@ +/* + * This class is 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 + */ package vazkii.botania.common.core.loot; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; + import net.minecraft.util.ResourceLocation; import net.minecraft.world.storage.loot.LootContext; import net.minecraft.world.storage.loot.conditions.ILootCondition; + import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.lib.LibMisc; diff --git a/src/main/java/vazkii/botania/common/core/loot/LootHandler.java b/src/main/java/vazkii/botania/common/core/loot/LootHandler.java index 20abfd00f..f5b144ab8 100644 --- a/src/main/java/vazkii/botania/common/core/loot/LootHandler.java +++ b/src/main/java/vazkii/botania/common/core/loot/LootHandler.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.common.core.loot; import net.minecraft.util.ResourceLocation; @@ -7,6 +15,7 @@ import net.minecraft.world.storage.loot.TableLootEntry; import net.minecraftforge.event.LootTableLoadEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.common.lib.LibMisc; @Mod.EventBusSubscriber(modid = LibMisc.MOD_ID) @@ -26,8 +35,11 @@ public final class LootHandler { case "simple_dungeon": case "spawn_bonus_chest": case "stronghold_corridor": - case "village_blacksmith": evt.getTable().addPool(getInjectPool(file)); break; - default: break; + case "village_blacksmith": + evt.getTable().addPool(getInjectPool(file)); + break; + default: + break; } } } diff --git a/src/main/java/vazkii/botania/common/core/loot/TrueGuardianKiller.java b/src/main/java/vazkii/botania/common/core/loot/TrueGuardianKiller.java index b67fdcff2..c4f31d36d 100644 --- a/src/main/java/vazkii/botania/common/core/loot/TrueGuardianKiller.java +++ b/src/main/java/vazkii/botania/common/core/loot/TrueGuardianKiller.java @@ -1,13 +1,23 @@ +/* + * This class is 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 + */ package vazkii.botania.common.core.loot; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; + import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; import net.minecraft.world.storage.loot.LootContext; import net.minecraft.world.storage.loot.LootParameters; import net.minecraft.world.storage.loot.conditions.ILootCondition; + import vazkii.botania.common.entity.EntityDoppleganger; import vazkii.botania.common.lib.LibMisc; diff --git a/src/main/java/vazkii/botania/common/core/proxy/IProxy.java b/src/main/java/vazkii/botania/common/core/proxy/IProxy.java index 336b6cf96..3a1a17ef5 100644 --- a/src/main/java/vazkii/botania/common/core/proxy/IProxy.java +++ b/src/main/java/vazkii/botania/common/core/proxy/IProxy.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.common.core.proxy; import net.minecraft.entity.LivingEntity; @@ -6,6 +14,7 @@ import net.minecraft.particles.IParticleData; import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import vazkii.botania.api.boss.IBotaniaBoss; import vazkii.botania.common.core.helper.Vector3; import vazkii.patchouli.api.IMultiblock; diff --git a/src/main/java/vazkii/botania/common/core/proxy/ServerProxy.java b/src/main/java/vazkii/botania/common/core/proxy/ServerProxy.java index 94ddd47cf..19e36bf3b 100644 --- a/src/main/java/vazkii/botania/common/core/proxy/ServerProxy.java +++ b/src/main/java/vazkii/botania/common/core/proxy/ServerProxy.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 13, 2014, 7:45:37 PM (GMT)] */ package vazkii.botania.common.core.proxy; @@ -14,9 +12,9 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.world.dimension.DimensionType; import net.minecraftforge.fml.server.ServerLifecycleHooks; + import vazkii.botania.api.boss.IBotaniaBoss; import vazkii.botania.common.core.helper.Vector3; -import vazkii.botania.common.lib.LibMisc; public class ServerProxy implements IProxy { diff --git a/src/main/java/vazkii/botania/common/crafting/FluxfieldCondition.java b/src/main/java/vazkii/botania/common/crafting/FluxfieldCondition.java index 0bd4294db..06ab6c875 100644 --- a/src/main/java/vazkii/botania/common/crafting/FluxfieldCondition.java +++ b/src/main/java/vazkii/botania/common/crafting/FluxfieldCondition.java @@ -1,6 +1,6 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @@ -9,9 +9,11 @@ package vazkii.botania.common.crafting; import com.google.gson.JsonObject; + import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.crafting.conditions.ICondition; import net.minecraftforge.common.crafting.conditions.IConditionSerializer; + import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.lib.LibMisc; diff --git a/src/main/java/vazkii/botania/common/crafting/ModBrewRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModBrewRecipes.java index e323d5d29..24404d0f5 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModBrewRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModBrewRecipes.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 1, 2014, 9:15:15 PM (GMT)] */ package vazkii.botania.common.crafting; @@ -19,6 +17,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.registries.ForgeRegistries; + import vazkii.botania.api.recipe.RecipeBrew; import vazkii.botania.api.recipe.RegisterRecipesEvent; import vazkii.botania.common.Botania; @@ -55,7 +54,7 @@ public class ModBrewRecipes { evt.brew().accept(new RecipeBrew(prefix("allure"), ModBrews.allure, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.COD), Ingredient.fromItems(Items.QUARTZ), Ingredient.fromItems(Items.GOLDEN_CARROT))); evt.brew().accept(new RecipeBrew(prefix("clear"), ModBrews.clear, Ingredient.fromItems(Items.NETHER_WART), Ingredient.fromItems(Items.QUARTZ), Ingredient.fromItems(Items.EMERALD), Ingredient.fromItems(Items.MELON_SLICE))); - if(Botania.thaumcraftLoaded) { + if (Botania.thaumcraftLoaded) { Item salisMundus = ForgeRegistries.ITEMS.getValue(new ResourceLocation("thaumcraft", "salis_mundus")); Item bathSalts = ForgeRegistries.ITEMS.getValue(new ResourceLocation("thaumcraft", "bath_salts")); Item amber = ForgeRegistries.ITEMS.getValue(new ResourceLocation("thaumcraft", "amber")); diff --git a/src/main/java/vazkii/botania/common/crafting/ModElvenTradeRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModElvenTradeRecipes.java index fd3e46393..be31b5729 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModElvenTradeRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModElvenTradeRecipes.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.common.crafting; import net.minecraft.block.Blocks; @@ -7,6 +15,7 @@ import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.ResourceLocation; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.api.recipe.RecipeElvenTrade; import vazkii.botania.api.recipe.RegisterRecipesEvent; import vazkii.botania.common.block.ModBlocks; @@ -65,8 +74,9 @@ public class ModElvenTradeRecipes { @Override public Optional> match(List stacks) { - if(stacks.size() == 1 && !ItemNBTHelper.getBoolean(stacks.get(0), ItemLexicon.TAG_ELVEN_UNLOCK, false)) + if (stacks.size() == 1 && !ItemNBTHelper.getBoolean(stacks.get(0), ItemLexicon.TAG_ELVEN_UNLOCK, false)) { return super.match(stacks); + } return Optional.empty(); } diff --git a/src/main/java/vazkii/botania/common/crafting/ModManaAlchemyRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModManaAlchemyRecipes.java index a763ce693..4f86ebdb1 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModManaAlchemyRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModManaAlchemyRecipes.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 2, 2014, 7:50:07 PM (GMT)] */ package vazkii.botania.common.crafting; @@ -19,6 +17,7 @@ import net.minecraft.util.IItemProvider; import net.minecraft.util.ResourceLocation; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.api.recipe.RecipeManaInfusion; import vazkii.botania.api.recipe.RegisterRecipesEvent; import vazkii.botania.common.Botania; @@ -28,6 +27,7 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nullable; + import java.util.function.Consumer; import static vazkii.botania.common.lib.ResourceLocationHelper.prefix; @@ -100,7 +100,7 @@ public final class ModManaAlchemyRecipes { cycle(evt.manaInfusion(), 240, "botania:berry_cycle", Items.APPLE, Items.SWEET_BERRIES); - if(Botania.gardenOfGlassLoaded) { + if (Botania.gardenOfGlassLoaded) { evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("prismarine_shard_gog"), new ItemStack(Items.PRISMARINE_SHARD), Ingredient.fromItems(Items.QUARTZ), 1000)); evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("prismarine_crystals_gog"), new ItemStack(Items.PRISMARINE_CRYSTALS), Ingredient.fromItems(Items.PRISMARINE_SHARD), 500)); evt.manaInfusion().accept(RecipeManaInfusion.alchemy(prefix("heart_of_the_sea"), new ItemStack(Items.HEART_OF_THE_SEA), Ingredient.fromItems(Items.NAUTILUS_SHELL), 20000)); @@ -117,14 +117,14 @@ public final class ModManaAlchemyRecipes { } private static void cycle(Consumer consumer, int cost, @Nullable String group, IItemProvider... items) { - for(int i = 0; i < items.length; i++) { + for (int i = 0; i < items.length; i++) { Ingredient in = Ingredient.fromItems(items[i]); ItemStack out = new ItemStack(i == items.length - 1 ? items[0] : items[i + 1]); String id = String.format("%s_to_%s", items[i].asItem().getRegistryName().getPath(), out.getItem().getRegistryName().getPath()); consumer.accept(RecipeManaInfusion.alchemy(new ResourceLocation(LibMisc.MOD_ID, id), out, in, cost, group)); } } - + private static RecipeManaInfusion mini(IItemProvider mini, IItemProvider full) { return RecipeManaInfusion.alchemy(mini.asItem().getRegistryName(), new ItemStack(mini), Ingredient.fromItems(full), 2500); } diff --git a/src/main/java/vazkii/botania/common/crafting/ModManaConjurationRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModManaConjurationRecipes.java index b74f2d413..66e18cff1 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModManaConjurationRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModManaConjurationRecipes.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 20, 2014, 3:57:02 PM (GMT)] */ package vazkii.botania.common.crafting; @@ -17,6 +15,7 @@ import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.IItemProvider; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.api.recipe.RecipeManaInfusion; import vazkii.botania.api.recipe.RegisterRecipesEvent; import vazkii.botania.common.lib.LibMisc; @@ -41,23 +40,23 @@ public class ModManaConjurationRecipes { @SubscribeEvent public static void register(RegisterRecipesEvent evt) { - evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("redstone_dupe"), new ItemStack(Items.REDSTONE, 2), ingr(Items.REDSTONE), 5000)); - evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("glowstone_dupe"), new ItemStack(Items.GLOWSTONE_DUST, 2), ingr(Items.GLOWSTONE_DUST), 5000)); - evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("quartz_dupe"), new ItemStack(Items.QUARTZ, 2), ingr(Items.QUARTZ), 2500)); - evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("coal_dupe"), new ItemStack(Items.COAL, 2), ingr(Items.COAL), 2100)); - evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("snowball_dupe"), new ItemStack(Items.SNOWBALL, 2), ingr(Items.SNOWBALL), 200)); - evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("netherrack_dupe"), new ItemStack(Blocks.NETHERRACK, 2), ingr(Blocks.NETHERRACK), 200)); - evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("soul_sand_dupe"), new ItemStack(Blocks.SOUL_SAND, 2), ingr(Blocks.SOUL_SAND), 1500)); - evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("gravel_dupe"), new ItemStack(Blocks.GRAVEL, 2), ingr(Blocks.GRAVEL), 720)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("redstone_dupe"), new ItemStack(Items.REDSTONE, 2), ingr(Items.REDSTONE), 5000)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("glowstone_dupe"), new ItemStack(Items.GLOWSTONE_DUST, 2), ingr(Items.GLOWSTONE_DUST), 5000)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("quartz_dupe"), new ItemStack(Items.QUARTZ, 2), ingr(Items.QUARTZ), 2500)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("coal_dupe"), new ItemStack(Items.COAL, 2), ingr(Items.COAL), 2100)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("snowball_dupe"), new ItemStack(Items.SNOWBALL, 2), ingr(Items.SNOWBALL), 200)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("netherrack_dupe"), new ItemStack(Blocks.NETHERRACK, 2), ingr(Blocks.NETHERRACK), 200)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("soul_sand_dupe"), new ItemStack(Blocks.SOUL_SAND, 2), ingr(Blocks.SOUL_SAND), 1500)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("gravel_dupe"), new ItemStack(Blocks.GRAVEL, 2), ingr(Blocks.GRAVEL), 720)); - evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("oak_leaves_dupe"), new ItemStack(Blocks.OAK_LEAVES, 2), ingr(Blocks.OAK_LEAVES), 2000)); - evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("birch_leaves_dupe"), new ItemStack(Blocks.BIRCH_LEAVES, 2), ingr(Blocks.BIRCH_LEAVES), 2000)); - evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("spruce_leaves_dupe"), new ItemStack(Blocks.SPRUCE_LEAVES, 2), ingr(Blocks.SPRUCE_LEAVES), 2000)); - evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("jungle_leaves_dupe"), new ItemStack(Blocks.JUNGLE_LEAVES, 2), ingr(Blocks.JUNGLE_LEAVES), 2000)); - evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("acacia_leaves_dupe"), new ItemStack(Blocks.ACACIA_LEAVES, 2), ingr(Blocks.ACACIA_LEAVES), 2000)); - evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("dark_oak_leaves_dupe"), new ItemStack(Blocks.DARK_OAK_LEAVES, 2), ingr(Blocks.DARK_OAK_LEAVES), 2000)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("oak_leaves_dupe"), new ItemStack(Blocks.OAK_LEAVES, 2), ingr(Blocks.OAK_LEAVES), 2000)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("birch_leaves_dupe"), new ItemStack(Blocks.BIRCH_LEAVES, 2), ingr(Blocks.BIRCH_LEAVES), 2000)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("spruce_leaves_dupe"), new ItemStack(Blocks.SPRUCE_LEAVES, 2), ingr(Blocks.SPRUCE_LEAVES), 2000)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("jungle_leaves_dupe"), new ItemStack(Blocks.JUNGLE_LEAVES, 2), ingr(Blocks.JUNGLE_LEAVES), 2000)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("acacia_leaves_dupe"), new ItemStack(Blocks.ACACIA_LEAVES, 2), ingr(Blocks.ACACIA_LEAVES), 2000)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("dark_oak_leaves_dupe"), new ItemStack(Blocks.DARK_OAK_LEAVES, 2), ingr(Blocks.DARK_OAK_LEAVES), 2000)); - evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("grass"), new ItemStack(Blocks.GRASS, 2), ingr(Blocks.GRASS), 800)); + evt.manaInfusion().accept(RecipeManaInfusion.conjuration(prefix("grass"), new ItemStack(Blocks.GRASS, 2), ingr(Blocks.GRASS), 800)); } private static Ingredient ingr(IItemProvider i) { diff --git a/src/main/java/vazkii/botania/common/crafting/ModManaInfusionRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModManaInfusionRecipes.java index 70bf1516a..52ff5e8bb 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModManaInfusionRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModManaInfusionRecipes.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 30, 2014, 6:10:48 PM (GMT)] */ package vazkii.botania.common.crafting; @@ -21,6 +19,7 @@ import net.minecraftforge.common.Tags; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.registries.ForgeRegistries; + import vazkii.botania.api.recipe.RecipeManaInfusion; import vazkii.botania.api.recipe.RegisterRecipesEvent; import vazkii.botania.common.Botania; @@ -60,7 +59,7 @@ public final class ModManaInfusionRecipes { evt.manaInfusion().accept(new RecipeManaInfusion(prefix("mana_quartz"), new ItemStack(ModItems.manaQuartz), Ingredient.fromItems(Items.QUARTZ), 250)); evt.manaInfusion().accept(new RecipeManaInfusion(prefix("tiny_potato"), new ItemStack(ModBlocks.tinyPotato), Ingredient.fromItems(Items.POTATO), 1337)); - if(Botania.thaumcraftLoaded) { + if (Botania.thaumcraftLoaded) { Item inkwell = ForgeRegistries.ITEMS.getValue(new ResourceLocation("thaumcraft", "scribing_tools")); evt.manaInfusion().accept(new RecipeManaInfusion(prefix("mana_inkwell"), new ItemStack(ModItems.manaInkwell), Ingredient.fromItems(inkwell), 35000)); } @@ -68,8 +67,9 @@ public final class ModManaInfusionRecipes { evt.manaInfusion().accept(new RecipeManaInfusion(prefix("mana_glass"), new ItemStack(ModBlocks.manaGlass), Ingredient.fromItems(Blocks.GLASS), 150)); evt.manaInfusion().accept(new RecipeManaInfusion(prefix("mana_string"), new ItemStack(ModItems.manaString), Ingredient.fromItems(Items.STRING), 5000)); - if(Botania.gardenOfGlassLoaded) + if (Botania.gardenOfGlassLoaded) { evt.manaInfusion().accept(new RecipeManaInfusion(prefix("sugar_cane"), new ItemStack(Blocks.SUGAR_CANE), Ingredient.fromItems(Blocks.HAY_BLOCK), 2000)); + } evt.manaInfusion().accept(new RecipeManaInfusion(prefix("mana_bottle"), new ItemStack(ModItems.manaBottle), Ingredient.fromItems(Items.GLASS_BOTTLE), 5000)); } diff --git a/src/main/java/vazkii/botania/common/crafting/ModPetalRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModPetalRecipes.java index 96d4b4f30..56aeeade7 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModPetalRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModPetalRecipes.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 22], 2014], 2:22:21 PM (GMT)] */ package vazkii.botania.common.crafting; @@ -18,6 +16,7 @@ import net.minecraft.util.IItemProvider; import net.minecraft.util.ResourceLocation; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.api.recipe.RecipePetals; import vazkii.botania.api.recipe.RegisterRecipesEvent; import vazkii.botania.common.Botania; @@ -81,7 +80,7 @@ public final class ModPetalRecipes { evt.apothecary().accept(make(ModSubtiles.rosaArcana, pink, pink, purple, purple, lime, runeMana)); evt.apothecary().accept(make(ModSubtiles.munchdew, lime, lime, red, red, green, runeGluttony)); evt.apothecary().accept(make(ModSubtiles.entropinnyum, red, red, gray, gray, white, white, runeWrath, runeFire)); - evt.apothecary().accept(make(ModSubtiles.kekimurus, white, white, orange, orange, brown, brown,runeGluttony, pixieDust)); + evt.apothecary().accept(make(ModSubtiles.kekimurus, white, white, orange, orange, brown, brown, runeGluttony, pixieDust)); evt.apothecary().accept(make(ModSubtiles.gourmaryllis, lightGray, lightGray, yellow, yellow, red, runeFire, runeSummer)); evt.apothecary().accept(make(ModSubtiles.narslimmus, lime, lime, green, green, black, runeSummer, runeWater)); evt.apothecary().accept(make(ModSubtiles.spectrolus, red, red, green, green, blue, blue, white, white, runeWinter, runeAir, pixieDust)); @@ -95,13 +94,16 @@ public final class ModPetalRecipes { evt.apothecary().accept(make(ModSubtiles.heiseiDream, magenta, magenta, purple, pink, runeWrath, pixieDust)); evt.apothecary().accept(make(ModSubtiles.tigerseye, yellow, brown, orange, lime, runeAutumn)); - if(Botania.gardenOfGlassLoaded) + if (Botania.gardenOfGlassLoaded) { evt.apothecary().accept(make(ModSubtiles.orechid, gray, gray, yellow, yellow, green, green, red, red)); - else evt.apothecary().accept(make(ModSubtiles.orechid, gray, gray, yellow, green, red, runePride, runeGreed, redstoneRoot, pixieDust)); + } else { + evt.apothecary().accept(make(ModSubtiles.orechid, gray, gray, yellow, green, red, runePride, runeGreed, redstoneRoot, pixieDust)); + } evt.apothecary().accept(make(ModSubtiles.orechidIgnem, red, red, white, white, pink, runePride, runeGreed, redstoneRoot, pixieDust)); - if(ConfigHandler.COMMON.fallenKanadeEnabled.get()) + if (ConfigHandler.COMMON.fallenKanadeEnabled.get()) { evt.apothecary().accept(make(ModSubtiles.fallenKanade, white, white, yellow, yellow, orange, runeSpring)); + } evt.apothecary().accept(make(ModSubtiles.exoflame, red, red, gray, lightGray, runeFire, runeSummer)); evt.apothecary().accept(make(ModSubtiles.agricarnation, lime, lime, green, yellow, runeSpring, redstoneRoot)); evt.apothecary().accept(make(ModSubtiles.hopperhock, gray, gray, lightGray, lightGray, runeAir, redstoneRoot)); diff --git a/src/main/java/vazkii/botania/common/crafting/ModPureDaisyRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModPureDaisyRecipes.java index 3273ec50f..7ba881b8e 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModPureDaisyRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModPureDaisyRecipes.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 17, 2015, 5:18:06 PM (GMT)] */ package vazkii.botania.common.crafting; @@ -15,6 +13,7 @@ import net.minecraft.tags.BlockTags; import net.minecraftforge.common.Tags; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.api.recipe.RecipePureDaisy; import vazkii.botania.api.recipe.RegisterRecipesEvent; import vazkii.botania.common.block.ModBlocks; diff --git a/src/main/java/vazkii/botania/common/crafting/ModRuneRecipes.java b/src/main/java/vazkii/botania/common/crafting/ModRuneRecipes.java index 25fbf754e..0378c73b2 100644 --- a/src/main/java/vazkii/botania/common/crafting/ModRuneRecipes.java +++ b/src/main/java/vazkii/botania/common/crafting/ModRuneRecipes.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 6, 2014, 5:59:28 PM (GMT)] */ package vazkii.botania.common.crafting; @@ -18,6 +16,7 @@ import net.minecraft.tags.ItemTags; import net.minecraftforge.common.Tags; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.api.recipe.RecipeRuneAltar; import vazkii.botania.api.recipe.RegisterRecipesEvent; import vazkii.botania.common.crafting.recipe.HeadRecipe; @@ -48,7 +47,7 @@ public final class ModRuneRecipes { evt.runeAltar().accept(new RecipeRuneAltar(prefix("earth"), new ItemStack(ModItems.runeEarth, 2), costTier1, manaPowder, manaSteel, stone, coalBlock, Ingredient.fromItems(Blocks.BROWN_MUSHROOM, Blocks.RED_MUSHROOM))); evt.runeAltar().accept(new RecipeRuneAltar(prefix("air"), new ItemStack(ModItems.runeAir, 2), costTier1, manaPowder, manaSteel, Ingredient.fromTag(ItemTags.CARPETS), Ingredient.fromItems(Items.FEATHER), Ingredient.fromItems(Items.STRING))); - + Ingredient fire = Ingredient.fromTag(ModTags.Items.RUNES_FIRE); Ingredient water = Ingredient.fromTag(ModTags.Items.RUNES_WATER); Ingredient earth = Ingredient.fromTag(ModTags.Items.RUNES_EARTH); @@ -67,7 +66,7 @@ public final class ModRuneRecipes { Ingredient summer = Ingredient.fromTag(ModTags.Items.RUNES_SUMMER); Ingredient autumn = Ingredient.fromTag(ModTags.Items.RUNES_AUTUMN); Ingredient winter = Ingredient.fromTag(ModTags.Items.RUNES_WINTER); - + evt.runeAltar().accept(new RecipeRuneAltar(prefix("mana"), new ItemStack(ModItems.runeMana), costTier2, manaSteel, manaSteel, manaSteel, manaSteel, manaSteel, Ingredient.fromItems(ModItems.manaPearl))); evt.runeAltar().accept(new RecipeRuneAltar(prefix("lust"), new ItemStack(ModItems.runeLust), costTier3, manaDiamond, manaDiamond, summer, air)); diff --git a/src/main/java/vazkii/botania/common/crafting/SyncHandler.java b/src/main/java/vazkii/botania/common/crafting/SyncHandler.java index 949fde704..de23c4f71 100644 --- a/src/main/java/vazkii/botania/common/crafting/SyncHandler.java +++ b/src/main/java/vazkii/botania/common/crafting/SyncHandler.java @@ -1,17 +1,25 @@ +/* + * This class is 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 + */ package vazkii.botania.common.crafting; import com.google.common.collect.ImmutableMap; -import net.minecraft.entity.player.ServerPlayerEntity; + import net.minecraft.resources.IResourceManager; import net.minecraft.resources.IResourceManagerReloadListener; import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.ClientPlayerNetworkEvent; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.network.PacketDistributor; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipeBrew; import vazkii.botania.api.recipe.RecipeElvenTrade; @@ -25,57 +33,58 @@ import vazkii.botania.common.network.PacketHandler; import vazkii.botania.common.network.PacketSyncRecipes; import javax.annotation.Nullable; + import java.util.Collections; import java.util.HashMap; import java.util.Map; public class SyncHandler { - public static class ReloadListener implements IResourceManagerReloadListener { - @Override - public void onResourceManagerReload(@Nullable IResourceManager manager) { - Map pureDaisy = new HashMap<>(); - Map manaInfusion = new HashMap<>(); - Map brew = new HashMap<>(); - Map elvenTrade = new HashMap<>(); - Map apothecary = new HashMap<>(); - Map runeAltar = new HashMap<>(); + public static class ReloadListener implements IResourceManagerReloadListener { + @Override + public void onResourceManagerReload(@Nullable IResourceManager manager) { + Map pureDaisy = new HashMap<>(); + Map manaInfusion = new HashMap<>(); + Map brew = new HashMap<>(); + Map elvenTrade = new HashMap<>(); + Map apothecary = new HashMap<>(); + Map runeAltar = new HashMap<>(); - RegisterRecipesEvent evt = new RegisterRecipesEvent( - r -> pureDaisy.put(r.getId(), r), - r -> manaInfusion.put(r.getId(), r), - r -> brew.put(r.getId(), r), - r -> elvenTrade.put(r.getId(), r), - r -> apothecary.put(r.getId(), r), - r -> runeAltar.put(r.getId(), r) - ); - MinecraftForge.EVENT_BUS.post(evt); + RegisterRecipesEvent evt = new RegisterRecipesEvent( + r -> pureDaisy.put(r.getId(), r), + r -> manaInfusion.put(r.getId(), r), + r -> brew.put(r.getId(), r), + r -> elvenTrade.put(r.getId(), r), + r -> apothecary.put(r.getId(), r), + r -> runeAltar.put(r.getId(), r) + ); + MinecraftForge.EVENT_BUS.post(evt); - BotaniaAPI.pureDaisyRecipes = ImmutableMap.copyOf(pureDaisy); - BotaniaAPI.manaInfusionRecipes = ImmutableMap.copyOf(manaInfusion); - BotaniaAPI.brewRecipes = ImmutableMap.copyOf(brew); - BotaniaAPI.elvenTradeRecipes = ImmutableMap.copyOf(elvenTrade); - BotaniaAPI.petalRecipes = ImmutableMap.copyOf(apothecary); - BotaniaAPI.runeAltarRecipes = ImmutableMap.copyOf(runeAltar); - PacketHandler.HANDLER.send(PacketDistributor.ALL.noArg(), syncPacket()); - } - } + BotaniaAPI.pureDaisyRecipes = ImmutableMap.copyOf(pureDaisy); + BotaniaAPI.manaInfusionRecipes = ImmutableMap.copyOf(manaInfusion); + BotaniaAPI.brewRecipes = ImmutableMap.copyOf(brew); + BotaniaAPI.elvenTradeRecipes = ImmutableMap.copyOf(elvenTrade); + BotaniaAPI.petalRecipes = ImmutableMap.copyOf(apothecary); + BotaniaAPI.runeAltarRecipes = ImmutableMap.copyOf(runeAltar); + PacketHandler.HANDLER.send(PacketDistributor.ALL.noArg(), syncPacket()); + } + } - private static PacketSyncRecipes syncPacket() { - return new PacketSyncRecipes(BotaniaAPI.brewRecipes, BotaniaAPI.elvenTradeRecipes, BotaniaAPI.manaInfusionRecipes, - BotaniaAPI.petalRecipes, BotaniaAPI.pureDaisyRecipes, BotaniaAPI.runeAltarRecipes); - } + private static PacketSyncRecipes syncPacket() { + return new PacketSyncRecipes(BotaniaAPI.brewRecipes, BotaniaAPI.elvenTradeRecipes, BotaniaAPI.manaInfusionRecipes, + BotaniaAPI.petalRecipes, BotaniaAPI.pureDaisyRecipes, BotaniaAPI.runeAltarRecipes); + } - @Mod.EventBusSubscriber(modid = LibMisc.MOD_ID, value = Dist.CLIENT) - public static class ClientEvents { - @SubscribeEvent - public static void clientLogout(ClientPlayerNetworkEvent.LoggedOutEvent evt) { - BotaniaAPI.brewRecipes = Collections.emptyMap(); - BotaniaAPI.elvenTradeRecipes = Collections.emptyMap(); - BotaniaAPI.manaInfusionRecipes = Collections.emptyMap(); - BotaniaAPI.petalRecipes = Collections.emptyMap(); - BotaniaAPI.pureDaisyRecipes = Collections.emptyMap(); - BotaniaAPI.runeAltarRecipes = Collections.emptyMap(); - } - } + @Mod.EventBusSubscriber(modid = LibMisc.MOD_ID, value = Dist.CLIENT) + public static class ClientEvents { + @SubscribeEvent + public static void clientLogout(ClientPlayerNetworkEvent.LoggedOutEvent evt) { + BotaniaAPI.brewRecipes = Collections.emptyMap(); + BotaniaAPI.elvenTradeRecipes = Collections.emptyMap(); + BotaniaAPI.manaInfusionRecipes = Collections.emptyMap(); + BotaniaAPI.petalRecipes = Collections.emptyMap(); + BotaniaAPI.pureDaisyRecipes = Collections.emptyMap(); + BotaniaAPI.runeAltarRecipes = Collections.emptyMap(); + } + } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/AncientWillRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/AncientWillRecipe.java index d4fea50e8..5d14fc998 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/AncientWillRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/AncientWillRecipe.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 30, 2015, 11:24:08 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -17,6 +15,7 @@ import net.minecraft.item.crafting.SpecialRecipe; import net.minecraft.item.crafting.SpecialRecipeSerializer; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + import vazkii.botania.api.item.IAncientWillContainer; import vazkii.botania.common.item.ItemAncientWill; @@ -34,15 +33,17 @@ public class AncientWillRecipe extends SpecialRecipe { boolean foundWill = false; boolean foundItem = false; - for(int i = 0; i < inv.getSizeInventory(); i++) { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(!stack.isEmpty()) { - if(stack.getItem() instanceof ItemAncientWill && !foundWill) + if (!stack.isEmpty()) { + if (stack.getItem() instanceof ItemAncientWill && !foundWill) { foundWill = true; - else if(!foundItem) { - if(stack.getItem() instanceof IAncientWillContainer) + } else if (!foundItem) { + if (stack.getItem() instanceof IAncientWillContainer) { foundItem = true; - else return false; + } else { + return false; + } } } } @@ -56,18 +57,21 @@ public class AncientWillRecipe extends SpecialRecipe { ItemStack item = ItemStack.EMPTY; IAncientWillContainer.AncientWillType will = null; - for(int i = 0; i < inv.getSizeInventory(); i++) { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(!stack.isEmpty()) { - if(stack.getItem() instanceof IAncientWillContainer && item.isEmpty()) + if (!stack.isEmpty()) { + if (stack.getItem() instanceof IAncientWillContainer && item.isEmpty()) { item = stack; - else will = ((ItemAncientWill) stack.getItem()).type; // we already verified this is a will in matches() + } else { + will = ((ItemAncientWill) stack.getItem()).type; // we already verified this is a will in matches() + } } } IAncientWillContainer container = (IAncientWillContainer) item.getItem(); - if(container.hasAncientWill(item, will)) + if (container.hasAncientWill(item, will)) { return ItemStack.EMPTY; + } ItemStack copy = item.copy(); container.addAncientWill(copy, will); diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/ArmorUpgradeRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/ArmorUpgradeRecipe.java index d1c9335f3..b63def0b2 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/ArmorUpgradeRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/ArmorUpgradeRecipe.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 4, 2016, 7:49:08 PM (EST)] */ package vazkii.botania.common.crafting.recipe; import com.google.gson.JsonObject; + import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.inventory.CraftingInventory; import net.minecraft.item.ArmorItem; @@ -24,6 +23,7 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.registries.ForgeRegistryEntry; + import vazkii.botania.common.Botania; import javax.annotation.Nonnull; @@ -48,8 +48,9 @@ public class ArmorUpgradeRecipe implements ICraftingRecipe { ItemStack stack = inv.getStackInSlot(i); if (!stack.isEmpty() && stack.getItem() instanceof ArmorItem && stack.hasTag()) { EnchantmentHelper.setEnchantments(EnchantmentHelper.getEnchantments(stack), out); - if(Botania.thaumcraftLoaded) + if (Botania.thaumcraftLoaded) { HelmRevealingRecipe.copyTCData(stack, out); + } break; } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/BannerRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/BannerRecipe.java index a9f132150..adedf99e7 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/BannerRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/BannerRecipe.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [2020-01-30, 19:13 (UTC+2)] */ package vazkii.botania.common.crafting.recipe; @@ -25,6 +23,7 @@ import net.minecraft.tileentity.BannerPattern; import net.minecraft.tileentity.BannerTileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + import vazkii.botania.common.block.ModBanners; import javax.annotation.Nonnull; @@ -45,8 +44,9 @@ public class BannerRecipe extends SpecialRecipe { for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); Item item = stack.getItem(); - if (stack.isEmpty()) + if (stack.isEmpty()) { continue; + } if (ModBanners.PATTERNS.containsKey(item.delegate) && !foundItem) { foundItem = true; @@ -54,7 +54,9 @@ public class BannerRecipe extends SpecialRecipe { foundBanner = true; } else if (item instanceof DyeItem && !foundDye) { foundDye = true; - } else return false; + } else { + return false; + } } return foundBanner && foundItem && foundDye; } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/BlackHoleTalismanExtractRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/BlackHoleTalismanExtractRecipe.java index cac5f944d..3673e366f 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/BlackHoleTalismanExtractRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/BlackHoleTalismanExtractRecipe.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 9, 2015, 7:48:00 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -18,6 +16,7 @@ import net.minecraft.item.crafting.SpecialRecipe; import net.minecraft.item.crafting.SpecialRecipeSerializer; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + import vazkii.botania.common.item.ItemBlackHoleTalisman; import vazkii.botania.common.item.ModItems; @@ -34,12 +33,14 @@ public class BlackHoleTalismanExtractRecipe extends SpecialRecipe { public boolean matches(@Nonnull CraftingInventory inv, @Nonnull World world) { boolean foundTalisman = false; - for(int i = 0; i < inv.getSizeInventory(); i++) { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(!stack.isEmpty()) { - if(stack.getItem() == ModItems.blackHoleTalisman && !foundTalisman) + if (!stack.isEmpty()) { + if (stack.getItem() == ModItems.blackHoleTalisman && !foundTalisman) { foundTalisman = true; - else return false; + } else { + return false; + } } } @@ -51,16 +52,17 @@ public class BlackHoleTalismanExtractRecipe extends SpecialRecipe { public ItemStack getCraftingResult(@Nonnull CraftingInventory inv) { ItemStack talisman = ItemStack.EMPTY; - for(int i = 0; i < inv.getSizeInventory(); i++) { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(!stack.isEmpty()) + if (!stack.isEmpty()) { talisman = stack; + } } int count = ItemBlackHoleTalisman.getBlockCount(talisman); - if(count > 0) { + if (count > 0) { Block block = ItemBlackHoleTalisman.getBlock(talisman); - if(block != null) { + if (block != null) { return new ItemStack(block, Math.min(64, count)); } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/CompositeLensRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/CompositeLensRecipe.java index 078c473d3..b863f39b2 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/CompositeLensRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/CompositeLensRecipe.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 17, 2014, 8:30:41 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -18,6 +16,7 @@ import net.minecraft.item.crafting.SpecialRecipe; import net.minecraft.item.crafting.SpecialRecipeSerializer; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + import vazkii.botania.api.mana.ICompositableLens; import javax.annotation.Nonnull; @@ -35,16 +34,20 @@ public class CompositeLensRecipe extends SpecialRecipe { boolean foundSecondLens = false; boolean foundSlimeball = false; - for(int i = 0; i < inv.getSizeInventory(); i++) { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(!stack.isEmpty()) { - if(stack.getItem() instanceof ICompositableLens && !foundSecondLens) { - if(foundLens) + if (!stack.isEmpty()) { + if (stack.getItem() instanceof ICompositableLens && !foundSecondLens) { + if (foundLens) { foundSecondLens = true; - else foundLens = true; - } else if(stack.getItem() == Items.SLIME_BALL) + } else { + foundLens = true; + } + } else if (stack.getItem() == Items.SLIME_BALL) { foundSlimeball = true; - else return false; // Found an invalid item, breaking the recipe + } else { + return false; // Found an invalid item, breaking the recipe + } } } @@ -57,20 +60,24 @@ public class CompositeLensRecipe extends SpecialRecipe { ItemStack lens = ItemStack.EMPTY; ItemStack secondLens = ItemStack.EMPTY; - for(int i = 0; i < inv.getSizeInventory(); i++) { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(!stack.isEmpty()) { - if(stack.getItem() instanceof ICompositableLens) - if(lens.isEmpty()) + if (!stack.isEmpty()) { + if (stack.getItem() instanceof ICompositableLens) { + if (lens.isEmpty()) { lens = stack; - else secondLens = stack; + } else { + secondLens = stack; + } + } } } - if(lens.getItem() instanceof ICompositableLens) { + if (lens.getItem() instanceof ICompositableLens) { ICompositableLens lensItem = (ICompositableLens) lens.getItem(); - if(secondLens.isEmpty() || !lensItem.canCombineLenses(lens, secondLens) || !lensItem.getCompositeLens(lens).isEmpty() || !lensItem.getCompositeLens(secondLens).isEmpty()) + if (secondLens.isEmpty() || !lensItem.canCombineLenses(lens, secondLens) || !lensItem.getCompositeLens(lens).isEmpty() || !lensItem.getCompositeLens(secondLens).isEmpty()) { return ItemStack.EMPTY; + } ItemStack lensCopy = lens.copy(); lensItem.setCompositeLens(lensCopy, secondLens); @@ -91,4 +98,4 @@ public class CompositeLensRecipe extends SpecialRecipe { public IRecipeSerializer getSerializer() { return SERIALIZER; } -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticAttachRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticAttachRecipe.java index d8ce98bf8..a41863824 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticAttachRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticAttachRecipe.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 22, 2015, 8:49:53 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -17,6 +15,7 @@ import net.minecraft.item.crafting.SpecialRecipe; import net.minecraft.item.crafting.SpecialRecipeSerializer; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + import vazkii.botania.api.item.ICosmeticAttachable; import vazkii.botania.api.item.ICosmeticBauble; @@ -34,15 +33,17 @@ public class CosmeticAttachRecipe extends SpecialRecipe { boolean foundCosmetic = false; boolean foundAttachable = false; - for(int i = 0; i < inv.getSizeInventory(); i++) { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(!stack.isEmpty()) { - if(stack.getItem() instanceof ICosmeticBauble && !foundCosmetic) + if (!stack.isEmpty()) { + if (stack.getItem() instanceof ICosmeticBauble && !foundCosmetic) { foundCosmetic = true; - else if(!foundAttachable) { - if(stack.getItem() instanceof ICosmeticAttachable && !(stack.getItem() instanceof ICosmeticBauble) && ((ICosmeticAttachable) stack.getItem()).getCosmeticItem(stack).isEmpty()) + } else if (!foundAttachable) { + if (stack.getItem() instanceof ICosmeticAttachable && !(stack.getItem() instanceof ICosmeticBauble) && ((ICosmeticAttachable) stack.getItem()).getCosmeticItem(stack).isEmpty()) { foundAttachable = true; - else return false; + } else { + return false; + } } } } @@ -56,21 +57,25 @@ public class CosmeticAttachRecipe extends SpecialRecipe { ItemStack cosmeticItem = ItemStack.EMPTY; ItemStack attachableItem = ItemStack.EMPTY; - for(int i = 0; i < inv.getSizeInventory(); i++) { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(!stack.isEmpty()) { - if(stack.getItem() instanceof ICosmeticBauble && cosmeticItem.isEmpty()) + if (!stack.isEmpty()) { + if (stack.getItem() instanceof ICosmeticBauble && cosmeticItem.isEmpty()) { cosmeticItem = stack; - else attachableItem = stack; + } else { + attachableItem = stack; + } } } - if(!(attachableItem.getItem() instanceof ICosmeticAttachable)) + if (!(attachableItem.getItem() instanceof ICosmeticAttachable)) { return ItemStack.EMPTY; - + } + ICosmeticAttachable attachable = (ICosmeticAttachable) attachableItem.getItem(); - if(!attachable.getCosmeticItem(attachableItem).isEmpty()) + if (!attachable.getCosmeticItem(attachableItem).isEmpty()) { return ItemStack.EMPTY; + } ItemStack copy = attachableItem.copy(); attachable.setCosmeticItem(copy, cosmeticItem); diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticRemoveRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticRemoveRecipe.java index ac336b704..3c778d356 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticRemoveRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/CosmeticRemoveRecipe.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 22, 2015, 8:55:03 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -17,6 +15,7 @@ import net.minecraft.item.crafting.SpecialRecipe; import net.minecraft.item.crafting.SpecialRecipeSerializer; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + import vazkii.botania.api.item.ICosmeticAttachable; import vazkii.botania.api.item.ICosmeticBauble; @@ -33,12 +32,14 @@ public class CosmeticRemoveRecipe extends SpecialRecipe { public boolean matches(@Nonnull CraftingInventory inv, @Nonnull World world) { boolean foundAttachable = false; - for(int i = 0; i < inv.getSizeInventory(); i++) { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(!stack.isEmpty()) { - if(stack.getItem() instanceof ICosmeticAttachable && !(stack.getItem() instanceof ICosmeticBauble) && !((ICosmeticAttachable) stack.getItem()).getCosmeticItem(stack).isEmpty()) + if (!stack.isEmpty()) { + if (stack.getItem() instanceof ICosmeticAttachable && !(stack.getItem() instanceof ICosmeticBauble) && !((ICosmeticAttachable) stack.getItem()).getCosmeticItem(stack).isEmpty()) { foundAttachable = true; - else return false; + } else { + return false; + } } } @@ -50,15 +51,17 @@ public class CosmeticRemoveRecipe extends SpecialRecipe { public ItemStack getCraftingResult(@Nonnull CraftingInventory inv) { ItemStack attachableItem = ItemStack.EMPTY; - for(int i = 0; i < inv.getSizeInventory(); i++) { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(!stack.isEmpty()) + if (!stack.isEmpty()) { attachableItem = stack; + } } ICosmeticAttachable attachable = (ICosmeticAttachable) attachableItem.getItem(); - if(attachable.getCosmeticItem(attachableItem).isEmpty()) + if (attachable.getCosmeticItem(attachableItem).isEmpty()) { return ItemStack.EMPTY; + } ItemStack copy = attachableItem.copy(); attachable.setCosmeticItem(copy, ItemStack.EMPTY); diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/HeadRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/HeadRecipe.java index d48a0e1df..a43f1ecc8 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/HeadRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/HeadRecipe.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 23, 2014, 3:02:17 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -16,6 +14,7 @@ import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.TranslationTextComponent; import net.minecraftforge.items.IItemHandler; + import vazkii.botania.api.recipe.RecipeRuneAltar; import vazkii.botania.common.core.helper.ItemNBTHelper; @@ -31,17 +30,19 @@ public class HeadRecipe extends RecipeRuneAltar { public boolean matches(IItemHandler inv) { boolean matches = super.matches(inv); - if(matches) { - for(int i = 0; i < inv.getSlots(); i++) { + if (matches) { + for (int i = 0; i < inv.getSlots(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(stack.isEmpty()) + if (stack.isEmpty()) { break; + } - if(stack.getItem() == Items.NAME_TAG) { + if (stack.getItem() == Items.NAME_TAG) { String defaultName = new TranslationTextComponent(Items.NAME_TAG.getTranslationKey()).getString(); name = stack.getDisplayName().getString(); - if(name.equals(defaultName)) + if (name.equals(defaultName)) { return false; + } } } } @@ -52,8 +53,9 @@ public class HeadRecipe extends RecipeRuneAltar { @Override public ItemStack getOutput() { ItemStack stack = new ItemStack(Items.PLAYER_HEAD); - if(!name.isEmpty()) + if (!name.isEmpty()) { ItemNBTHelper.setString(stack, "SkullOwner", name); + } return stack; } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/HelmRevealingRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/HelmRevealingRecipe.java index 060a88628..1f1feaea5 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/HelmRevealingRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/HelmRevealingRecipe.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 6, 2015, 9:45:56 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; import com.google.gson.JsonObject; + import net.minecraft.inventory.CraftingInventory; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.ICraftingRecipe; @@ -23,6 +22,7 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.registries.ForgeRegistryEntry; + import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.lib.LibMisc; @@ -45,26 +45,31 @@ public class HelmRevealingRecipe implements ICraftingRecipe { public ItemStack getCraftingResult(@Nonnull CraftingInventory inv) { ItemStack helm = ItemStack.EMPTY; - for(int i = 0; i < inv.getSizeInventory(); i++) { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(!stack.isEmpty() && stack.getItem().getRegistryName().getNamespace().equals(LibMisc.MOD_ID)) + if (!stack.isEmpty() && stack.getItem().getRegistryName().getNamespace().equals(LibMisc.MOD_ID)) { helm = stack; + } } - if(helm.isEmpty()) + if (helm.isEmpty()) { return ItemStack.EMPTY; + } ItemStack newHelm = compose.getCraftingResult(inv); //Copy Ancient Wills - for(int i = 0; i < 6; i++) - if(ItemNBTHelper.getBoolean(helm, "AncientWill" + i, false)) + for (int i = 0; i < 6; i++) { + if (ItemNBTHelper.getBoolean(helm, "AncientWill" + i, false)) { ItemNBTHelper.setBoolean(newHelm, "AncientWill" + i, true); + } + } //Copy Enchantments ListNBT enchList = ItemNBTHelper.getList(helm, "ench", 10, true); - if(enchList != null) + if (enchList != null) { ItemNBTHelper.setList(newHelm, "ench", enchList); + } copyTCData(helm, newHelm); return newHelm; @@ -114,16 +119,19 @@ public class HelmRevealingRecipe implements ICraftingRecipe { */ public static void copyTCData(ItemStack source, ItemStack destination) { byte runicShielding = ItemNBTHelper.getByte(source, TAG_RUNIC, (byte) 0); - if(runicShielding != 0) + if (runicShielding != 0) { ItemNBTHelper.setByte(destination, TAG_RUNIC, runicShielding); + } byte warp = ItemNBTHelper.getByte(source, TAG_WARP, (byte) 0); - if(warp != 0) + if (warp != 0) { ItemNBTHelper.setByte(destination, TAG_WARP, warp); + } ListNBT infEnchList = ItemNBTHelper.getList(source, TAG_INFUSION_ENCH, 10, true); - if(infEnchList != null) + if (infEnchList != null) { ItemNBTHelper.setList(destination, TAG_INFUSION_ENCH, infEnchList); + } } public static final IRecipeSerializer SERIALIZER = new Serializer(); diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/KeepIvyRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/KeepIvyRecipe.java index e26e6adaf..8bddb7c57 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/KeepIvyRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/KeepIvyRecipe.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 31, 2015, 9:23:22 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -17,6 +15,7 @@ import net.minecraft.item.crafting.SpecialRecipe; import net.minecraft.item.crafting.SpecialRecipeSerializer; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.item.ItemKeepIvy; import vazkii.botania.common.item.ModItems; @@ -35,16 +34,18 @@ public class KeepIvyRecipe extends SpecialRecipe { boolean foundIvy = false; boolean foundItem = false; - for(int i = 0; i < inv.getSizeInventory(); i++) { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(!stack.isEmpty()) { - if(stack.getItem() == ModItems.keepIvy) + if (!stack.isEmpty()) { + if (stack.getItem() == ModItems.keepIvy) { foundIvy = true; - else if(!foundItem + } else if (!foundItem && !(stack.hasTag() && ItemNBTHelper.getBoolean(stack, ItemKeepIvy.TAG_KEEP, false)) - && !stack.getItem().hasContainerItem(stack)) + && !stack.getItem().hasContainerItem(stack)) { foundItem = true; - else return false; + } else { + return false; + } } } @@ -56,10 +57,11 @@ public class KeepIvyRecipe extends SpecialRecipe { public ItemStack getCraftingResult(@Nonnull CraftingInventory inv) { ItemStack item = ItemStack.EMPTY; - for(int i = 0; i < inv.getSizeInventory(); i++) { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(!stack.isEmpty() && stack.getItem() != ModItems.keepIvy) + if (!stack.isEmpty() && stack.getItem() != ModItems.keepIvy) { item = stack; + } } ItemStack copy = item.copy(); diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/LensDyeingRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/LensDyeingRecipe.java index 23ded8939..ad4885d5d 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/LensDyeingRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/LensDyeingRecipe.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 23, 2015, 4:10:24 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -19,11 +17,13 @@ import net.minecraft.item.crafting.SpecialRecipeSerializer; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.common.Tags; + import vazkii.botania.api.mana.ILens; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.lens.ItemLens; import javax.annotation.Nonnull; + import java.util.Arrays; import java.util.List; @@ -57,18 +57,21 @@ public class LensDyeingRecipe extends SpecialRecipe { boolean foundLens = false; boolean foundDye = false; - for(int i = 0; i < inv.getSizeInventory(); i++) { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(!stack.isEmpty()) { - if(stack.getItem() instanceof ILens && !foundLens) + if (!stack.isEmpty()) { + if (stack.getItem() instanceof ILens && !foundLens) { foundLens = true; - else if(!foundDye) { + } else if (!foundDye) { int color = getStackColor(stack); - if(color > -1) + if (color > -1) { foundDye = true; - else return false; + } else { + return false; + } + } else { + return false;//This means we have an additional item in the recipe after the lens and dye } - else return false;//This means we have an additional item in the recipe after the lens and dye } } @@ -81,16 +84,18 @@ public class LensDyeingRecipe extends SpecialRecipe { ItemStack lens = ItemStack.EMPTY; int color = -1; - for(int i = 0; i < inv.getSizeInventory(); i++) { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(!stack.isEmpty()) { - if(stack.getItem() instanceof ILens && lens.isEmpty()) + if (!stack.isEmpty()) { + if (stack.getItem() instanceof ILens && lens.isEmpty()) { lens = stack; - else color = getStackColor(stack);//We can assume if its not a lens its a dye because we checked it in matches() + } else { + color = getStackColor(stack);//We can assume if its not a lens its a dye because we checked it in matches() + } } } - if(lens.getItem() instanceof ILens) { + if (lens.getItem() instanceof ILens) { ItemStack lensCopy = lens.copy(); ItemLens.setLensColor(lensCopy, color); @@ -107,7 +112,7 @@ public class LensDyeingRecipe extends SpecialRecipe { private int getStackColor(ItemStack stack) { for (int i = 0; i < dyes.size(); i++) { - if(dyes.get(i).test(stack)) { + if (dyes.get(i).test(stack)) { return i; } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunClipRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunClipRecipe.java index 99e993541..50532f57d 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunClipRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunClipRecipe.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 24, 2015, 8:37:33 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -17,6 +15,7 @@ import net.minecraft.item.crafting.SpecialRecipe; import net.minecraft.item.crafting.SpecialRecipeSerializer; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + import vazkii.botania.common.item.ItemManaGun; import vazkii.botania.common.item.ModItems; @@ -34,16 +33,16 @@ public class ManaGunClipRecipe extends SpecialRecipe { boolean foundGun = false; boolean foundClip = false; - for(int i = 0; i < inv.getSizeInventory(); i++) { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(!stack.isEmpty()) { - if(stack.getItem() instanceof ItemManaGun && !ItemManaGun.hasClip(stack)) + if (!stack.isEmpty()) { + if (stack.getItem() instanceof ItemManaGun && !ItemManaGun.hasClip(stack)) { foundGun = true; - - else if(stack.getItem() == ModItems.clip) + } else if (stack.getItem() == ModItems.clip) { foundClip = true; - - else return false; // Found an invalid item, breaking the recipe + } else { + return false; // Found an invalid item, breaking the recipe + } } } @@ -55,14 +54,16 @@ public class ManaGunClipRecipe extends SpecialRecipe { public ItemStack getCraftingResult(@Nonnull CraftingInventory inv) { ItemStack gun = ItemStack.EMPTY; - for(int i = 0; i < inv.getSizeInventory(); i++) { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(!stack.isEmpty() && stack.getItem() instanceof ItemManaGun) + if (!stack.isEmpty() && stack.getItem() instanceof ItemManaGun) { gun = stack; + } } - if(gun.isEmpty()) + if (gun.isEmpty()) { return ItemStack.EMPTY; + } ItemStack lens = ItemManaGun.getLens(gun); ItemManaGun.setLens(gun, ItemStack.EMPTY); diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunLensRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunLensRecipe.java index fd0c943a4..81d1f9bb2 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunLensRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunLensRecipe.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 13, 2014, 8:01:14 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -17,6 +15,7 @@ import net.minecraft.item.crafting.SpecialRecipe; import net.minecraft.item.crafting.SpecialRecipeSerializer; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + import vazkii.botania.api.mana.ILens; import vazkii.botania.api.mana.ILensControl; import vazkii.botania.common.item.ItemManaGun; @@ -35,19 +34,22 @@ public class ManaGunLensRecipe extends SpecialRecipe { boolean foundLens = false; boolean foundGun = false; - for(int i = 0; i < inv.getSizeInventory(); i++) { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(!stack.isEmpty()) { - if(stack.getItem() instanceof ItemManaGun && ItemManaGun.getLens(stack).isEmpty()) + if (!stack.isEmpty()) { + if (stack.getItem() instanceof ItemManaGun && ItemManaGun.getLens(stack).isEmpty()) { foundGun = true; - - else if(stack.getItem() instanceof ILens) { - if(!(stack.getItem() instanceof ILensControl) || !((ILensControl) stack.getItem()).isControlLens(stack)) + } else if (stack.getItem() instanceof ILens) { + if (!(stack.getItem() instanceof ILensControl) || !((ILensControl) stack.getItem()).isControlLens(stack)) { foundLens = true; - else return false; + } else { + return false; + } } - else return false; // Found an invalid item, breaking the recipe + else { + return false; // Found an invalid item, breaking the recipe + } } } @@ -60,18 +62,20 @@ public class ManaGunLensRecipe extends SpecialRecipe { ItemStack lens = ItemStack.EMPTY; ItemStack gun = ItemStack.EMPTY; - for(int i = 0; i < inv.getSizeInventory(); i++) { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(!stack.isEmpty()) { - if(stack.getItem() instanceof ItemManaGun) + if (!stack.isEmpty()) { + if (stack.getItem() instanceof ItemManaGun) { gun = stack; - else if(stack.getItem() instanceof ILens) + } else if (stack.getItem() instanceof ILens) { lens = stack; + } } } - if(lens.isEmpty() || gun.isEmpty()) + if (lens.isEmpty() || gun.isEmpty()) { return ItemStack.EMPTY; + } ItemStack gunCopy = gun.copy(); ItemManaGun.setLens(gunCopy, lens); diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunRemoveLensRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunRemoveLensRecipe.java index 469057d73..5df24d242 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunRemoveLensRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/ManaGunRemoveLensRecipe.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Oct 6, 2014, 5:56:24 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -17,6 +15,7 @@ import net.minecraft.item.crafting.SpecialRecipe; import net.minecraft.item.crafting.SpecialRecipeSerializer; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + import vazkii.botania.common.item.ItemManaGun; import javax.annotation.Nonnull; @@ -32,13 +31,14 @@ public class ManaGunRemoveLensRecipe extends SpecialRecipe { public boolean matches(@Nonnull CraftingInventory inv, @Nonnull World world) { boolean foundGun = false; - for(int i = 0; i < inv.getSizeInventory(); i++) { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(!stack.isEmpty()) { - if(stack.getItem() instanceof ItemManaGun && !ItemManaGun.getLens(stack).isEmpty()) + if (!stack.isEmpty()) { + if (stack.getItem() instanceof ItemManaGun && !ItemManaGun.getLens(stack).isEmpty()) { foundGun = true; - - else return false; // Found an invalid item, breaking the recipe + } else { + return false; // Found an invalid item, breaking the recipe + } } } @@ -50,11 +50,12 @@ public class ManaGunRemoveLensRecipe extends SpecialRecipe { public ItemStack getCraftingResult(@Nonnull CraftingInventory inv) { ItemStack gun = ItemStack.EMPTY; - for(int i = 0; i < inv.getSizeInventory(); i++) { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(!stack.isEmpty()) { - if(stack.getItem() instanceof ItemManaGun) + if (!stack.isEmpty()) { + if (stack.getItem() instanceof ItemManaGun) { gun = stack; + } } } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/ManaUpgradeRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/ManaUpgradeRecipe.java index 658a3e35f..1ad523594 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/ManaUpgradeRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/ManaUpgradeRecipe.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 4, 2016, 1:16:22 PM (EST)] */ package vazkii.botania.common.crafting.recipe; import com.google.gson.JsonObject; + import net.minecraft.inventory.CraftingInventory; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -23,6 +22,7 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.registries.ForgeRegistryEntry; + import vazkii.botania.api.mana.IManaItem; import javax.annotation.Nonnull; @@ -36,8 +36,9 @@ public class ManaUpgradeRecipe implements ICraftingRecipe { public static ItemStack output(ItemStack output, IInventory inv) { ItemStack out = output.copy(); - if (!(out.getItem() instanceof IManaItem)) + if (!(out.getItem() instanceof IManaItem)) { return out; + } IManaItem outItem = (IManaItem) out.getItem(); for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/PhantomInkRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/PhantomInkRecipe.java index 974eb5217..306f842dd 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/PhantomInkRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/PhantomInkRecipe.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 17, 2015, 5:21:07 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -17,6 +15,7 @@ import net.minecraft.item.crafting.SpecialRecipe; import net.minecraft.item.crafting.SpecialRecipeSerializer; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + import vazkii.botania.api.item.IPhantomInkable; import vazkii.botania.common.item.ModItems; @@ -34,16 +33,20 @@ public class PhantomInkRecipe extends SpecialRecipe { boolean foundInk = false; boolean foundItem = false; - for(int i = 0; i < var1.getSizeInventory(); i++) { + for (int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(!stack.isEmpty()) { - if(stack.getItem() == ModItems.phantomInk && !foundInk) + if (!stack.isEmpty()) { + if (stack.getItem() == ModItems.phantomInk && !foundInk) { foundInk = true; - else if(!foundItem) { - if(stack.getItem() instanceof IPhantomInkable && stack.getItem().getContainerItem(stack).isEmpty()) + } else if (!foundItem) { + if (stack.getItem() instanceof IPhantomInkable && stack.getItem().getContainerItem(stack).isEmpty()) { foundItem = true; - else return false; - } else return false; + } else { + return false; + } + } else { + return false; + } } } @@ -55,10 +58,11 @@ public class PhantomInkRecipe extends SpecialRecipe { public ItemStack getCraftingResult(@Nonnull CraftingInventory var1) { ItemStack item = ItemStack.EMPTY; - for(int i = 0; i < var1.getSizeInventory(); i++) { + for (int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); - if(!stack.isEmpty() && stack.getItem() instanceof IPhantomInkable && item.isEmpty()) + if (!stack.isEmpty() && stack.getItem() instanceof IPhantomInkable && item.isEmpty()) { item = stack; + } } IPhantomInkable inkable = (IPhantomInkable) item.getItem(); diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/ShapelessManaUpgradeRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/ShapelessManaUpgradeRecipe.java index 8cb8bf125..f98083c58 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/ShapelessManaUpgradeRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/ShapelessManaUpgradeRecipe.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 4, 2016, 1:20:34 PM (EST)] */ package vazkii.botania.common.crafting.recipe; import com.google.gson.JsonObject; + import net.minecraft.inventory.CraftingInventory; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.ICraftingRecipe; @@ -27,6 +26,7 @@ import javax.annotation.Nonnull; public class ShapelessManaUpgradeRecipe implements ICraftingRecipe { private final ShapelessRecipe compose; + public ShapelessManaUpgradeRecipe(ShapelessRecipe compose) { this.compose = compose; } diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/SpellClothRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/SpellClothRecipe.java index 5baf6816d..4488e3c2e 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/SpellClothRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/SpellClothRecipe.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 25, 2015, 6:16:13 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -17,6 +15,7 @@ import net.minecraft.item.crafting.SpecialRecipe; import net.minecraft.item.crafting.SpecialRecipeSerializer; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + import vazkii.botania.common.item.ModItems; import javax.annotation.Nonnull; @@ -33,16 +32,16 @@ public class SpellClothRecipe extends SpecialRecipe { boolean foundCloth = false; boolean foundEnchanted = false; - for(int i = 0; i < inv.getSizeInventory(); i++) { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(!stack.isEmpty()) { - if(stack.isEnchanted() && !foundEnchanted && stack.getItem() != ModItems.spellCloth) + if (!stack.isEmpty()) { + if (stack.isEnchanted() && !foundEnchanted && stack.getItem() != ModItems.spellCloth) { foundEnchanted = true; - - else if(stack.getItem() == ModItems.spellCloth && !foundCloth) + } else if (stack.getItem() == ModItems.spellCloth && !foundCloth) { foundCloth = true; - - else return false; // Found an invalid item, breaking the recipe + } else { + return false; // Found an invalid item, breaking the recipe + } } } @@ -53,17 +52,18 @@ public class SpellClothRecipe extends SpecialRecipe { @Override public ItemStack getCraftingResult(@Nonnull CraftingInventory inv) { ItemStack stackToDisenchant = ItemStack.EMPTY; - for(int i = 0; i < inv.getSizeInventory(); i++) { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(!stack.isEmpty() && stack.isEnchanted() && stack.getItem() != ModItems.spellCloth) { + if (!stack.isEmpty() && stack.isEnchanted() && stack.getItem() != ModItems.spellCloth) { stackToDisenchant = stack.copy(); stackToDisenchant.setCount(1); break; } } - if(stackToDisenchant.isEmpty()) + if (stackToDisenchant.isEmpty()) { return ItemStack.EMPTY; + } stackToDisenchant.removeChildTag("Enchantments"); // Remove enchantments stackToDisenchant.removeChildTag("RepairCost"); diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/TerraPickTippingRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/TerraPickTippingRecipe.java index 7ba37b96c..a56324dcb 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/TerraPickTippingRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/TerraPickTippingRecipe.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 22, 2014, 7:45:56 PM (GMT)] */ package vazkii.botania.common.crafting.recipe; @@ -17,6 +15,7 @@ import net.minecraft.item.crafting.SpecialRecipe; import net.minecraft.item.crafting.SpecialRecipeSerializer; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.terrasteel.ItemTerraPick; @@ -40,16 +39,16 @@ public class TerraPickTippingRecipe extends SpecialRecipe { boolean foundTerraPick = false; boolean foundElementiumPick = false; - for(int i = 0; i < inv.getSizeInventory(); i++) { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(!stack.isEmpty()) { - if(stack.getItem() instanceof ItemTerraPick && !ItemTerraPick.isTipped(stack)) + if (!stack.isEmpty()) { + if (stack.getItem() instanceof ItemTerraPick && !ItemTerraPick.isTipped(stack)) { foundTerraPick = true; - - else if(stack.getItem() == ModItems.elementiumPick) + } else if (stack.getItem() == ModItems.elementiumPick) { foundElementiumPick = true; - - else return false; // Found an invalid item, breaking the recipe + } else { + return false; // Found an invalid item, breaking the recipe + } } } @@ -61,14 +60,16 @@ public class TerraPickTippingRecipe extends SpecialRecipe { public ItemStack getCraftingResult(@Nonnull CraftingInventory inv) { ItemStack terraPick = ItemStack.EMPTY; - for(int i = 0; i < inv.getSizeInventory(); i++) { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(!stack.isEmpty() && stack.getItem() instanceof ItemTerraPick) + if (!stack.isEmpty() && stack.getItem() instanceof ItemTerraPick) { terraPick = stack; + } } - if(terraPick.isEmpty()) + if (terraPick.isEmpty()) { return ItemStack.EMPTY; + } ItemStack terraPickCopy = terraPick.copy(); ItemTerraPick.setTipped(terraPickCopy); diff --git a/src/main/java/vazkii/botania/common/crafting/recipe/TwigWandRecipe.java b/src/main/java/vazkii/botania/common/crafting/recipe/TwigWandRecipe.java index 5a08b3fdd..e8dd6f1af 100644 --- a/src/main/java/vazkii/botania/common/crafting/recipe/TwigWandRecipe.java +++ b/src/main/java/vazkii/botania/common/crafting/recipe/TwigWandRecipe.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [2020-01-30, 17:20 (UTC+2)] */ package vazkii.botania.common.crafting.recipe; import com.google.gson.JsonObject; + import net.minecraft.inventory.CraftingInventory; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; @@ -24,6 +23,7 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.registries.ForgeRegistryEntry; + import vazkii.botania.common.block.decor.BlockModMushroom; import vazkii.botania.common.item.ItemTwigWand; import vazkii.botania.common.item.ModItems; @@ -52,7 +52,7 @@ public class TwigWandRecipe implements ICraftingRecipe { for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); Item item = stack.getItem(); - + int colorId; if (item instanceof ItemPetal) { colorId = ((ItemPetal) item).color.getId(); @@ -61,10 +61,11 @@ public class TwigWandRecipe implements ICraftingRecipe { } else { continue; } - if (first == -1) + if (first == -1) { first = colorId; - else + } else { return ItemTwigWand.forColors(first, colorId); + } } return ItemTwigWand.forColors(first != -1 ? first : 0, 0); } diff --git a/src/main/java/vazkii/botania/common/entity/EntityBabylonWeapon.java b/src/main/java/vazkii/botania/common/entity/EntityBabylonWeapon.java index 51f0597b4..78210220f 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityBabylonWeapon.java +++ b/src/main/java/vazkii/botania/common/entity/EntityBabylonWeapon.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 16, 2015, 3:56:14 PM (GMT)] */ package vazkii.botania.common.entity; @@ -24,13 +22,13 @@ import net.minecraft.util.SoundCategory; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.EntityRayTraceResult; -import net.minecraft.util.math.RayTraceContext; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; import net.minecraft.world.Explosion; import net.minecraft.world.World; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.client.fx.WispParticleData; import vazkii.botania.common.core.handler.ModSounds; import vazkii.botania.common.core.helper.PlayerHelper; @@ -41,11 +39,11 @@ import vazkii.botania.common.item.relic.ItemKingKey; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.List; public class EntityBabylonWeapon extends EntityThrowableCopy { - @ObjectHolder(LibMisc.MOD_ID + ":babylon_weapon") - public static EntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":babylon_weapon") public static EntityType TYPE; private static final String TAG_CHARGING = "charging"; private static final String TAG_VARIETY = "variety"; @@ -97,16 +95,16 @@ public class EntityBabylonWeapon extends EntityThrowableCopy { @Override public void tick() { LivingEntity thrower = getThrower(); - if(!world.isRemote && (thrower == null || !(thrower instanceof PlayerEntity) || thrower.removed)) { + if (!world.isRemote && (thrower == null || !(thrower instanceof PlayerEntity) || thrower.removed)) { remove(); return; } PlayerEntity player = (PlayerEntity) thrower; boolean charging = isCharging(); - if(!world.isRemote) { + if (!world.isRemote) { ItemStack stack = player == null ? ItemStack.EMPTY : PlayerHelper.getFirstHeldItem(player, ModItems.kingKey); boolean newCharging = !stack.isEmpty() && ItemKingKey.isCharging(stack); - if(charging != newCharging) { + if (charging != newCharging) { setCharging(newCharging); charging = newCharging; } @@ -118,23 +116,24 @@ public class EntityBabylonWeapon extends EntityThrowableCopy { int delay = getDelay(); charging &= liveTime == 0; - if(charging) { + if (charging) { setMotion(Vec3d.ZERO); int chargeTime = getChargeTicks(); setChargeTicks(chargeTime + 1); - if(world.rand.nextInt(20) == 0) + if (world.rand.nextInt(20) == 0) { world.playSound(null, getX(), getY(), getZ(), ModSounds.babylonSpawn, SoundCategory.PLAYERS, 0.1F, 1F + world.rand.nextFloat() * 3F); + } } else { - if(liveTime < delay) { + if (liveTime < delay) { setMotion(Vec3d.ZERO); } else if (liveTime == delay && player != null) { Vector3 playerLook; BlockRayTraceResult rtr = ToolCommons.raytraceFromEntity(player, 64, true); - if(rtr.getType() != RayTraceResult.Type.BLOCK) + if (rtr.getType() != RayTraceResult.Type.BLOCK) { playerLook = new Vector3(player.getLookVec()).multiply(64).add(Vector3.fromEntity(player)); - else { + } else { playerLook = new Vector3(rtr.getPos().getX() + 0.5, rtr.getPos().getY() + 0.5, rtr.getPos().getZ() + 0.5); } @@ -146,17 +145,20 @@ public class EntityBabylonWeapon extends EntityThrowableCopy { } setLiveTicks(liveTime + 1); - if(!world.isRemote) { + if (!world.isRemote) { AxisAlignedBB axis = new AxisAlignedBB(getX(), getY(), getZ(), lastTickPosX, lastTickPosY, lastTickPosZ).grow(2); List entities = world.getEntitiesWithinAABB(LivingEntity.class, axis); - for(LivingEntity living : entities) { - if(living == thrower) + for (LivingEntity living : entities) { + if (living == thrower) { continue; + } - if(living.hurtTime == 0) { - if(player != null) + if (living.hurtTime == 0) { + if (player != null) { living.attackEntityFrom(DamageSource.causePlayerDamage(player), 20); - else living.attackEntityFrom(DamageSource.GENERIC, 20); + } else { + living.attackEntityFrom(DamageSource.GENERIC, 20); + } onImpact(new EntityRayTraceResult(living)); return; } @@ -168,19 +170,20 @@ public class EntityBabylonWeapon extends EntityThrowableCopy { setMotion(mot); - if(liveTime > delay) { - WispParticleData data = WispParticleData.wisp(0.3F, 1F, 1F, 0F, 1); - world.addParticle(data, getX(), getY(), getZ(), 0, -0F, 0); - } + if (liveTime > delay) { + WispParticleData data = WispParticleData.wisp(0.3F, 1F, 1F, 0F, 1); + world.addParticle(data, getX(), getY(), getZ(), 0, -0F, 0); + } - if(liveTime > 200 + delay) + if (liveTime > 200 + delay) { remove(); + } } @Override protected void onImpact(RayTraceResult pos) { LivingEntity thrower = getThrower(); - if(pos.getType() != RayTraceResult.Type.ENTITY || ((EntityRayTraceResult) pos).getEntity() != thrower) { + if (pos.getType() != RayTraceResult.Type.ENTITY || ((EntityRayTraceResult) pos).getEntity() != thrower) { world.createExplosion(this, getX(), getY(), getZ(), 3F, Explosion.Mode.NONE); remove(); } diff --git a/src/main/java/vazkii/botania/common/entity/EntityCorporeaSpark.java b/src/main/java/vazkii/botania/common/entity/EntityCorporeaSpark.java index bb4d0b2c4..f9639e330 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityCorporeaSpark.java +++ b/src/main/java/vazkii/botania/common/entity/EntityCorporeaSpark.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 13, 2015, 10:52:40 PM (GMT)] */ package vazkii.botania.common.entity; import com.google.common.base.Predicates; + import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.player.PlayerEntity; @@ -30,6 +29,7 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.corporea.ICorporeaSpark; import vazkii.botania.api.corporea.InvWithLocation; import vazkii.botania.common.core.helper.InventoryHelper; @@ -38,12 +38,12 @@ import vazkii.botania.common.item.material.ItemDye; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.ArrayList; import java.util.List; public class EntityCorporeaSpark extends EntitySparkBase implements ICorporeaSpark { - @ObjectHolder(LibMisc.MOD_ID + ":corporea_spark") - public static EntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":corporea_spark") public static EntityType TYPE; private static final int SCAN_RANGE = 8; @@ -84,34 +84,40 @@ public class EntityCorporeaSpark extends EntitySparkBase implements ICorporeaSpa public void tick() { super.tick(); - if(world.isRemote) + if (world.isRemote) { return; + } InvWithLocation inv = getSparkInventory(); - if(inv == null) { + if (inv == null) { dropAndKill(); return; } - if(isMaster()) + if (isMaster()) { master = this; + } - if(firstTick) { - if(isMaster()) + if (firstTick) { + if (isMaster()) { restartNetwork(); - else findNetwork(); + } else { + findNetwork(); + } firstTick = false; } - if(master != null && (((Entity) master).removed || master.getNetwork() != getNetwork())) + if (master != null && (((Entity) master).removed || master.getNetwork() != getNetwork())) { master = null; + } int displayTicks = getItemDisplayTicks(); - if(displayTicks > 0) + if (displayTicks > 0) { setItemDisplayTicks(displayTicks - 1); - else if(displayTicks < 0) + } else if (displayTicks < 0) { setItemDisplayTicks(displayTicks + 1); + } } private void dropAndKill() { @@ -129,9 +135,10 @@ public class EntityCorporeaSpark extends EntitySparkBase implements ICorporeaSpa @Override public void registerConnections(ICorporeaSpark master, ICorporeaSpark referrer, List connections) { relatives.clear(); - for(ICorporeaSpark spark : getNearbySparks()) { - if(spark == null || connections.contains(spark) || spark.getNetwork() != getNetwork() || spark.isMaster() || ((Entity) spark).removed) + for (ICorporeaSpark spark : getNearbySparks()) { + if (spark == null || connections.contains(spark) || spark.getNetwork() != getNetwork() || spark.isMaster() || ((Entity) spark).removed) { continue; + } connections.add(spark); relatives.add(spark); @@ -151,7 +158,7 @@ public class EntityCorporeaSpark extends EntitySparkBase implements ICorporeaSpa connections = new ArrayList<>(); relatives = new ArrayList<>(); - if(master != null) { + if (master != null) { ICorporeaSpark oldMaster = master; master = null; @@ -160,30 +167,34 @@ public class EntityCorporeaSpark extends EntitySparkBase implements ICorporeaSpa } private void findNetwork() { - for(ICorporeaSpark spark : getNearbySparks()) - if(spark.getNetwork() == getNetwork() && !((Entity) spark).removed) { + for (ICorporeaSpark spark : getNearbySparks()) { + if (spark.getNetwork() == getNetwork() && !((Entity) spark).removed) { ICorporeaSpark master = spark.getMaster(); - if(master != null) { + if (master != null) { this.master = master; restartNetwork(); break; } } + } } private static void displayRelatives(PlayerEntity player, List checked, ICorporeaSpark spark) { - if(spark == null) + if (spark == null) { return; + } List sparks = spark.getRelatives(); - if(sparks.isEmpty()) + if (sparks.isEmpty()) { EntitySpark.particleBeam(player, (Entity) spark, (Entity) spark.getMaster()); - else for(ICorporeaSpark endSpark : sparks) { - if(!checked.contains(endSpark)) { - EntitySpark.particleBeam(player, (Entity) spark, (Entity) endSpark); - checked.add(endSpark); - displayRelatives(player, checked, endSpark); + } else { + for (ICorporeaSpark endSpark : sparks) { + if (!checked.contains(endSpark)) { + EntitySpark.particleBeam(player, (Entity) spark, (Entity) endSpark); + checked.add(endSpark); + displayRelatives(player, checked, endSpark); + } } } } @@ -214,7 +225,7 @@ public class EntityCorporeaSpark extends EntitySparkBase implements ICorporeaSpa @Override public void onItemsRequested(List stacks) { - if(!stacks.isEmpty()) { + if (!stacks.isEmpty()) { setItemDisplayTicks(-10); setDisplayedItem(stacks.get(0)); } @@ -253,36 +264,40 @@ public class EntityCorporeaSpark extends EntitySparkBase implements ICorporeaSpa @Override public boolean processInitialInteract(PlayerEntity player, Hand hand) { ItemStack stack = player.getHeldItem(hand); - if(!removed && !stack.isEmpty()) { - if(player.world.isRemote) { + if (!removed && !stack.isEmpty()) { + if (player.world.isRemote) { boolean valid = stack.getItem() == ModItems.twigWand || stack.getItem() instanceof ItemDye || stack.getItem() == ModItems.phantomInk; - if(valid) + if (valid) { player.swingArm(hand); + } return valid; } - if(stack.getItem() == ModItems.twigWand) { - if(player.isSneaking()) { + if (stack.getItem() == ModItems.twigWand) { + if (player.isSneaking()) { dropAndKill(); - if(isMaster()) + if (isMaster()) { restartNetwork(); + } } else { displayRelatives(player, new ArrayList<>(), master); } return true; - } else if(stack.getItem() instanceof ItemDye) { + } else if (stack.getItem() instanceof ItemDye) { DyeColor color = ((ItemDye) stack.getItem()).color; - if(color != getNetwork()) { + if (color != getNetwork()) { setNetwork(color); - if(isMaster()) + if (isMaster()) { restartNetwork(); - else findNetwork(); + } else { + findNetwork(); + } stack.shrink(1); return true; } - } else if(stack.getItem() == ModItems.phantomInk) { + } else if (stack.getItem() == ModItems.phantomInk) { setInvisible(true); return true; } diff --git a/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java b/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java index 3a4020c1f..5e7f4fcc4 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java +++ b/src/main/java/vazkii/botania/common/entity/EntityDoppleganger.java @@ -1,24 +1,21 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 12, 2014, 3:47:45 PM (GMT)] */ package vazkii.botania.common.entity; import com.google.common.collect.ImmutableList; -import com.mojang.blaze3d.platform.GLX; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.TickableSound; -import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; @@ -57,13 +54,12 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.Style; import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.BossInfo; import net.minecraft.world.Difficulty; -import net.minecraft.world.server.ServerBossInfo; import net.minecraft.world.World; +import net.minecraft.world.server.ServerBossInfo; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -71,6 +67,7 @@ import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.boss.IBotaniaBoss; import vazkii.botania.api.internal.ShaderCallback; import vazkii.botania.client.core.handler.BossBarHandler; @@ -89,6 +86,7 @@ import vazkii.botania.common.network.PacketHandler; import javax.annotation.Nonnull; import javax.annotation.Nullable; + import java.awt.*; import java.util.ArrayList; import java.util.Arrays; @@ -99,8 +97,7 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEntityAdditionalSpawnData { - @ObjectHolder(LibMisc.MOD_ID + ":doppleganger") - public static EntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":doppleganger") public static EntityType TYPE; public static final float ARENA_RANGE = 12F; public static final int ARENA_HEIGHT = 5; @@ -135,8 +132,8 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti ); private static final List CHEATY_BLOCKS = Arrays.asList( - new ResourceLocation("openblocks", "beartrap"), - new ResourceLocation("thaumictinkerer", "magnet") + new ResourceLocation("openblocks", "beartrap"), + new ResourceLocation("thaumictinkerer", "magnet") ); private boolean spawnLandmines = false; @@ -156,7 +153,7 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti public EntityDoppleganger(EntityType type, World world) { super(type, world); experienceValue = 825; - if(world.isRemote) { + if (world.isRemote) { Botania.proxy.addBoss(this); } } @@ -167,24 +164,24 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti public static boolean spawn(PlayerEntity player, ItemStack stack, World world, BlockPos pos, boolean hard) { //initial checks - if( - !(world.getTileEntity(pos) instanceof BeaconTileEntity) || - !isTruePlayer(player) || - countGaiaGuardiansAround(world, pos) > 0 - ) + if (!(world.getTileEntity(pos) instanceof BeaconTileEntity) || + !isTruePlayer(player) || + countGaiaGuardiansAround(world, pos) > 0) { return false; - + } + //check difficulty - if(world.getDifficulty() == Difficulty.PEACEFUL) { - if(!world.isRemote) + if (world.getDifficulty() == Difficulty.PEACEFUL) { + if (!world.isRemote) { player.sendMessage(new TranslationTextComponent("botaniamisc.peacefulNoob").applyTextStyle(TextFormatting.RED)); + } return false; } //check pylons List invalidPylonBlocks = checkPylons(world, pos); - if(!invalidPylonBlocks.isEmpty()) { - if(world.isRemote) { + if (!invalidPylonBlocks.isEmpty()) { + if (world.isRemote) { warnInvalidBlocks(world, invalidPylonBlocks); } else { player.sendMessage(new TranslationTextComponent("botaniamisc.needsCatalysts").applyTextStyle(TextFormatting.RED)); @@ -195,12 +192,12 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti //check arena shape List invalidArenaBlocks = checkArena(world, pos); - if(!invalidArenaBlocks.isEmpty()) { - if(world.isRemote) { + if (!invalidArenaBlocks.isEmpty()) { + if (world.isRemote) { warnInvalidBlocks(world, invalidArenaBlocks); } else { PacketHandler.sendTo((ServerPlayerEntity) player, - new PacketBotaniaEffect(PacketBotaniaEffect.EffectType.ARENA_INDICATOR, pos.getX(), pos.getY(), pos.getZ())); + new PacketBotaniaEffect(PacketBotaniaEffect.EffectType.ARENA_INDICATOR, pos.getX(), pos.getY(), pos.getZ())); player.sendMessage(new TranslationTextComponent("botaniamisc.badArena").applyTextStyle(TextFormatting.RED)); } @@ -209,7 +206,7 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti } //all checks ok, spawn the boss - if(!world.isRemote) { + if (!world.isRemote) { stack.shrink(1); EntityDoppleganger e = new EntityDoppleganger(world); @@ -223,25 +220,26 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti int playerCount = e.getPlayersAround().size(); e.playerCount = playerCount; e.getAttributes().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(MAX_HP * playerCount); - if(hard) + if (hard) { e.getAttributes().getAttributeInstance(SharedMonsterAttributes.ARMOR).setBaseValue(15); + } e.playSound(SoundEvents.ENTITY_ENDER_DRAGON_GROWL, 10F, 0.1F); e.onInitialSpawn(world, world.getDifficultyForLocation(new BlockPos(e)), SpawnReason.EVENT, null, null); world.addEntity(e); } - + return true; } private static List checkPylons(World world, BlockPos beaconPos) { List invalidPylonBlocks = new ArrayList<>(); - for(BlockPos coords : PYLON_LOCATIONS) { + for (BlockPos coords : PYLON_LOCATIONS) { BlockPos pos_ = beaconPos.add(coords); - + BlockState state = world.getBlockState(pos_); - if(state.getBlock() != ModBlocks.gaiaPylon) { + if (state.getBlock() != ModBlocks.gaiaPylon) { invalidPylonBlocks.add(pos_); } } @@ -254,16 +252,18 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti int range = (int) Math.ceil(ARENA_RANGE); BlockPos pos; - for(int x = -range; x <= range; x++) - for(int z = -range; z <= range; z++) { - if(Math.abs(x) == 4 && Math.abs(z) == 4 || vazkii.botania.common.core.helper.MathHelper.pointDistancePlane(x, z, 0, 0) > ARENA_RANGE) + for (int x = -range; x <= range; x++) { + for (int z = -range; z <= range; z++) { + if (Math.abs(x) == 4 && Math.abs(z) == 4 || vazkii.botania.common.core.helper.MathHelper.pointDistancePlane(x, z, 0, 0) > ARENA_RANGE) { continue; // Ignore pylons and out of circle + } boolean hasFloor = false; - for(int y = -2; y <= ARENA_HEIGHT; y++) { - if(x == 0 && y == 0 && z == 0) + for (int y = -2; y <= ARENA_HEIGHT; y++) { + if (x == 0 && y == 0 && z == 0) { continue; //the beacon + } pos = beaconPos.add(x, y, z); @@ -272,23 +272,30 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti boolean allowBlockHere = y < 0; boolean isBlockHere = !state.getCollisionShape(world, pos).isEmpty(); - if(allowBlockHere && isBlockHere) //floor is here! good + if (allowBlockHere && isBlockHere) //floor is here! good + { hasFloor = true; + } - if(y == 0 && !hasFloor) //column is entirely missing floor + if (y == 0 && !hasFloor) //column is entirely missing floor + { trippedPositions.add(pos.down()); + } - if(!allowBlockHere && isBlockHere && !BLACKLIST.contains(state.getBlock())) //ceiling is obstructed in this column + if (!allowBlockHere && isBlockHere && !BLACKLIST.contains(state.getBlock())) //ceiling is obstructed in this column + { trippedPositions.add(pos); + } } } + } return trippedPositions; } private static void warnInvalidBlocks(World world, Iterable invalidPositions) { WispParticleData data = WispParticleData.wisp(0.5F, 1, 0.2F, 0.2F, 8, false); - for(BlockPos pos_ : invalidPositions) { + for (BlockPos pos_ : invalidPositions) { world.addParticle(data, pos_.getX() + 0.5, pos_.getY() + 0.5, pos_.getZ() + 0.5, 0, 0, 0); } } @@ -345,9 +352,11 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti source = new BlockPos(x, y, z); hardMode = cmp.getBoolean(TAG_HARD_MODE); - if(cmp.contains(TAG_PLAYER_COUNT)) + if (cmp.contains(TAG_PLAYER_COUNT)) { playerCount = cmp.getInt(TAG_PLAYER_COUNT); - else playerCount = 1; + } else { + playerCount = 1; + } if (this.hasCustomName()) { this.bossInfo.setName(this.getDisplayName()); @@ -362,7 +371,7 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti @Override public void heal(float amount) { - if(getInvulTime() == 0) { + if (getInvulTime() == 0) { super.heal(amount); } } @@ -378,8 +387,9 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti if (e instanceof PlayerEntity && isTruePlayer(e) && getInvulTime() == 0) { PlayerEntity player = (PlayerEntity) e; - if(!playersWhoAttacked.contains(player.getUniqueID())) + if (!playersWhoAttacked.contains(player.getUniqueID())) { playersWhoAttacked.add(player.getUniqueID()); + } int cap = 25; return super.attackEntityFrom(source, Math.min(cap, amount)); @@ -389,9 +399,11 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti } private static final Pattern FAKE_PLAYER_PATTERN = Pattern.compile("^(?:\\[.*\\])|(?:ComputerCraft)$"); + public static boolean isTruePlayer(Entity e) { - if(!(e instanceof PlayerEntity)) + if (!(e instanceof PlayerEntity)) { return false; + } PlayerEntity player = (PlayerEntity) e; @@ -404,12 +416,12 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti super.damageEntity(source, amount); Entity attacker = source.getImmediateSource(); - if(attacker != null) { + if (attacker != null) { Vector3 thisVector = Vector3.fromEntityCenter(this); Vector3 playerVector = Vector3.fromEntityCenter(attacker); Vector3 motionVector = thisVector.subtract(playerVector).normalize().multiply(0.75); - if(getHealth() > 0) { + if (getHealth() > 0) { setMotion(-motionVector.x, 0.5, -motionVector.z); tpDelay = 4; spawnPixies = aggro; @@ -423,7 +435,7 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti public void onDeath(@Nonnull DamageSource source) { super.onDeath(source); LivingEntity entitylivingbase = getAttackingEntity(); - if(entitylivingbase instanceof ServerPlayerEntity && !anyWithArmor) { + if (entitylivingbase instanceof ServerPlayerEntity && !anyWithArmor) { DopplegangerNoArmorTrigger.INSTANCE.trigger((ServerPlayerEntity) entitylivingbase, this, source); } @@ -466,8 +478,9 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti // Generate loot table for every single attacking player for (UUID u : playersWhoAttacked) { PlayerEntity player = world.getPlayerByUuid(u); - if (player == null) + if (player == null) { continue; + } PlayerEntity saveLastAttacker = attackingPlayer; Vec3d savePos = getPositionVec(); @@ -485,7 +498,7 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti @Override public void remove() { - if(world.isRemote) { + if (world.isRemote) { Botania.proxy.removeBoss(this); } super.remove(); @@ -503,7 +516,7 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti } private void particles() { - for(int i = 0; i < 360; i += 8) { + for (int i = 0; i < 360; i += 8) { float r = 0.6F; float g = 0F; float b = 0.2F; @@ -519,9 +532,9 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti world.addParticle(data, x, y, z, (float) (Math.random() - 0.5F) * m, (float) (Math.random() - 0.5F) * mv, (float) (Math.random() - 0.5F) * m); } - if(getInvulTime() > 10) { + if (getInvulTime() > 10) { Vector3 pos = Vector3.fromEntityCenter(this).subtract(new Vector3(0, 0.2, 0)); - for(BlockPos arr : PYLON_LOCATIONS) { + for (BlockPos arr : PYLON_LOCATIONS) { Vector3 pylonPos = new Vector3(source.getX() + arr.getX(), source.getY() + arr.getY(), source.getZ() + arr.getZ()); double worldTime = ticksExisted; worldTime /= 5; @@ -546,32 +559,42 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti } private void smashBlocksAround(int centerX, int centerY, int centerZ, int radius) { - for(int dx = -radius; dx <= radius; dx++) - for(int dy = -radius; dy <= radius + 1; dy++) - for(int dz = -radius; dz <= radius; dz++) { + for (int dx = -radius; dx <= radius; dx++) { + for (int dy = -radius; dy <= radius + 1; dy++) { + for (int dz = -radius; dz <= radius; dz++) { int x = centerX + dx; int y = centerY + dy; int z = centerZ + dz; - + BlockPos pos = new BlockPos(x, y, z); BlockState state = world.getBlockState(pos); Block block = state.getBlock(); - - if(state.getBlockHardness(world, pos) == -1) continue; - - if(CHEATY_BLOCKS.contains(block.getRegistryName())) { + + if (state.getBlockHardness(world, pos) == -1) { + continue; + } + + if (CHEATY_BLOCKS.contains(block.getRegistryName())) { world.destroyBlock(pos, true); } else { //don't break blacklisted blocks - if(BLACKLIST.contains(block)) continue; + if (BLACKLIST.contains(block)) { + continue; + } //don't break the floor - if(y < source.getY()) continue; + if (y < source.getY()) { + continue; + } //don't break blocks in pylon columns - if(Math.abs(source.getX() - x) == 4 && Math.abs(source.getZ() - z) == 4) continue; - + if (Math.abs(source.getX() - x) == 4 && Math.abs(source.getZ() - z) == 4) { + continue; + } + world.destroyBlock(pos, true); } } + } + } } private void clearPotions(PlayerEntity player) { @@ -589,7 +612,7 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti } private void keepInsideArena(PlayerEntity player) { - if(vazkii.botania.common.core.helper.MathHelper.pointDistanceSpace(player.getX(), player.getY(), player.getZ(), source.getX() + 0.5, source.getY() + 0.5, source.getZ() + 0.5) >= ARENA_RANGE) { + if (vazkii.botania.common.core.helper.MathHelper.pointDistanceSpace(player.getX(), player.getY(), player.getZ(), source.getX() + 0.5, source.getY() + 0.5, source.getZ() + 0.5) >= ARENA_RANGE) { Vector3 sourceVector = new Vector3(source.getX() + 0.5, source.getY() + 0.5, source.getZ() + 0.5); Vector3 playerVector = Vector3.fromEntityCenter(player); Vector3 motion = sourceVector.subtract(playerVector).normalize(); @@ -600,48 +623,49 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti } private void spawnMobs(List players) { - for(int pl = 0; pl < playerCount; pl++) { - for(int i = 0; i < 3 + world.rand.nextInt(2); i++) { + for (int pl = 0; pl < playerCount; pl++) { + for (int i = 0; i < 3 + world.rand.nextInt(2); i++) { MobEntity entity = null; switch (world.rand.nextInt(2)) { - case 0: { - entity = new ZombieEntity(world); - if(world.rand.nextInt(hardMode ? 3 : 12) == 0) { - entity = EntityType.WITCH.create(world); - } - break; + case 0: { + entity = new ZombieEntity(world); + if (world.rand.nextInt(hardMode ? 3 : 12) == 0) { + entity = EntityType.WITCH.create(world); } - case 1: { - entity = EntityType.SKELETON.create(world); - if(world.rand.nextInt(8) == 0) { - entity = EntityType.WITHER_SKELETON.create(world); - } - break; + break; + } + case 1: { + entity = EntityType.SKELETON.create(world); + if (world.rand.nextInt(8) == 0) { + entity = EntityType.WITHER_SKELETON.create(world); } - case 3: { - if(!players.isEmpty()) { - for(int j = 0; j < 1 + world.rand.nextInt(hardMode ? 8 : 5); j++) { - EntityPixie pixie = new EntityPixie(world); - pixie.setProps(players.get(rand.nextInt(players.size())), this, 1, 8); - pixie.setPosition(getX() + getWidth() / 2, getY() + 2, getZ() + getWidth() / 2); - pixie.onInitialSpawn(world, world.getDifficultyForLocation(new BlockPos(pixie)), - SpawnReason.MOB_SUMMONED, null, null); - world.addEntity(pixie); - } + break; + } + case 3: { + if (!players.isEmpty()) { + for (int j = 0; j < 1 + world.rand.nextInt(hardMode ? 8 : 5); j++) { + EntityPixie pixie = new EntityPixie(world); + pixie.setProps(players.get(rand.nextInt(players.size())), this, 1, 8); + pixie.setPosition(getX() + getWidth() / 2, getY() + 2, getZ() + getWidth() / 2); + pixie.onInitialSpawn(world, world.getDifficultyForLocation(new BlockPos(pixie)), + SpawnReason.MOB_SUMMONED, null, null); + world.addEntity(pixie); } - break; } + break; + } } - if(entity != null) { - if(!entity.isImmuneToFire()) + if (entity != null) { + if (!entity.isImmuneToFire()) { entity.addPotionEffect(new EffectInstance(Effects.FIRE_RESISTANCE, 600, 0)); + } float range = 6F; entity.setPosition(getX() + 0.5 + Math.random() * range - range / 2, getY() - 1, getZ() + 0.5 + Math.random() * range - range / 2); entity.onInitialSpawn(world, world.getDifficultyForLocation(new BlockPos(entity)), SpawnReason.MOB_SUMMONED, null, null); - if(entity instanceof WitherSkeletonEntity && hardMode) { + if (entity instanceof WitherSkeletonEntity && hardMode) { entity.setItemStackToSlot(EquipmentSlotType.MAINHAND, new ItemStack(ModItems.elementiumSword)); } world.addEntity(entity); @@ -649,63 +673,71 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti } } } - + @Override public void livingTick() { super.livingTick(); int invul = getInvulTime(); - if(world.isRemote) { + if (world.isRemote) { particles(); PlayerEntity player = Botania.proxy.getClientPlayer(); - if(getPlayersAround().contains(player)) + if (getPlayersAround().contains(player)) { player.abilities.isFlying &= player.abilities.isCreativeMode; + } return; } bossInfo.setPercent(getHealth() / getMaxHealth()); - if(isPassenger()) + if (isPassenger()) { stopRiding(); + } - if(world.getDifficulty() == Difficulty.PEACEFUL) + if (world.getDifficulty() == Difficulty.PEACEFUL) { remove(); + } smashBlocksAround(MathHelper.floor(getX()), MathHelper.floor(getY()), MathHelper.floor(getZ()), 1); List players = getPlayersAround(); - if(players.isEmpty() && !world.getPlayers().isEmpty()) + if (players.isEmpty() && !world.getPlayers().isEmpty()) { remove(); - else { - for(PlayerEntity player : players) { - for(EquipmentSlotType e : EquipmentSlotType.values()) { - if(e.getSlotType() == EquipmentSlotType.Group.ARMOR && !player.getItemStackFromSlot(e).isEmpty()) { + } else { + for (PlayerEntity player : players) { + for (EquipmentSlotType e : EquipmentSlotType.values()) { + if (e.getSlotType() == EquipmentSlotType.Group.ARMOR && !player.getItemStackFromSlot(e).isEmpty()) { anyWithArmor = true; break; } } //also see SleepingHandler - if(player.isSleeping()) player.wakeUp(true, true); - + if (player.isSleeping()) { + player.wakeUp(true, true); + } + clearPotions(player); keepInsideArena(player); player.abilities.isFlying &= player.abilities.isCreativeMode; } } - if(!isAlive() || players.isEmpty()) + if (!isAlive() || players.isEmpty()) { return; + } boolean spawnMissiles = hardMode && ticksExisted % 15 < 4; - if(invul > 0 && mobSpawnTicks == MOB_SPAWN_TICKS) { - if(invul < SPAWN_TICKS) { - if(invul > SPAWN_TICKS / 2 && world.rand.nextInt(SPAWN_TICKS - invul + 1) == 0) - for(int i = 0; i < 2; i++) + if (invul > 0 && mobSpawnTicks == MOB_SPAWN_TICKS) { + if (invul < SPAWN_TICKS) { + if (invul > SPAWN_TICKS / 2 && world.rand.nextInt(SPAWN_TICKS - invul + 1) == 0) { + for (int i = 0; i < 2; i++) { spawnExplosionParticle(); + } + } } setHealth(getHealth() + (getMaxHealth() - 1F) / SPAWN_TICKS); @@ -713,40 +745,42 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti setMotion(getMotion().getX(), 0, getMotion().getZ()); } else { - if(aggro) { + if (aggro) { boolean dying = getHealth() / getMaxHealth() < 0.2; - if(dying && mobSpawnTicks > 0) { + if (dying && mobSpawnTicks > 0) { setMotion(Vec3d.ZERO); int reverseTicks = MOB_SPAWN_TICKS - mobSpawnTicks; - if(reverseTicks < MOB_SPAWN_START_TICKS) { + if (reverseTicks < MOB_SPAWN_START_TICKS) { setMotion(getMotion().getX(), 0.2, getMotion().getZ()); setInvulTime(invul + 1); } - if(reverseTicks > MOB_SPAWN_START_TICKS * 2 && mobSpawnTicks > MOB_SPAWN_END_TICKS && mobSpawnTicks % MOB_SPAWN_WAVE_TIME == 0) { + if (reverseTicks > MOB_SPAWN_START_TICKS * 2 && mobSpawnTicks > MOB_SPAWN_END_TICKS && mobSpawnTicks % MOB_SPAWN_WAVE_TIME == 0) { spawnMobs(players); - if(hardMode && ticksExisted % 3 < 2) { - for(int i = 0; i < playerCount; i++) + if (hardMode && ticksExisted % 3 < 2) { + for (int i = 0; i < playerCount; i++) { spawnMissile(); + } spawnMissiles = false; } } mobSpawnTicks--; tpDelay = 10; - } else if(tpDelay > 0) { - if(invul > 0) + } else if (tpDelay > 0) { + if (invul > 0) { setInvulTime(invul - 1); + } tpDelay--; - if(tpDelay == 0 && getHealth() > 0) { + if (tpDelay == 0 && getHealth() > 0) { teleportRandomly(); - if(spawnLandmines) { + if (spawnLandmines) { int count = dying && hardMode ? 7 : 6; - for(int i = 0; i < count; i++) { + for (int i = 0; i < count; i++) { int x = source.getX() - 10 + rand.nextInt(20); int y = (int) players.get(rand.nextInt(players.size())).getY(); int z = source.getZ() - 10 + rand.nextInt(20); @@ -759,8 +793,8 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti } - for(int pl = 0; pl < playerCount; pl++) - for(int i = 0; i < (spawnPixies ? world.rand.nextInt(hardMode ? 6 : 3) : 1); i++) { + for (int pl = 0; pl < playerCount; pl++) { + for (int i = 0; i < (spawnPixies ? world.rand.nextInt(hardMode ? 6 : 3) : 1); i++) { EntityPixie pixie = new EntityPixie(world); pixie.setProps(players.get(rand.nextInt(players.size())), this, 1, 8); pixie.setPosition(getX() + getWidth() / 2, getY() + 2, getZ() + getWidth() / 2); @@ -768,6 +802,7 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti SpawnReason.MOB_SUMMONED, null, null); world.addEntity(pixie); } + } tpDelay = hardMode ? dying ? 35 : 45 : dying ? 40 : 60; spawnLandmines = true; @@ -775,8 +810,9 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti } } - if(spawnMissiles) + if (spawnMissiles) { spawnMissile(); + } } else { damageEntity(DamageSource.causePlayerDamage(players.get(0)), 0); } @@ -802,8 +838,9 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti @Override protected void collideWithNearbyEntities() { - if(getInvulTime() == 0) + if (getInvulTime() == 0) { super.collideWithNearbyEntities(); + } } @Override @@ -814,7 +851,7 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti private void spawnMissile() { EntityMagicMissile missile = new EntityMagicMissile(this, true); missile.setPosition(getX() + (Math.random() - 0.5 * 0.1), getY() + 2.4 + (Math.random() - 0.5 * 0.1), getZ() + (Math.random() - 0.5 * 0.1)); - if(missile.findTarget()) { + if (missile.findTarget()) { playSound(ModSounds.missile, 0.6F, 0.8F + (float) Math.random() * 0.2F); world.addEntity(missile); } @@ -831,19 +868,18 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti newZ = source.getZ() + (rand.nextDouble() - .5) * ARENA_RANGE; tries++; //ensure it's inside the arena ring, and not just its bounding square - } - while(tries < 50 && vazkii.botania.common.core.helper.MathHelper.pointDistanceSpace(newX, newY, newZ, source.getX(), source.getY(), source.getZ()) > 12); + } while (tries < 50 && vazkii.botania.common.core.helper.MathHelper.pointDistanceSpace(newX, newY, newZ, source.getX(), source.getY(), source.getZ()) > 12); - if(tries == 50) { + if (tries == 50) { //failsafe: teleport to the beacon newX = source.getX() + .5; newY = source.getY() + 1.6; newZ = source.getZ() + .5; } - + //for low-floor arenas, ensure landing on the ground BlockPos tentativeFloorPos = new BlockPos(newX, newY - 1, newZ); - if(world.getBlockState(tentativeFloorPos).getCollisionShape(world, tentativeFloorPos).isEmpty()) { + if (world.getBlockState(tentativeFloorPos).getCollisionShape(world, tentativeFloorPos).isEmpty()) { newY--; } @@ -858,7 +894,7 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti //spawn particles along the path int particleCount = 128; - for(int i = 0; i < particleCount; ++i) { + for (int i = 0; i < particleCount; ++i) { double progress = i / (double) (particleCount - 1); float vx = (random.nextFloat() - 0.5F) * 0.2F; float vy = (random.nextFloat() - 0.5F) * 0.2F; @@ -872,19 +908,20 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti Vec3d oldPosVec = new Vec3d(oldX, oldY + getHeight() / 2, oldZ); Vec3d newPosVec = new Vec3d(newX, newY + getHeight() / 2, newZ); - if(oldPosVec.squareDistanceTo(newPosVec) > 1) { + if (oldPosVec.squareDistanceTo(newPosVec) > 1) { //damage players in the path of the teleport - for(PlayerEntity player : getPlayersAround()) { + for (PlayerEntity player : getPlayersAround()) { boolean hit = player.getBoundingBox().grow(0.25).rayTrace(oldPosVec, newPosVec) .isPresent(); - if(hit) + if (hit) { player.attackEntityFrom(DamageSource.causeMobDamage(this), 6); + } } //break blocks in the path of the teleport int breakSteps = (int) oldPosVec.distanceTo(newPosVec); - if(breakSteps >= 2) { - for(int i = 0; i < breakSteps; i++) { + if (breakSteps >= 2) { + for (int i = 0; i < breakSteps; i++) { float progress = i / (float) (breakSteps - 1); int breakX = MathHelper.floor(oldX + (newX - oldX) * progress); int breakY = MathHelper.floor(oldY + (newY - oldY) * progress); @@ -902,24 +939,24 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti return BossBarHandler.defaultBossBar; } - @OnlyIn(Dist.CLIENT) - private static Rectangle barRect; - @OnlyIn(Dist.CLIENT) - private static Rectangle hpBarRect; + @OnlyIn(Dist.CLIENT) private static Rectangle barRect; + @OnlyIn(Dist.CLIENT) private static Rectangle hpBarRect; @Override @OnlyIn(Dist.CLIENT) public Rectangle getBossBarTextureRect() { - if(barRect == null) + if (barRect == null) { barRect = new Rectangle(0, 0, 185, 15); + } return barRect; } @Override @OnlyIn(Dist.CLIENT) public Rectangle getBossBarHPTextureRect() { - if(hpBarRect == null) + if (hpBarRect == null) { hpBarRect = new Rectangle(0, barRect.y + barRect.height, 181, 7); + } return hpBarRect; } @@ -951,13 +988,12 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti return background ? 0 : ShaderHelper.getShader(ShaderHelper.BotaniaShader.DOPPLEGANGER_BAR).orElse(0); } - @OnlyIn(Dist.CLIENT) - private ShaderCallback shaderCallback; + @OnlyIn(Dist.CLIENT) private ShaderCallback shaderCallback; @Override @OnlyIn(Dist.CLIENT) public ShaderCallback getBossBarShaderCallback(boolean background, int shader) { - if(shaderCallback == null) + if (shaderCallback == null) { shaderCallback = shader1 -> { int grainIntensityUniform = GlStateManager.getUniformLocation(shader1, "grainIntensity"); int hpFractUniform = GlStateManager.getUniformLocation(shader1, "hpFract"); @@ -973,8 +1009,9 @@ public class EntityDoppleganger extends MobEntity implements IBotaniaBoss, IEnti ShaderHelper.FLOAT_BUF.put(0, getHealth() / getMaxHealth()); GlStateManager.uniform1(hpFractUniform, ShaderHelper.FLOAT_BUF); }; + } - return background ? null : shaderCallback; + return background ? null : shaderCallback; } @Override diff --git a/src/main/java/vazkii/botania/common/entity/EntityEnderAirBottle.java b/src/main/java/vazkii/botania/common/entity/EntityEnderAirBottle.java index 50ede56d0..6d726af27 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityEnderAirBottle.java +++ b/src/main/java/vazkii/botania/common/entity/EntityEnderAirBottle.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 16, 2015, 5:15:31 PM (GMT)] */ package vazkii.botania.common.entity; @@ -28,10 +26,12 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -42,8 +42,7 @@ import java.util.stream.Collectors; _interface = IRendersAsItem.class ) public class EntityEnderAirBottle extends ThrowableEntity implements IRendersAsItem { - @ObjectHolder(LibMisc.MOD_ID + ":ender_air_bottle") - public static EntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":ender_air_bottle") public static EntityType TYPE; public EntityEnderAirBottle(EntityType type, World world) { super(type, world); @@ -55,14 +54,15 @@ public class EntityEnderAirBottle extends ThrowableEntity implements IRendersAsI @Override protected void onImpact(@Nonnull RayTraceResult pos) { - if(pos.getType() == RayTraceResult.Type.BLOCK && !world.isRemote) { + if (pos.getType() == RayTraceResult.Type.BLOCK && !world.isRemote) { List coordsList = getCoordsToPut(((BlockRayTraceResult) pos).getPos()); world.playEvent(2002, new BlockPos(this), 8); - for(BlockPos coords : coordsList) { + for (BlockPos coords : coordsList) { world.setBlockState(coords, Blocks.END_STONE.getDefaultState()); - if(Math.random() < 0.1) + if (Math.random() < 0.1) { world.playEvent(2001, coords, Block.getStateId(Blocks.END_STONE.getDefaultState())); + } } remove(); } @@ -77,8 +77,9 @@ public class EntityEnderAirBottle extends ThrowableEntity implements IRendersAsI pos.add(range, rangeY, range))) { BlockState state = world.getBlockState(bPos); Block block = state.getBlock(); - if(block.isReplaceableOreGen(state, world, bPos, BlockStateMatcher.forBlock(Blocks.STONE))) + if (block.isReplaceableOreGen(state, world, bPos, BlockStateMatcher.forBlock(Blocks.STONE))) { possibleCoords.add(bPos.toImmutable()); + } } Collections.shuffle(possibleCoords, rand); diff --git a/src/main/java/vazkii/botania/common/entity/EntityFallingStar.java b/src/main/java/vazkii/botania/common/entity/EntityFallingStar.java index 8e35652b5..fd85d661b 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityFallingStar.java +++ b/src/main/java/vazkii/botania/common/entity/EntityFallingStar.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 17, 2015, 4:19:52 PM (GMT)] */ package vazkii.botania.common.entity; @@ -26,6 +24,7 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.client.fx.SparkleParticleData; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.lib.LibMisc; @@ -33,8 +32,7 @@ import vazkii.botania.common.lib.LibMisc; import java.util.List; public class EntityFallingStar extends EntityThrowableCopy { - @ObjectHolder(LibMisc.MOD_ID + ":falling_star") - public static EntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":falling_star") public static EntityType TYPE; public EntityFallingStar(EntityType type, World world) { super(type, world); @@ -58,7 +56,7 @@ public class EntityFallingStar extends EntityThrowableCopy { float dist = 1.5F; SparkleParticleData data = SparkleParticleData.sparkle(2F, 1F, 0.4F, 1F, 6); - for(int i = 0; i < 10; i++) { + for (int i = 0; i < 10; i++) { float xs = (float) (Math.random() - 0.5) * dist; float ys = (float) (Math.random() - 0.5) * dist; float zs = (float) (Math.random() - 0.5) * dist; @@ -66,47 +64,52 @@ public class EntityFallingStar extends EntityThrowableCopy { } LivingEntity thrower = getThrower(); - if(!world.isRemote && thrower != null) { + if (!world.isRemote && thrower != null) { AxisAlignedBB axis = new AxisAlignedBB(getX(), getY(), getZ(), lastTickPosX, lastTickPosY, lastTickPosZ).grow(2); List entities = world.getEntitiesWithinAABB(LivingEntity.class, axis); - for(LivingEntity living : entities) { - if(living == thrower) + for (LivingEntity living : entities) { + if (living == thrower) { continue; + } - if(living.hurtTime == 0) { + if (living.hurtTime == 0) { onImpact(new EntityRayTraceResult(living)); return; } } } - if(ticksExisted > 200) + if (ticksExisted > 200) { remove(); + } } @Override protected void onImpact(RayTraceResult pos) { - if (world.isRemote) + if (world.isRemote) { return; + } LivingEntity thrower = getThrower(); - if(pos.getType() == RayTraceResult.Type.ENTITY && thrower != null ) { + if (pos.getType() == RayTraceResult.Type.ENTITY && thrower != null) { Entity e = ((EntityRayTraceResult) pos).getEntity(); - if(e != thrower && e.isAlive()) { - if(thrower instanceof PlayerEntity) + if (e != thrower && e.isAlive()) { + if (thrower instanceof PlayerEntity) { e.attackEntityFrom(DamageSource.causePlayerDamage((PlayerEntity) thrower), Math.random() < 0.25 ? 10 : 5); - else e.attackEntityFrom(DamageSource.GENERIC, Math.random() < 0.25 ? 10 : 5); + } else { + e.attackEntityFrom(DamageSource.GENERIC, Math.random() < 0.25 ? 10 : 5); + } } } if (pos.getType() == RayTraceResult.Type.BLOCK) { BlockPos bpos = ((BlockRayTraceResult) pos).getPos(); BlockState state = world.getBlockState(bpos); - if(ConfigHandler.COMMON.blockBreakParticles.get() && !state.isAir(world, bpos)) + if (ConfigHandler.COMMON.blockBreakParticles.get() && !state.isAir(world, bpos)) { world.playEvent(2001, bpos, Block.getStateId(state)); + } } remove(); } } - diff --git a/src/main/java/vazkii/botania/common/entity/EntityFlameRing.java b/src/main/java/vazkii/botania/common/entity/EntityFlameRing.java index a1cc6c2bd..44d79111a 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityFlameRing.java +++ b/src/main/java/vazkii/botania/common/entity/EntityFlameRing.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 26, 2014, 12:31:10 AM (GMT)] */ package vazkii.botania.common.entity; @@ -22,16 +20,17 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.world.World; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.client.fx.WispParticleData; import vazkii.botania.common.core.helper.MathHelper; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.List; public class EntityFlameRing extends Entity { - @ObjectHolder(LibMisc.MOD_ID + ":flame_ring") - public static EntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":flame_ring") public static EntityType TYPE; public EntityFlameRing(EntityType type, World world) { super(type, world); @@ -51,12 +50,13 @@ public class EntityFlameRing extends Entity { float radius = 5F; float renderRadius = (float) (radius - Math.random()); - for(int i = 0; i < Math.min(90, ticksExisted); i++) { + for (int i = 0; i < Math.min(90, ticksExisted); i++) { float a = i; - if(a % 2 == 0) + if (a % 2 == 0) { a = 45 + a; + } - if(world.rand.nextInt(ticksExisted < 90 ? 8 : 20) == 0) { + if (world.rand.nextInt(ticksExisted < 90 ? 8 : 20) == 0) { float rad = (float) (a * 4 * Math.PI / 180F); double x = Math.cos(rad) * renderRadius; double z = Math.sin(rad) * renderRadius; @@ -73,27 +73,31 @@ public class EntityFlameRing extends Entity { } } - if(world.rand.nextInt(20) == 0) + if (world.rand.nextInt(20) == 0) { world.playSound(getX(), getY(), getZ(), SoundEvents.BLOCK_FIRE_AMBIENT, SoundCategory.BLOCKS, 1F, 1F, false); + } - if(world.isRemote) + if (world.isRemote) { return; + } - if(ticksExisted >= 300) { + if (ticksExisted >= 300) { remove(); return; } - if(ticksExisted > 45) { + if (ticksExisted > 45) { AxisAlignedBB boundingBox = new AxisAlignedBB(getX(), getY(), getZ(), getX(), getY(), getZ()).grow(radius, radius, radius); List entities = world.getEntitiesWithinAABB(LivingEntity.class, boundingBox); - if(entities.isEmpty()) + if (entities.isEmpty()) { return; + } - for(LivingEntity entity : entities) { - if(entity == null || MathHelper.pointDistancePlane(getX(), getY(), entity.getX(), entity.getY()) > radius) + for (LivingEntity entity : entities) { + if (entity == null || MathHelper.pointDistancePlane(getX(), getY(), entity.getX(), entity.getY()) > radius) { continue; + } entity.setFire(4); } @@ -116,4 +120,4 @@ public class EntityFlameRing extends Entity { public IPacket createSpawnPacket() { return NetworkHooks.getEntitySpawningPacket(this); } -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/common/entity/EntityMagicLandmine.java b/src/main/java/vazkii/botania/common/entity/EntityMagicLandmine.java index 2f28c3b56..e34e8232e 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityMagicLandmine.java +++ b/src/main/java/vazkii/botania/common/entity/EntityMagicLandmine.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 12, 2014, 7:59:00 PM (GMT)] */ package vazkii.botania.common.entity; @@ -24,16 +22,17 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.client.fx.WispParticleData; import vazkii.botania.common.core.handler.ModSounds; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.List; public class EntityMagicLandmine extends Entity { - @ObjectHolder(LibMisc.MOD_ID + ":magic_landmine") - public static EntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":magic_landmine") public static EntityType TYPE; public EntityDoppleganger summoner; @@ -57,24 +56,24 @@ public class EntityMagicLandmine extends Entity { float b = 0.2F; //Botania.proxy.wispFX(world, getX(), getY(), getZ(), r, g, b, 0.6F, -0.2F, 1); - for(int i = 0; i < 6; i++) { - WispParticleData data = WispParticleData.wisp(0.4F, r, g, b, (float) 1); - world.addParticle(data, getX() - range + Math.random() * range * 2, getY(), getZ() - range + Math.random() * range * 2, 0, - -0.015F, 0); - } + for (int i = 0; i < 6; i++) { + WispParticleData data = WispParticleData.wisp(0.4F, r, g, b, (float) 1); + world.addParticle(data, getX() - range + Math.random() * range * 2, getY(), getZ() - range + Math.random() * range * 2, 0, - -0.015F, 0); + } - if(ticksExisted >= 55) { + if (ticksExisted >= 55) { world.playSound(null, getX(), getY(), getZ(), ModSounds.gaiaTrap, SoundCategory.NEUTRAL, 0.3F, 1F); float m = 0.35F; g = 0.4F; - for(int i = 0; i < 25; i++) { + for (int i = 0; i < 25; i++) { WispParticleData data = WispParticleData.wisp(0.5F, r, g, b); world.addParticle(data, getX(), getY() + 1, getZ(), (float) (Math.random() - 0.5F) * m, (float) (Math.random() - 0.5F) * m, (float) (Math.random() - 0.5F) * m); } - if(!world.isRemote) { + if (!world.isRemote) { List players = world.getEntitiesWithinAABB(PlayerEntity.class, new AxisAlignedBB(getX() - range, getY() - range, getZ() - range, getX() + range, getY() + range, getZ() + range)); - for(PlayerEntity player : players) { + for (PlayerEntity player : players) { player.attackEntityFrom(DamageSource.causeIndirectMagicDamage(this, summoner), 10); player.addPotionEffect(new EffectInstance(Effects.BLINDNESS, 25, 0)); EffectInstance wither = new EffectInstance(Effects.WITHER, 120, 2); @@ -88,16 +87,13 @@ public class EntityMagicLandmine extends Entity { } @Override - protected void registerData() { - } + protected void registerData() {} @Override - protected void readAdditional(@Nonnull CompoundNBT var1) { - } + protected void readAdditional(@Nonnull CompoundNBT var1) {} @Override - protected void writeAdditional(@Nonnull CompoundNBT var1) { - } + protected void writeAdditional(@Nonnull CompoundNBT var1) {} @Nonnull @Override diff --git a/src/main/java/vazkii/botania/common/entity/EntityMagicMissile.java b/src/main/java/vazkii/botania/common/entity/EntityMagicMissile.java index 374aa73aa..20eeaee23 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityMagicMissile.java +++ b/src/main/java/vazkii/botania/common/entity/EntityMagicMissile.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 24, 2014, 5:58:22 PM (GMT)] */ package vazkii.botania.common.entity; import com.google.common.base.Predicates; + import net.minecraft.block.Block; import net.minecraft.block.BushBlock; import net.minecraft.block.LeavesBlock; @@ -33,16 +32,17 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.client.fx.SparkleParticleData; import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.List; public class EntityMagicMissile extends ThrowableEntity { - @ObjectHolder(LibMisc.MOD_ID + ":magic_missile") - public static EntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":magic_missile") public static EntityType TYPE; private static final String TAG_TIME = "time"; private static final DataParameter EVIL = EntityDataManager.createKey(EntityMagicMissile.class, DataSerializers.BOOLEAN); @@ -91,8 +91,9 @@ public class EntityMagicMissile extends ThrowableEntity { public LivingEntity getTargetEntity() { int id = dataManager.get(TARGET); Entity e = world.getEntityByID(id); - if(e != null && e instanceof LivingEntity) + if (e != null && e instanceof LivingEntity) { return (LivingEntity) e; + } return null; } @@ -105,7 +106,7 @@ public class EntityMagicMissile extends ThrowableEntity { super.tick(); - if(!world.isRemote && (!findTarget() || time > 40)) { + if (!world.isRemote && (!findTarget() || time > 40)) { remove(); return; } @@ -119,19 +120,20 @@ public class EntityMagicMissile extends ThrowableEntity { Vector3 particlePos = oldPos; SparkleParticleData data = evil ? SparkleParticleData.corrupt(0.8F, 1F, 0.0F, 1F, 2) - : SparkleParticleData.sparkle(0.8F, 1F, 0.4F, 1F, 2); - for(int i = 0; i < steps; i++) { + : SparkleParticleData.sparkle(0.8F, 1F, 0.4F, 1F, 2); + for (int i = 0; i < steps; i++) { world.addParticle(data, particlePos.x, particlePos.y, particlePos.z, 0, 0, 0); - if(world.rand.nextInt(steps) <= 1) + if (world.rand.nextInt(steps) <= 1) { world.addParticle(data, particlePos.x + (Math.random() - 0.5) * 0.4, particlePos.y + (Math.random() - 0.5) * 0.4, particlePos.z + (Math.random() - 0.5) * 0.4, 0, 0, 0); + } particlePos = particlePos.add(step); } LivingEntity target = getTargetEntity(); - if(target != null) { - if(lockY == -1) { + if (target != null) { + if (lockY == -1) { lockX = target.getX(); lockY = target.getY(); lockZ = target.getZ(); @@ -141,22 +143,26 @@ public class EntityMagicMissile extends ThrowableEntity { Vector3 diffVec = targetVec.subtract(thisVec); Vector3 motionVec = diffVec.normalize().multiply(evil ? 0.5 : 0.6); setMotion(motionVec.toVec3D()); - if(time < 10) + if (time < 10) { setMotion(getMotion().getX(), Math.abs(getMotion().getY()), getMotion().getZ()); + } List targetList = world.getEntitiesWithinAABB(LivingEntity.class, new AxisAlignedBB(getX() - 0.5, getY() - 0.5, getZ() - 0.5, getX() + 0.5, getY() + 0.5, getZ() + 0.5)); - if(targetList.contains(target)) { + if (targetList.contains(target)) { LivingEntity thrower = getThrower(); - if(thrower != null) { + if (thrower != null) { PlayerEntity player = thrower instanceof PlayerEntity ? (PlayerEntity) thrower : null; target.attackEntityFrom(player == null ? DamageSource.causeMobDamage(thrower) : DamageSource.causePlayerDamage(player), evil ? 12 : 7); - } else target.attackEntityFrom(DamageSource.GENERIC, evil ? 12 : 7); + } else { + target.attackEntityFrom(DamageSource.GENERIC, evil ? 12 : 7); + } remove(); } - if(evil && diffVec.mag() < 1) + if (evil && diffVec.mag() < 1) { remove(); + } } time++; @@ -174,25 +180,26 @@ public class EntityMagicMissile extends ThrowableEntity { time = cmp.getInt(TAG_TIME); } - public boolean findTarget() { LivingEntity target = getTargetEntity(); - if(target != null && target.isAlive()) + if (target != null && target.isAlive()) { return true; - if(target != null) + } + if (target != null) { setTarget(null); + } double range = 12; AxisAlignedBB bounds = new AxisAlignedBB(getX() - range, getY() - range, getZ() - range, getX() + range, getY() + range, getZ() + range); List entities; - if(isEvil()) { + if (isEvil()) { entities = world.getEntitiesWithinAABB(PlayerEntity.class, bounds); } else { entities = world.getEntitiesWithinAABB(Entity.class, bounds, Predicates.instanceOf(IMob.class)); } - while(entities.size() > 0) { + while (entities.size() > 0) { Entity e = (Entity) entities.get(world.rand.nextInt(entities.size())); - if(!(e instanceof LivingEntity) || !e.isAlive()) { // Just in case... + if (!(e instanceof LivingEntity) || !e.isAlive()) { // Just in case... entities.remove(e); continue; } @@ -210,13 +217,15 @@ public class EntityMagicMissile extends ThrowableEntity { switch (pos.getType()) { case BLOCK: { Block block = world.getBlockState(((BlockRayTraceResult) pos).getPos()).getBlock(); - if(!(block instanceof BushBlock) && !(block instanceof LeavesBlock)) + if (!(block instanceof BushBlock) && !(block instanceof LeavesBlock)) { remove(); + } break; } case ENTITY: { - if (((EntityRayTraceResult) pos).getEntity() == getTargetEntity()) + if (((EntityRayTraceResult) pos).getEntity() == getTargetEntity()) { remove(); + } break; } default: { diff --git a/src/main/java/vazkii/botania/common/entity/EntityManaBurst.java b/src/main/java/vazkii/botania/common/entity/EntityManaBurst.java index 0b3770ef6..e93b73d74 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityManaBurst.java +++ b/src/main/java/vazkii/botania/common/entity/EntityManaBurst.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 26, 2014, 5:09:12 PM (GMT)] */ package vazkii.botania.common.entity; @@ -28,7 +26,6 @@ import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.EntityDataManager; import net.minecraft.particles.ParticleTypes; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Hand; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; @@ -41,6 +38,7 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.mana.IClientManaHandler; @@ -62,7 +60,7 @@ import vazkii.botania.common.item.lens.LensWarp; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; -import java.awt.*; + import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -72,8 +70,7 @@ import java.util.Set; import java.util.UUID; public class EntityManaBurst extends ThrowableEntity implements IManaBurst { - @ObjectHolder(LibMisc.MOD_ID + ":mana_burst") - public static EntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":mana_burst") public static EntityType TYPE; private static final String TAG_TICKS_EXISTED = "ticksExisted"; private static final String TAG_COLOR = "color"; private static final String TAG_MANA = "mana"; @@ -131,7 +128,7 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst { } public EntityManaBurst(IManaSpreader spreader, boolean fake) { - this(((TileEntity)spreader).getWorld()); + this(((TileEntity) spreader).getWorld()); TileEntity tile = (TileEntity) spreader; @@ -177,7 +174,7 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst { if (this.inGround) { this.inGround = false; - this.setMotion(this.getMotion().mul((double)(this.rand.nextFloat() * 0.2F), (double)(this.rand.nextFloat() * 0.2F), (double)(this.rand.nextFloat() * 0.2F))); + this.setMotion(this.getMotion().mul((double) (this.rand.nextFloat() * 0.2F), (double) (this.rand.nextFloat() * 0.2F), (double) (this.rand.nextFloat() * 0.2F))); } AxisAlignedBB axisalignedbb = this.getBoundingBox().expand(this.getMotion()).grow(1.0D); @@ -190,7 +187,7 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst { ++this.ignoreTime; break; } - + if (this.owner != null && this.ticksExisted < 2 && this.ignoreEntity == null) { this.ignoreEntity = entity; this.ignoreTime = 3; @@ -209,9 +206,9 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst { */ if (raytraceresult.getType() != RayTraceResult.Type.MISS) { - if (raytraceresult.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)raytraceresult).getPos()).getBlock() == Blocks.NETHER_PORTAL) { - this.setPortal(((BlockRayTraceResult)raytraceresult).getPos()); - } else if (!net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, raytraceresult)){ + if (raytraceresult.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult) raytraceresult).getPos()).getBlock() == Blocks.NETHER_PORTAL) { + this.setPortal(((BlockRayTraceResult) raytraceresult).getPos()); + } else if (!net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, raytraceresult)) { this.onImpact(raytraceresult); } } @@ -221,21 +218,21 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst { double d1 = this.getY() + vec3d.y; double d2 = this.getZ() + vec3d.z; float f = MathHelper.sqrt(horizontalMag(vec3d)); - this.rotationYaw = (float)(MathHelper.atan2(vec3d.x, vec3d.z) * (double)(180F / (float)Math.PI)); + this.rotationYaw = (float) (MathHelper.atan2(vec3d.x, vec3d.z) * (double) (180F / (float) Math.PI)); - for(this.rotationPitch = (float)(MathHelper.atan2(vec3d.y, (double)f) * (double)(180F / (float)Math.PI)); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) { + for (this.rotationPitch = (float) (MathHelper.atan2(vec3d.y, (double) f) * (double) (180F / (float) Math.PI)); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) { ; } - while(this.rotationPitch - this.prevRotationPitch >= 180.0F) { + while (this.rotationPitch - this.prevRotationPitch >= 180.0F) { this.prevRotationPitch += 360.0F; } - while(this.rotationYaw - this.prevRotationYaw < -180.0F) { + while (this.rotationYaw - this.prevRotationYaw < -180.0F) { this.prevRotationYaw -= 360.0F; } - while(this.rotationYaw - this.prevRotationYaw >= 180.0F) { + while (this.rotationYaw - this.prevRotationYaw >= 180.0F) { this.prevRotationYaw += 360.0F; } @@ -243,7 +240,7 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst { this.rotationYaw = MathHelper.lerp(0.2F, this.prevRotationYaw, this.rotationYaw); float f1; if (this.isInWater()) { - for(int i = 0; i < 4; ++i) { + for (int i = 0; i < 4; ++i) { float f2 = 0.25F; this.world.addParticle(ParticleTypes.BUBBLE, d0 - vec3d.x * 0.25D, d1 - vec3d.y * 0.25D, d2 - vec3d.z * 0.25D, vec3d.x, vec3d.y, vec3d.z); } @@ -256,7 +253,7 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst { // Botania - no drag this.setMotion(vec3d.scale((double)f1)); if (!this.hasNoGravity()) { Vec3d vec3d1 = this.getMotion(); - this.setMotion(vec3d1.x, vec3d1.y - (double)this.getGravityVelocity(), vec3d1.z); + this.setMotion(vec3d1.x, vec3d1.y - (double) this.getGravityVelocity(), vec3d1.z); } this.setPosition(d0, d1, d2); @@ -267,22 +264,25 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst { setTicksExisted(getTicksExisted() + 1); superUpdate(); - if(!fake && isAlive() && !scanBeam) + if (!fake && isAlive() && !scanBeam) { ping(); + } ILensEffect lens = getLensInstance(); - if(lens != null) + if (lens != null) { lens.updateBurst(this, getSourceLens()); + } int mana = getMana(); - if(getTicksExisted() >= getMinManaLoss()) { + if (getTicksExisted() >= getMinManaLoss()) { accumulatedManaLoss += getManaLossPerTick(); int loss = (int) accumulatedManaLoss; setMana(mana - loss); accumulatedManaLoss -= loss; - if(getMana() <= 0) + if (getMana() <= 0) { remove(); + } } particles(); @@ -291,14 +291,15 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst { fullManaLastTick = getMana() == getStartingMana(); - if(scanBeam) { + if (scanBeam) { PositionProperties props = new PositionProperties(this); - if(propsList.isEmpty()) + if (propsList.isEmpty()) { propsList.add(props); - else { + } else { PositionProperties lastProps = propsList.get(propsList.size() - 1); - if(!props.coordsEqual(lastProps)) + if (!props.coordsEqual(lastProps)) { propsList.add(props); + } } } } @@ -328,13 +329,14 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst { this.noParticles = noParticles; int iterations = 0; - while(isAlive() && iterations < ConfigHandler.COMMON.spreaderTraceTime.get()) { + while (isAlive() && iterations < ConfigHandler.COMMON.spreaderTraceTime.get()) { tick(); iterations++; } - if(fake) + if (fake) { incrementFakeParticleTick(); + } return collidedTile; } @@ -352,8 +354,9 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst { ItemStack stack = getSourceLens(); CompoundNBT lensCmp = new CompoundNBT(); - if(!stack.isEmpty()) + if (!stack.isEmpty()) { lensCmp = stack.write(lensCmp); + } tag.put(TAG_LENS_STACK, lensCmp); BlockPos coords = getBurstSourceBlockPos(); @@ -368,7 +371,7 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst { UUID identity = getShooterUUID(); boolean hasShooter = identity != null; tag.putBoolean(TAG_HAS_SHOOTER, hasShooter); - if(hasShooter) { + if (hasShooter) { tag.putLong(TAG_SHOOTER_UUID_MOST, identity.getMostSignificantBits()); tag.putLong(TAG_SHOOTER_UUID_LEAST, identity.getLeastSignificantBits()); } @@ -387,9 +390,11 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst { CompoundNBT lensCmp = cmp.getCompound(TAG_LENS_STACK); ItemStack stack = ItemStack.read(lensCmp); - if(!stack.isEmpty()) + if (!stack.isEmpty()) { setSourceLens(stack); - else setSourceLens(ItemStack.EMPTY); + } else { + setSourceLens(ItemStack.EMPTY); + } int x = cmp.getInt(TAG_SPREADER_X); int y = cmp.getInt(TAG_SPREADER_Y); @@ -404,22 +409,25 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst { setBurstMotion(lastMotionX, lastMotionY, lastMotionZ); boolean hasShooter = cmp.getBoolean(TAG_HAS_SHOOTER); - if(hasShooter) { + if (hasShooter) { long most = cmp.getLong(TAG_SHOOTER_UUID_MOST); long least = cmp.getLong(TAG_SHOOTER_UUID_LEAST); UUID identity = getShooterUUID(); - if(identity == null || most != identity.getMostSignificantBits() || least != identity.getLeastSignificantBits()) + if (identity == null || most != identity.getMostSignificantBits() || least != identity.getLeastSignificantBits()) { shooterIdentity = new UUID(most, least); + } } } public void particles() { - if(!isAlive() || !world.isRemote) + if (!isAlive() || !world.isRemote) { return; + } ILensEffect lens = getLensInstance(); - if(lens != null && !lens.doParticles(this, getSourceLens())) + if (lens != null && !lens.doParticles(this, getSourceLens())) { return; + } int color = getColor(); float r = (color >> 16 & 0xFF) / 255F; @@ -428,20 +436,21 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst { float osize = getParticleSize(); float size = osize; - if(fake) { - if(getMana() == getStartingMana()) + if (fake) { + if (getMana() == getStartingMana()) { size = 2F; - else if(fullManaLastTick) + } else if (fullManaLastTick) { size = 4F; + } - if(!noParticles && shouldDoFakeParticles()) { + if (!noParticles && shouldDoFakeParticles()) { SparkleParticleData data = SparkleParticleData.fake(0.4F * size, r, g, b, 1); Botania.proxy.addParticleForce(world, data, getX(), getY(), getZ(), 0, 0, 0); } } else { boolean depth = !Botania.proxy.isClientPlayerWearingMonocle(); - if(ConfigHandler.CLIENT.subtlePowerSystem.get()) { + if (ConfigHandler.CLIENT.subtlePowerSystem.get()) { WispParticleData data = WispParticleData.wisp(0.1F * size, r, g, b, depth); world.addParticle(data, getX(), getY(), getZ(), (float) (Math.random() - 0.5F) * 0.02F, (float) (Math.random() - 0.5F) * 0.02F, (float) (Math.random() - 0.5F) * 0.01F); } else { @@ -481,16 +490,17 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst { currentPos = new Vector3(iterX, iterY, iterZ); diffVec = oldPos.subtract(currentPos); - if(getPersistentData().contains(ItemTinyPlanet.TAG_ORBIT)) + if (getPersistentData().contains(ItemTinyPlanet.TAG_ORBIT)) { break; - } while(Math.abs(diffVec.mag()) > distance); + } + } while (Math.abs(diffVec.mag()) > distance); WispParticleData data = WispParticleData.wisp(0.1F * size, or, og, ob, depth); world.addParticle(data, iterX, iterY, iterZ, (float) (Math.random() - 0.5F) * 0.06F, (float) (Math.random() - 0.5F) * 0.06F, (float) (Math.random() - 0.5F) * 0.06F); } } } - + public float getParticleSize() { return (float) getMana() / (float) getStartingMana(); } @@ -500,47 +510,54 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst { BlockPos pos = null; boolean dead = false; - if(rtr.getType() == RayTraceResult.Type.BLOCK) { + if (rtr.getType() == RayTraceResult.Type.BLOCK) { pos = ((BlockRayTraceResult) rtr).getPos(); TileEntity tile = world.getTileEntity(pos); BlockState state = world.getBlockState(pos); Block block = state.getBlock(); - if(block instanceof IManaCollisionGhost + if (block instanceof IManaCollisionGhost && ((IManaCollisionGhost) block).isGhost(state, world, pos) && !(block instanceof IManaTrigger) || block instanceof BushBlock - || block instanceof LeavesBlock) + || block instanceof LeavesBlock) { return; + } BlockPos coords = getBurstSourceBlockPos(); - if(tile != null && !tile.getPos().equals(coords)) + if (tile != null && !tile.getPos().equals(coords)) { collidedTile = tile; + } - if(tile == null || !tile.getPos().equals(coords)) { - if(!fake && !noParticles && (!world.isRemote || tile instanceof IClientManaHandler) && tile != null && tile instanceof IManaReceiver && ((IManaReceiver) tile).canRecieveManaFromBursts()) + if (tile == null || !tile.getPos().equals(coords)) { + if (!fake && !noParticles && (!world.isRemote || tile instanceof IClientManaHandler) && tile != null && tile instanceof IManaReceiver && ((IManaReceiver) tile).canRecieveManaFromBursts()) { onRecieverImpact((IManaReceiver) tile, tile.getPos()); + } - if(block instanceof IManaTrigger) + if (block instanceof IManaTrigger) { ((IManaTrigger) block).onBurstCollision(this, world, pos); + } boolean ghost = block instanceof IManaCollisionGhost; dead = !ghost; - if(ghost) + if (ghost) { return; + } } } ILensEffect lens = getLensInstance(); - if(lens != null) + if (lens != null) { dead = lens.collideBurst(this, rtr, collidedTile instanceof IManaReceiver - && ((IManaReceiver) collidedTile).canRecieveManaFromBursts(), dead, getSourceLens()); + && ((IManaReceiver) collidedTile).canRecieveManaFromBursts(), dead, getSourceLens()); + } - if(pos != null && !hasAlreadyCollidedAt(pos)) + if (pos != null && !hasAlreadyCollidedAt(pos)) { alreadyCollidedAt.add(pos); + } - if(dead && isAlive()) { - if(!fake && world.isRemote) { + if (dead && isAlive()) { + if (!fake && world.isRemote) { int color = getColor(); float r = (color >> 16 & 0xFF) / 255F; float g = (color >> 8 & 0xFF) / 255F; @@ -550,11 +567,12 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst { int maxMana = getStartingMana(); float size = (float) mana / (float) maxMana; - if(!ConfigHandler.CLIENT.subtlePowerSystem.get()) - for(int i = 0; i < 4; i++) { + if (!ConfigHandler.CLIENT.subtlePowerSystem.get()) { + for (int i = 0; i < 4; i++) { WispParticleData data = WispParticleData.wisp(0.15F * size, r, g, b); world.addParticle(data, getX(), getY(), getZ(), (float) (Math.random() - 0.5F) * 0.04F, (float) (Math.random() - 0.5F) * 0.04F, (float) (Math.random() - 0.5F) * 0.04F); } + } SparkleParticleData data = SparkleParticleData.sparkle((float) 4, r, g, b, 2); world.addParticle(data, getX(), getY(), getZ(), 0, 0, 0); } @@ -564,36 +582,43 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst { } private void onRecieverImpact(IManaReceiver tile, BlockPos pos) { - if (getPersistentData().getBoolean(LensWarp.TAG_WARPED)) + if (getPersistentData().getBoolean(LensWarp.TAG_WARPED)) { return; + } ILensEffect lens = getLensInstance(); int mana = getMana(); - - if(lens != null) { + + if (lens != null) { ItemStack stack = getSourceLens(); mana = lens.getManaToTransfer(this, this, stack, tile); } - - if(tile instanceof IManaCollector) + + if (tile instanceof IManaCollector) { mana *= ((IManaCollector) tile).getManaYieldMultiplier(this); + } tile.recieveMana(mana); - - if(tile instanceof IThrottledPacket) + + if (tile instanceof IThrottledPacket) { ((IThrottledPacket) tile).markDispatchable(); - else VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos); + } else { + VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos); + } } @Override public void remove() { super.remove(); - if(!fake) { + if (!fake) { TileEntity tile = getShooter(); - if(tile instanceof IManaSpreader) + if (tile instanceof IManaSpreader) { ((IManaSpreader) tile).setCanShoot(true); - } else setDeathTicksForFakeParticle(); + } + } else { + setDeathTicksForFakeParticle(); + } } private TileEntity getShooter() { @@ -710,8 +735,9 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst { private ILensEffect getLensInstance() { ItemStack lens = getSourceLens(); - if(!lens.isEmpty() && lens.getItem() instanceof ILensEffect) + if (!lens.isEmpty() && lens.getItem() instanceof ILensEffect) { return (ILensEffect) lens.getItem(); + } return null; } @@ -728,8 +754,9 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst { @Override public void setCollidedAt(BlockPos pos) { - if(!hasAlreadyCollidedAt(pos)) + if (!hasAlreadyCollidedAt(pos)) { alreadyCollidedAt.add(pos.toImmutable()); + } } @Override @@ -745,8 +772,9 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst { @Override public void ping() { TileEntity tile = getShooter(); - if(tile != null && tile instanceof IPingable) + if (tile != null && tile instanceof IPingable) { ((IPingable) tile).pingback(this, getShooterUUID()); + } } @Nonnull @@ -756,30 +784,33 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst { } protected boolean shouldDoFakeParticles() { - if (ConfigHandler.CLIENT.staticWandBeam.get()) + if (ConfigHandler.CLIENT.staticWandBeam.get()) { return true; + } TileEntity tile = getShooter(); return tile instanceof IManaSpreader && (getMana() != getStartingMana() && fullManaLastTick - || Math.abs(((IManaSpreader) tile).getBurstParticleTick() - getTicksExisted()) < 4); + || Math.abs(((IManaSpreader) tile).getBurstParticleTick() - getTicksExisted()) < 4); } private void incrementFakeParticleTick() { TileEntity tile = getShooter(); - if(tile instanceof IManaSpreader) { + if (tile instanceof IManaSpreader) { IManaSpreader spreader = (IManaSpreader) tile; - spreader.setBurstParticleTick(spreader.getBurstParticleTick()+2); - if(spreader.getLastBurstDeathTick() != -1 && spreader.getBurstParticleTick() > spreader.getLastBurstDeathTick()) + spreader.setBurstParticleTick(spreader.getBurstParticleTick() + 2); + if (spreader.getLastBurstDeathTick() != -1 && spreader.getBurstParticleTick() > spreader.getLastBurstDeathTick()) { spreader.setBurstParticleTick(0); + } } } private void setDeathTicksForFakeParticle() { BlockPos coords = getBurstSourceBlockPos(); TileEntity tile = world.getTileEntity(coords); - if(tile != null && tile instanceof IManaSpreader) + if (tile != null && tile instanceof IManaSpreader) { ((IManaSpreader) tile).setLastBurstDeathTick(getTicksExisted()); + } } public static class PositionProperties { @@ -802,7 +833,7 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst { } public boolean contentsEqual(World world) { - if(!world.isBlockLoaded(coords)) { + if (!world.isBlockLoaded(coords)) { invalid = true; return false; } diff --git a/src/main/java/vazkii/botania/common/entity/EntityManaStorm.java b/src/main/java/vazkii/botania/common/entity/EntityManaStorm.java index cbae49dbb..97cece735 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityManaStorm.java +++ b/src/main/java/vazkii/botania/common/entity/EntityManaStorm.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 25, 2015, 12:35:51 AM (GMT)] */ package vazkii.botania.common.entity; @@ -19,6 +17,7 @@ import net.minecraft.world.Explosion; import net.minecraft.world.World; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibMisc; @@ -26,8 +25,7 @@ import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; public class EntityManaStorm extends Entity { - @ObjectHolder(LibMisc.MOD_ID + ":mana_storm") - public static EntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":mana_storm") public static EntityType TYPE; private static final String TAG_TIME = "time"; private static final String TAG_BURSTS_FIRED = "burstsFired"; @@ -57,15 +55,16 @@ public class EntityManaStorm extends Entity { liveTime++; int diffTime = Math.max(1, 30 - (int) (liveTime / 45f)); - if(burstsFired < TOTAL_BURSTS && liveTime % diffTime == 0) { - if(!world.isRemote) + if (burstsFired < TOTAL_BURSTS && liveTime % diffTime == 0) { + if (!world.isRemote) { spawnBurst(); + } burstsFired++; } - if(burstsFired >= TOTAL_BURSTS) { + if (burstsFired >= TOTAL_BURSTS) { deathTime++; - if(deathTime >= DEATH_TIME) { + if (deathTime >= DEATH_TIME) { remove(); world.createExplosion(this, getX(), getY(), getZ(), 8F, true, Explosion.Mode.DESTROY); } diff --git a/src/main/java/vazkii/botania/common/entity/EntityPinkWither.java b/src/main/java/vazkii/botania/common/entity/EntityPinkWither.java index cb670b495..cf9c683a4 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityPinkWither.java +++ b/src/main/java/vazkii/botania/common/entity/EntityPinkWither.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 25, 2015, 5:49:28 PM (GMT)] */ package vazkii.botania.common.entity; @@ -24,13 +22,13 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; public class EntityPinkWither extends WitherEntity { - @ObjectHolder(LibMisc.MOD_ID + ":pink_wither") - public static EntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":pink_wither") public static EntityType TYPE; public EntityPinkWither(EntityType type, World world) { super(type, world); @@ -51,24 +49,26 @@ public class EntityPinkWither extends WitherEntity { public void livingTick() { super.livingTick(); - if(Math.random() < 0.1) - for(int j = 0; j < 3; ++j) { + if (Math.random() < 0.1) { + for (int j = 0; j < 3; ++j) { double d10 = getHeadX(j); double d2 = getHeadY(j); double d4 = getHeadZ(j); world.addParticle(ParticleTypes.HEART, d10 + rand.nextGaussian() * 0.30000001192092896D, d2 + rand.nextGaussian() * 0.30000001192092896D, d4 + rand.nextGaussian() * 0.30000001192092896D, 0.0D, 0.0D, 0.0D); } + } } @Override public void updateAITasks() { - if(ticksExisted % 20 == 0) + if (ticksExisted % 20 == 0) { heal(1.0F); + } } @Override protected boolean processInteract(PlayerEntity player, Hand hand) { - if(!player.isSneaking()) { + if (!player.isSneaking()) { player.startRiding(this); return true; } @@ -84,9 +84,9 @@ public class EntityPinkWither extends WitherEntity { if (p_82214_1_ <= 0) { return this.getX(); } else { - float f = (this.renderYawOffset + (float)(180 * (p_82214_1_ - 1))) * ((float)Math.PI / 180F); + float f = (this.renderYawOffset + (float) (180 * (p_82214_1_ - 1))) * ((float) Math.PI / 180F); float f1 = MathHelper.cos(f); - return this.getX() + (double)f1 * 1.3D; + return this.getX() + (double) f1 * 1.3D; } } @@ -98,9 +98,9 @@ public class EntityPinkWither extends WitherEntity { if (p_82213_1_ <= 0) { return this.getZ(); } else { - float f = (this.renderYawOffset + (float)(180 * (p_82213_1_ - 1))) * ((float)Math.PI / 180F); + float f = (this.renderYawOffset + (float) (180 * (p_82213_1_ - 1))) * ((float) Math.PI / 180F); float f1 = MathHelper.sin(f); - return this.getZ() + (double)f1 * 1.3D; + return this.getZ() + (double) f1 * 1.3D; } } diff --git a/src/main/java/vazkii/botania/common/entity/EntityPixie.java b/src/main/java/vazkii/botania/common/entity/EntityPixie.java index 99d4ddfff..e2593d6c0 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityPixie.java +++ b/src/main/java/vazkii/botania/common/entity/EntityPixie.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [? (GMT)] */ package vazkii.botania.common.entity; @@ -24,14 +22,14 @@ import net.minecraft.util.DamageSource; import net.minecraft.world.World; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.client.fx.SparkleParticleData; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; public class EntityPixie extends FlyingEntity { - @ObjectHolder(LibMisc.MOD_ID + ":pixie") - public static EntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":pixie") public static EntityType TYPE; private static final DataParameter PIXIE_TYPE = EntityDataManager.createKey(EntityPixie.class, DataSerializers.VARINT); private LivingEntity summoner = null; @@ -86,40 +84,45 @@ public class EntityPixie extends FlyingEntity { @Override protected void updateAITasks() { LivingEntity target = getAttackTarget(); - if(target != null) { + if (target != null) { double d0 = target.getX() + target.getWidth() / 2 - getX(); double d1 = target.getY() + target.getHeight() / 2 - getY(); double d2 = target.getZ() + target.getWidth() / 2 - getZ(); double d3 = d0 * d0 + d1 * d1 + d2 * d2; float mod = 0.45F; - if(getPixieType() == 1) + if (getPixieType() == 1) { mod = 0.1F; + } setMotion(d0 / d3 * mod, d1 / d3 * mod, d2 / d3 * mod); - if(Math.sqrt(d3) < 1F) { - if(summoner != null) { - if(summoner instanceof PlayerEntity) + if (Math.sqrt(d3) < 1F) { + if (summoner != null) { + if (summoner instanceof PlayerEntity) { target.attackEntityFrom(DamageSource.causePlayerDamage((PlayerEntity) summoner), damage); - else { + } else { target.attackEntityFrom(DamageSource.causeMobDamage(summoner), damage); } - } else target.attackEntityFrom(DamageSource.causeMobDamage(this), damage); - if(effect != null && !(target instanceof PlayerEntity)) + } else { + target.attackEntityFrom(DamageSource.causeMobDamage(this), damage); + } + if (effect != null && !(target instanceof PlayerEntity)) { target.addPotionEffect(effect); + } remove(); } } - renderYawOffset = rotationYaw = -((float)Math.atan2(getMotion().getX(), getMotion().getZ())) - * 180.0F / (float)Math.PI; + renderYawOffset = rotationYaw = -((float) Math.atan2(getMotion().getX(), getMotion().getZ())) + * 180.0F / (float) Math.PI; } @Override public boolean attackEntityFrom(@Nonnull DamageSource source, float amount) { - if(getPixieType() == 0 && source.getTrueSource() != summoner || getPixieType() == 1 && source.getTrueSource() instanceof PlayerEntity) + if (getPixieType() == 0 && source.getTrueSource() != summoner || getPixieType() == 1 && source.getTrueSource() instanceof PlayerEntity) { return super.attackEntityFrom(source, amount); + } return false; } @@ -127,28 +130,31 @@ public class EntityPixie extends FlyingEntity { public void baseTick() { super.baseTick(); - if(!world.isRemote - && (getAttackTarget() == null || ticksExisted > 200)) + if (!world.isRemote + && (getAttackTarget() == null || ticksExisted > 200)) { remove(); + } boolean dark = getPixieType() == 1; - if(world.isRemote) - for(int i = 0; i < 4; i++) { - float r = dark ? 0.1F : 1F; - float g = dark ? 0.025F : 0.25F; - float b = dark ? 0.09F : 0.9F; - SparkleParticleData data = SparkleParticleData.sparkle(0.1F + (float) Math.random() * 0.25F, r, g, b, 12); - world.addParticle(data, getX() + (Math.random() - 0.5) * 0.25, getY() + 0.5 + (Math.random() - 0.5) * 0.25, getZ() + (Math.random() - 0.5) * 0.25, 0, 0, 0); - } + if (world.isRemote) { + for (int i = 0; i < 4; i++) { + float r = dark ? 0.1F : 1F; + float g = dark ? 0.025F : 0.25F; + float b = dark ? 0.09F : 0.9F; + SparkleParticleData data = SparkleParticleData.sparkle(0.1F + (float) Math.random() * 0.25F, r, g, b, 12); + world.addParticle(data, getX() + (Math.random() - 0.5) * 0.25, getY() + 0.5 + (Math.random() - 0.5) * 0.25, getZ() + (Math.random() - 0.5) * 0.25, 0, 0, 0); + } + } } @Override public void remove() { - if(world != null && world.isRemote && getPixieType() == 0) - for(int i = 0; i < 12; i++) { - SparkleParticleData data = SparkleParticleData.sparkle(1F + (float) Math.random() * 0.25F, 1F, 0.25F, 0.9F, 5); - world.addParticle(data, getX() + (Math.random() - 0.5) * 0.25, getY() + 0.5 + (Math.random() - 0.5) * 0.25, getZ() + (Math.random() - 0.5) * 0.25, 0, 0, 0); - } + if (world != null && world.isRemote && getPixieType() == 0) { + for (int i = 0; i < 12; i++) { + SparkleParticleData data = SparkleParticleData.sparkle(1F + (float) Math.random() * 0.25F, 1F, 0.25F, 0.9F, 5); + world.addParticle(data, getX() + (Math.random() - 0.5) * 0.25, getY() + 0.5 + (Math.random() - 0.5) * 0.25, getZ() + (Math.random() - 0.5) * 0.25, 0, 0, 0); + } + } super.remove(); } @@ -161,4 +167,4 @@ public class EntityPixie extends FlyingEntity { public boolean canBeLeashedTo(PlayerEntity player) { return false; } -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/common/entity/EntityPoolMinecart.java b/src/main/java/vazkii/botania/common/entity/EntityPoolMinecart.java index 3cbe3ac20..ccca7d572 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityPoolMinecart.java +++ b/src/main/java/vazkii/botania/common/entity/EntityPoolMinecart.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 17, 2015, 6:36:43 PM (GMT)] */ package vazkii.botania.common.entity; @@ -30,6 +28,7 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.mana.IManaPool; import vazkii.botania.client.fx.WispParticleData; @@ -42,8 +41,7 @@ import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; public class EntityPoolMinecart extends AbstractMinecartEntity { - @ObjectHolder(LibMisc.MOD_ID + ":pool_minecart") - public static EntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":pool_minecart") public static EntityType TYPE; private static final int TRANSFER_RATE = 10000; private static final String TAG_MANA = "mana"; private static final DataParameter MANA = EntityDataManager.createKey(EntityPoolMinecart.class, DataSerializers.VARINT); @@ -97,7 +95,6 @@ public class EntityPoolMinecart extends AbstractMinecartEntity { this.setMotion(getMotion().mul(f, 0, f)); } - @Nonnull @Override public ItemStack getPickedResult(RayTraceResult target) { @@ -119,7 +116,7 @@ public class EntityPoolMinecart extends AbstractMinecartEntity { public void tick() { super.tick(); - if(world.isRemote) { + if (world.isRemote) { double particleChance = 1F - (double) getMana() / (double) TilePool.MAX_MANA * 0.1; int color = TilePool.PARTICLE_COLOR; float red = (color >> 16 & 0xFF) / 255F; @@ -128,7 +125,7 @@ public class EntityPoolMinecart extends AbstractMinecartEntity { double x = MathHelper.floor(getX()); double y = MathHelper.floor(getY()); double z = MathHelper.floor(getZ()); - if(Math.random() > particleChance) { + if (Math.random() > particleChance) { WispParticleData data = WispParticleData.wisp((float) Math.random() / 3F, red, green, blue, 2F); world.addParticle(data, x + 0.3 + Math.random() * 0.5, y + 0.85 + Math.random() * 0.25, z + Math.random(), 0, (float) Math.random() / 25F, 0); } @@ -139,42 +136,42 @@ public class EntityPoolMinecart extends AbstractMinecartEntity { public void moveMinecartOnRail(BlockPos pos) { super.moveMinecartOnRail(pos); - for(Direction dir : vazkii.botania.common.core.helper.MathHelper.HORIZONTALS) { + for (Direction dir : vazkii.botania.common.core.helper.MathHelper.HORIZONTALS) { BlockPos posP = pos.offset(dir); Block block = world.getBlockState(posP).getBlock(); - if(block == ModBlocks.pump) { + if (block == ModBlocks.pump) { BlockPos posP_ = posP.offset(dir); TileEntity tile = world.getTileEntity(posP_); TileEntity tile_ = world.getTileEntity(posP); TilePump pump = (TilePump) tile_; - if(tile instanceof IManaPool) { + if (tile instanceof IManaPool) { IManaPool pool = (IManaPool) tile; Direction pumpDir = world.getBlockState(posP).get(BlockStateProperties.HORIZONTAL_FACING); boolean did = false; boolean can = false; - if(pumpDir == dir) { // Pool -> Cart + if (pumpDir == dir) { // Pool -> Cart can = true; - if(!pump.hasRedstone) { + if (!pump.hasRedstone) { int cartMana = getMana(); int poolMana = pool.getCurrentMana(); int transfer = Math.min(TRANSFER_RATE, poolMana); int actualTransfer = Math.min(TilePool.MAX_MANA - cartMana, transfer); - if(actualTransfer > 0) { + if (actualTransfer > 0) { pool.recieveMana(-transfer); setMana(cartMana + actualTransfer); did = true; } } - } else if(pumpDir == dir.getOpposite()) { // Cart -> Pool + } else if (pumpDir == dir.getOpposite()) { // Cart -> Pool can = true; - if(!pump.hasRedstone && !pool.isFull()) { + if (!pump.hasRedstone && !pool.isFull()) { int cartMana = getMana(); int transfer = Math.min(TRANSFER_RATE, cartMana); - if(transfer > 0) { + if (transfer > 0) { pool.recieveMana(transfer); setMana(cartMana - transfer); did = true; @@ -182,14 +179,15 @@ public class EntityPoolMinecart extends AbstractMinecartEntity { } } - if(did) { + if (did) { VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, posP_); pump.hasCart = true; - if(!pump.active) + if (!pump.active) { pump.setActive(true); + } } - if(can) { + if (can) { pump.hasCartOnTop = true; pump.comparator = (int) ((double) getMana() / (double) TilePool.MAX_MANA * 15); // different from TilePool.calculateComparatorLevel, kept for compatibility } diff --git a/src/main/java/vazkii/botania/common/entity/EntitySignalFlare.java b/src/main/java/vazkii/botania/common/entity/EntitySignalFlare.java index 236e0d868..443cd5ff3 100644 --- a/src/main/java/vazkii/botania/common/entity/EntitySignalFlare.java +++ b/src/main/java/vazkii/botania/common/entity/EntitySignalFlare.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 3, 2014, 7:10:32 PM (GMT)] */ package vazkii.botania.common.entity; @@ -22,6 +20,7 @@ import net.minecraft.util.SoundEvents; import net.minecraft.world.World; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.client.fx.WispParticleData; import vazkii.botania.common.Botania; import vazkii.botania.common.lib.LibMisc; @@ -29,8 +28,7 @@ import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; public class EntitySignalFlare extends Entity { - @ObjectHolder(LibMisc.MOD_ID + ":signal_flare") - public static EntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":signal_flare") public static EntityType TYPE; private static final String COLOR_TAG = "color"; private static final String FIRED_Y_TAG = "firedY"; private static final DataParameter COLOR = EntityDataManager.createKey(EntitySignalFlare.class, DataSerializers.VARINT); @@ -53,26 +51,28 @@ public class EntitySignalFlare extends Entity { @Override public void baseTick() { super.baseTick(); - if(ticksExisted++ >= 100) + if (ticksExisted++ >= 100) { remove(); + } - if(!removed) { - if(ticksExisted % 10 == 0) + if (!removed) { + if (ticksExisted % 10 == 0) { playSound(SoundEvents.ENTITY_CREEPER_PRIMED, 1F, 1F); + } int color = getColor(); - if(color < 16 && color >= 0) { + if (color < 16 && color >= 0) { int hex = DyeColor.byId(color).colorValue; int r = (hex & 0xFF0000) >> 16; int g = (hex & 0xFF00) >> 8; int b = hex & 0xFF; - for(int i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { WispParticleData data = WispParticleData.wisp((float) Math.random() * 5 + 1F, r / 255F, g / 255F, b / 255F); Botania.proxy.addParticleForce(world, data, getX(), getY(), getZ() + 0.5, (float) (Math.random() - 0.5F), 10F * (float) Math.sqrt(256F / (256F - (float) getY())), (float) (Math.random() - 0.5F)); } - for(int i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) { WispParticleData data = WispParticleData.wisp((float) Math.random() * 15 + 8F, r / 255F, g / 255F, b / 255F); Botania.proxy.addParticleForce(world, data, getX() + 0.5, Math.min(256, getFiredAt() + Botania.proxy.getClientRenderDistance() * 16), getZ() + 0.5, (float) (Math.random() - 0.5F) * 8F, 0F, (float) (Math.random() - 0.5F) * 8F); } diff --git a/src/main/java/vazkii/botania/common/entity/EntitySpark.java b/src/main/java/vazkii/botania/common/entity/EntitySpark.java index 3e077fca0..90f5e2191 100644 --- a/src/main/java/vazkii/botania/common/entity/EntitySpark.java +++ b/src/main/java/vazkii/botania/common/entity/EntitySpark.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 21, 2014, 5:43:44 PM (GMT)] */ package vazkii.botania.common.entity; @@ -30,6 +28,7 @@ import net.minecraft.world.World; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.mana.IManaItem; import vazkii.botania.api.mana.IManaPool; @@ -45,6 +44,7 @@ import vazkii.botania.common.network.PacketBotaniaEffect; import vazkii.botania.common.network.PacketHandler; import javax.annotation.Nonnull; + import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -57,8 +57,7 @@ import java.util.WeakHashMap; import java.util.stream.Collectors; public class EntitySpark extends EntitySparkBase implements ISparkEntity { - @ObjectHolder(LibMisc.MOD_ID + ":spark") - public static EntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":spark") public static EntityType TYPE; private static final int TRANSFER_RATE = 1000; private static final String TAG_UPGRADE = "upgrade"; private static final DataParameter UPGRADE = EntityDataManager.createKey(EntitySpark.class, DataSerializers.VARINT); @@ -91,11 +90,12 @@ public class EntitySpark extends EntitySparkBase implements ISparkEntity { public void tick() { super.tick(); - if(world.isRemote) + if (world.isRemote) { return; + } ISparkAttachable tile = getAttachedTile(); - if(tile == null) { + if (tile == null) { dropAndKill(); return; } @@ -103,46 +103,51 @@ public class EntitySpark extends EntitySparkBase implements ISparkEntity { SparkUpgradeType upgrade = getUpgrade(); Collection transfers = getTransfers(); - switch(upgrade) { - case DISPERSIVE : { + switch (upgrade) { + case DISPERSIVE: { List players = SparkHelper.getEntitiesAround(PlayerEntity.class, world, getX(), getY() + (getHeight() / 2.0), getZ()); Map> receivingPlayers = new HashMap<>(); ItemStack input = new ItemStack(ModItems.spark); - for(PlayerEntity player : players) { + for (PlayerEntity player : players) { List stacks = new ArrayList<>(); stacks.addAll(player.inventory.mainInventory); stacks.addAll(player.inventory.armorInventory); IItemHandler inv = BotaniaAPI.internalHandler.getAccessoriesInventory(player); - for(int i = 0; i < inv.getSlots(); i++) + for (int i = 0; i < inv.getSlots(); i++) { stacks.add(inv.getStackInSlot(i)); + } - for(ItemStack stack : stacks) { - if(stack.isEmpty() || !(stack.getItem() instanceof IManaItem)) + for (ItemStack stack : stacks) { + if (stack.isEmpty() || !(stack.getItem() instanceof IManaItem)) { continue; + } IManaItem manaItem = (IManaItem) stack.getItem(); - if(manaItem.canReceiveManaFromItem(stack, input)) { + if (manaItem.canReceiveManaFromItem(stack, input)) { Map receivingStacks; boolean add = false; - if(!receivingPlayers.containsKey(player)) { + if (!receivingPlayers.containsKey(player)) { add = true; receivingStacks = new HashMap<>(); - } else receivingStacks = receivingPlayers.get(player); + } else { + receivingStacks = receivingPlayers.get(player); + } int recv = Math.min(getAttachedTile().getCurrentMana(), Math.min(TRANSFER_RATE, manaItem.getMaxMana(stack) - manaItem.getMana(stack))); - if(recv > 0) { + if (recv > 0) { receivingStacks.put(stack, recv); - if(add) + if (add) { receivingPlayers.put(player, receivingStacks); + } } } } } - if(!receivingPlayers.isEmpty()) { + if (!receivingPlayers.isEmpty()) { List keys = new ArrayList<>(receivingPlayers.keySet()); Collections.shuffle(keys); PlayerEntity player = keys.iterator().next(); @@ -158,42 +163,44 @@ public class EntitySpark extends EntitySparkBase implements ISparkEntity { break; } - case DOMINANT : { + case DOMINANT: { List validSparks = SparkHelper.getSparksAround(world, getX(), getY() + (getHeight() / 2), getZ(), getNetwork()) .filter(s -> { SparkUpgradeType otherUpgrade = s.getUpgrade(); return s != this && otherUpgrade == SparkUpgradeType.NONE && s.getAttachedTile() instanceof IManaPool; }) .collect(Collectors.toList()); - if(validSparks.size() > 0) + if (validSparks.size() > 0) { validSparks.get(world.rand.nextInt(validSparks.size())).registerTransfer(this); + } break; } - case RECESSIVE : { + case RECESSIVE: { SparkHelper.getSparksAround(world, getX(), getY() + (getHeight() / 2), getZ(), getNetwork()) .filter(s -> { SparkUpgradeType otherUpgrade = s.getUpgrade(); return s != this - && otherUpgrade != SparkUpgradeType.DOMINANT - && otherUpgrade != SparkUpgradeType.RECESSIVE - && otherUpgrade != SparkUpgradeType.ISOLATED; + && otherUpgrade != SparkUpgradeType.DOMINANT + && otherUpgrade != SparkUpgradeType.RECESSIVE + && otherUpgrade != SparkUpgradeType.ISOLATED; }) .forEach(transfers::add); break; } case NONE: - default: break; + default: + break; } - if(!transfers.isEmpty()) { + if (!transfers.isEmpty()) { int manaTotal = Math.min(TRANSFER_RATE * transfers.size(), tile.getCurrentMana()); int manaForEach = manaTotal / transfers.size(); int manaSpent = 0; - if(manaForEach > transfers.size()) { - for(ISparkEntity spark : transfers) { - if(spark.getAttachedTile() == null || spark.getAttachedTile().isFull() || spark.areIncomingTransfersDone()) { + if (manaForEach > transfers.size()) { + for (ISparkEntity spark : transfers) { + if (spark.getAttachedTile() == null || spark.getAttachedTile().isFull() || spark.areIncomingTransfersDone()) { manaTotal -= manaForEach; continue; } @@ -209,8 +216,9 @@ public class EntitySpark extends EntitySparkBase implements ISparkEntity { } } - if(removeTransferants > 0) + if (removeTransferants > 0) { removeTransferants--; + } filterTransfers(); } @@ -221,7 +229,7 @@ public class EntitySpark extends EntitySparkBase implements ISparkEntity { } public static void particleBeam(PlayerEntity player, Entity e1, Entity e2) { - if(e1 != null && e2 != null && !e1.world.isRemote) { + if (e1 != null && e2 != null && !e1.world.isRemote) { PacketHandler.sendTo((ServerPlayerEntity) player, new PacketBotaniaEffect(PacketBotaniaEffect.EffectType.SPARK_NET_INDICATOR, e1.getX(), e1.getY(), e1.getZ(), e1.getEntityId(), e2.getEntityId())); @@ -231,40 +239,44 @@ public class EntitySpark extends EntitySparkBase implements ISparkEntity { private void dropAndKill() { SparkUpgradeType upgrade = getUpgrade(); entityDropItem(new ItemStack(ModItems.spark), 0F); - if(upgrade != SparkUpgradeType.NONE) + if (upgrade != SparkUpgradeType.NONE) { entityDropItem(ItemSparkUpgrade.getByType(upgrade), 0F); + } remove(); } @Override public boolean processInitialInteract(PlayerEntity player, Hand hand) { ItemStack stack = player.getHeldItem(hand); - if(isAlive() && !stack.isEmpty()) { - if(world.isRemote) { + if (isAlive() && !stack.isEmpty()) { + if (world.isRemote) { boolean valid = stack.getItem() == ModItems.twigWand || stack.getItem() instanceof ItemSparkUpgrade || stack.getItem() == ModItems.phantomInk || stack.getItem() instanceof ItemDye; - if(valid) + if (valid) { player.swingArm(hand); + } return valid; } SparkUpgradeType upgrade = getUpgrade(); - if(stack.getItem() == ModItems.twigWand) { - if(player.isSneaking()) { - if(upgrade != SparkUpgradeType.NONE) { + if (stack.getItem() == ModItems.twigWand) { + if (player.isSneaking()) { + if (upgrade != SparkUpgradeType.NONE) { entityDropItem(ItemSparkUpgrade.getByType(upgrade), 0F); setUpgrade(SparkUpgradeType.NONE); transfers.clear(); removeTransferants = 2; - } else dropAndKill(); + } else { + dropAndKill(); + } return true; } else { SparkHelper.getSparksAround(world, getX(), getY() + (getHeight() / 2), getZ(), getNetwork()) .forEach(s -> particleBeam(player, this, (Entity) s)); return true; } - } else if(stack.getItem() instanceof ItemSparkUpgrade && upgrade == SparkUpgradeType.NONE) { + } else if (stack.getItem() instanceof ItemSparkUpgrade && upgrade == SparkUpgradeType.NONE) { setUpgrade(((ItemSparkUpgrade) stack.getItem()).type); stack.shrink(1); return true; @@ -273,7 +285,7 @@ public class EntitySpark extends EntitySparkBase implements ISparkEntity { return true; } else if (stack.getItem() instanceof ItemDye) { DyeColor color = ((ItemDye) stack.getItem()).color; - if(color != getNetwork()) { + if (color != getNetwork()) { setNetwork(color); stack.shrink(1); return true; @@ -308,8 +320,9 @@ public class EntitySpark extends EntitySparkBase implements ISparkEntity { int y = MathHelper.floor(getY()) - 1; int z = MathHelper.floor(getZ()); TileEntity tile = world.getTileEntity(new BlockPos(x, y, z)); - if(tile instanceof ISparkAttachable) + if (tile instanceof ISparkAttachable) { return (ISparkAttachable) tile; + } return null; } @@ -322,15 +335,16 @@ public class EntitySpark extends EntitySparkBase implements ISparkEntity { SparkUpgradeType supgr = spark.getUpgrade(); ISparkAttachable atile = spark.getAttachedTile(); - if(spark == this + if (spark == this || spark.areIncomingTransfersDone() || getNetwork() != spark.getNetwork() || atile == null || atile.isFull() || !(upgr == SparkUpgradeType.NONE && supgr == SparkUpgradeType.DOMINANT || upgr == SparkUpgradeType.RECESSIVE && (supgr == SparkUpgradeType.NONE || supgr == SparkUpgradeType.DISPERSIVE) - || !(atile instanceof IManaPool))) + || !(atile instanceof IManaPool))) { iter.remove(); + } } } @@ -346,8 +360,9 @@ public class EntitySpark extends EntitySparkBase implements ISparkEntity { @Override public void registerTransfer(ISparkEntity entity) { - if(hasTransfer(entity)) + if (hasTransfer(entity)) { return; + } transfers.add(entity); } @@ -364,9 +379,10 @@ public class EntitySpark extends EntitySparkBase implements ISparkEntity { @Override public boolean areIncomingTransfersDone() { ISparkAttachable tile = getAttachedTile(); - if(tile instanceof IManaPool) + if (tile instanceof IManaPool) { return removeTransferants > 0; - return tile != null && tile.areIncomingTranfersDone(); + } + return tile != null && tile.areIncomingTranfersDone(); } } diff --git a/src/main/java/vazkii/botania/common/entity/EntitySparkBase.java b/src/main/java/vazkii/botania/common/entity/EntitySparkBase.java index 017980ed0..15585e540 100644 --- a/src/main/java/vazkii/botania/common/entity/EntitySparkBase.java +++ b/src/main/java/vazkii/botania/common/entity/EntitySparkBase.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.common.entity; import net.minecraft.entity.Entity; @@ -10,41 +18,41 @@ import net.minecraft.network.datasync.EntityDataManager; import net.minecraft.world.World; public abstract class EntitySparkBase extends Entity { - private static final String TAG_INVIS = "invis"; - private static final String TAG_NETWORK = "network"; - private static final DataParameter NETWORK = EntityDataManager.createKey(EntitySparkBase.class, DataSerializers.VARINT); + private static final String TAG_INVIS = "invis"; + private static final String TAG_NETWORK = "network"; + private static final DataParameter NETWORK = EntityDataManager.createKey(EntitySparkBase.class, DataSerializers.VARINT); - public EntitySparkBase(EntityType type, World world) { - super(type, world); - } + public EntitySparkBase(EntityType type, World world) { + super(type, world); + } - @Override - protected void registerData() { - dataManager.register(NETWORK, 0); - } + @Override + protected void registerData() { + dataManager.register(NETWORK, 0); + } - public DyeColor getNetwork() { - return DyeColor.byId(dataManager.get(NETWORK)); - } + public DyeColor getNetwork() { + return DyeColor.byId(dataManager.get(NETWORK)); + } - public void setNetwork(DyeColor color) { - dataManager.set(NETWORK, color.getId()); - } + public void setNetwork(DyeColor color) { + dataManager.set(NETWORK, color.getId()); + } - @Override - public boolean canBeCollidedWith() { - return true; - } + @Override + public boolean canBeCollidedWith() { + return true; + } - @Override - protected void readAdditional(CompoundNBT compound) { - setInvisible(compound.getBoolean(TAG_INVIS)); - setNetwork(DyeColor.byId(compound.getInt(TAG_NETWORK))); - } + @Override + protected void readAdditional(CompoundNBT compound) { + setInvisible(compound.getBoolean(TAG_INVIS)); + setNetwork(DyeColor.byId(compound.getInt(TAG_NETWORK))); + } - @Override - protected void writeAdditional(CompoundNBT compound) { - compound.putBoolean(TAG_INVIS, isInvisible()); - compound.putInt(TAG_NETWORK, getNetwork().getId()); - } + @Override + protected void writeAdditional(CompoundNBT compound) { + compound.putBoolean(TAG_INVIS, isInvisible()); + compound.putInt(TAG_NETWORK, getNetwork().getId()); + } } diff --git a/src/main/java/vazkii/botania/common/entity/EntityThornChakram.java b/src/main/java/vazkii/botania/common/entity/EntityThornChakram.java index 702a22cda..6f6af32c8 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityThornChakram.java +++ b/src/main/java/vazkii/botania/common/entity/EntityThornChakram.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 25, 2015, 6:47:35 PM (GMT)] */ package vazkii.botania.common.entity; @@ -40,6 +38,7 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibMisc; @@ -51,8 +50,7 @@ import javax.annotation.Nonnull; _interface = IRendersAsItem.class ) public class EntityThornChakram extends ThrowableEntity implements IRendersAsItem { - @ObjectHolder(LibMisc.MOD_ID + ":thorn_chakram") - public static EntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":thorn_chakram") public static EntityType TYPE; private static final DataParameter BOUNCES = EntityDataManager.createKey(EntityThornChakram.class, DataSerializers.VARINT); private static final DataParameter FLARE = EntityDataManager.createKey(EntityThornChakram.class, DataSerializers.BOOLEAN); @@ -95,7 +93,7 @@ public class EntityThornChakram extends ThrowableEntity implements IRendersAsIte super.tick(); - if(!bounced) { + if (!bounced) { // Reset the drag applied by super setMotion(old); } @@ -103,31 +101,33 @@ public class EntityThornChakram extends ThrowableEntity implements IRendersAsIte bounced = false; // Returning motion - if(isReturning()) { + if (isReturning()) { Entity thrower = getThrower(); - if(thrower != null) { + if (thrower != null) { Vector3 motion = Vector3.fromEntityCenter(thrower).subtract(Vector3.fromEntityCenter(this)).normalize(); setMotion(motion.toVec3D()); } } // Client FX - if(world.isRemote && isFire()) { + if (world.isRemote && isFire()) { double r = 0.1; double m = 0.1; - for(int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { world.addParticle(ParticleTypes.FLAME, getX() + r * (Math.random() - 0.5), getY() + r * (Math.random() - 0.5), getZ() + r * (Math.random() - 0.5), m * (Math.random() - 0.5), m * (Math.random() - 0.5), m * (Math.random() - 0.5)); + } } // Server state control - if(!world.isRemote && (getTimesBounced() >= MAX_BOUNCES || ticksExisted > 60)) { + if (!world.isRemote && (getTimesBounced() >= MAX_BOUNCES || ticksExisted > 60)) { LivingEntity thrower = getThrower(); - if(thrower == null) { + if (thrower == null) { dropAndKill(); } else { setEntityToReturnTo(thrower.getEntityId()); - if(getDistanceSq(thrower) < 2) + if (getDistanceSq(thrower) < 2) { dropAndKill(); + } } } } @@ -147,18 +147,20 @@ public class EntityThornChakram extends ThrowableEntity implements IRendersAsIte @Override protected void onImpact(@Nonnull RayTraceResult pos) { - if(isReturning()) + if (isReturning()) { return; + } switch (pos.getType()) { case BLOCK: { BlockRayTraceResult rtr = (BlockRayTraceResult) pos; Block block = world.getBlockState(rtr.getPos()).getBlock(); - if(block instanceof BushBlock || block instanceof LeavesBlock) + if (block instanceof BushBlock || block instanceof LeavesBlock) { return; + } int bounces = getTimesBounced(); - if(bounces < MAX_BOUNCES) { + if (bounces < MAX_BOUNCES) { Vector3 currentMovementVec = new Vector3(getMotion()); Direction dir = rtr.getFace(); Vector3 normalVector = new Vector3(dir.getXOffset(), dir.getYOffset(), dir.getZOffset()).normalize(); @@ -167,30 +169,33 @@ public class EntityThornChakram extends ThrowableEntity implements IRendersAsIte setMotion(movementVec.toVec3D()); bounced = true; - if(!world.isRemote) + if (!world.isRemote) { setTimesBounced(getTimesBounced() + 1); + } } break; } case ENTITY: { EntityRayTraceResult rtr = (EntityRayTraceResult) pos; - if(!world.isRemote && rtr.getEntity() instanceof LivingEntity && rtr.getEntity() != getThrower()) { + if (!world.isRemote && rtr.getEntity() instanceof LivingEntity && rtr.getEntity() != getThrower()) { LivingEntity thrower = getThrower(); rtr.getEntity().attackEntityFrom(thrower != null ? thrower instanceof PlayerEntity - ? DamageSource.causeThrownDamage(this, thrower) - : DamageSource.causeMobDamage(thrower) + ? DamageSource.causeThrownDamage(this, thrower) + : DamageSource.causeMobDamage(thrower) : DamageSource.GENERIC, 12); - if(isFire()) + if (isFire()) { rtr.getEntity().setFire(5); - else if(world.rand.nextInt(3) == 0) + } else if (world.rand.nextInt(3) == 0) { ((LivingEntity) rtr.getEntity()).addPotionEffect(new EffectInstance(Effects.POISON, 60, 0)); + } } break; } - default: break; + default: + break; } } @@ -230,7 +235,7 @@ public class EntityThornChakram extends ThrowableEntity implements IRendersAsIte @Override public void writeAdditional(CompoundNBT compound) { super.writeAdditional(compound); - if(!stack.isEmpty()) { + if (!stack.isEmpty()) { compound.put("fly_stack", stack.write(new CompoundNBT())); } compound.putBoolean("flare", isFire()); @@ -239,7 +244,7 @@ public class EntityThornChakram extends ThrowableEntity implements IRendersAsIte @Override public void readAdditional(CompoundNBT compound) { super.readAdditional(compound); - if(compound.contains("fly_stack")) { + if (compound.contains("fly_stack")) { stack = ItemStack.read(compound.getCompound("fly_stack")); } setFire(compound.getBoolean("flare")); diff --git a/src/main/java/vazkii/botania/common/entity/EntityThrowableCopy.java b/src/main/java/vazkii/botania/common/entity/EntityThrowableCopy.java index 7ab0e8ba4..93799629b 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityThrowableCopy.java +++ b/src/main/java/vazkii/botania/common/entity/EntityThrowableCopy.java @@ -1,7 +1,13 @@ +/* + * This class is 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 + */ package vazkii.botania.common.entity; -import java.util.UUID; -import javax.annotation.Nullable; import net.minecraft.block.Blocks; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; @@ -24,6 +30,10 @@ import net.minecraft.world.server.ServerWorld; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import javax.annotation.Nullable; + +import java.util.UUID; + public abstract class EntityThrowableCopy extends Entity implements IProjectile { private int xTile = -1; private int yTile = -1; @@ -45,7 +55,7 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile } protected EntityThrowableCopy(EntityType p_i48542_1_, LivingEntity p_i48542_2_, World p_i48542_3_) { - this(p_i48542_1_, p_i48542_2_.getX(), p_i48542_2_.getEyeY() - (double)0.1F, p_i48542_2_.getZ(), p_i48542_3_); + this(p_i48542_1_, p_i48542_2_.getX(), p_i48542_2_.getEyeY() - (double) 0.1F, p_i48542_2_.getZ(), p_i48542_3_); this.owner = p_i48542_2_; this.ownerId = p_i48542_2_.getUniqueID(); } @@ -68,10 +78,10 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile * Sets throwable heading based on an entity that's throwing it */ public void shoot(Entity p_184538_1_, float p_184538_2_, float p_184538_3_, float p_184538_4_, float p_184538_5_, float p_184538_6_) { - float f = -MathHelper.sin(p_184538_3_ * ((float)Math.PI / 180F)) * MathHelper.cos(p_184538_2_ * ((float)Math.PI / 180F)); - float f1 = -MathHelper.sin((p_184538_2_ + p_184538_4_) * ((float)Math.PI / 180F)); - float f2 = MathHelper.cos(p_184538_3_ * ((float)Math.PI / 180F)) * MathHelper.cos(p_184538_2_ * ((float)Math.PI / 180F)); - this.shoot((double)f, (double)f1, (double)f2, p_184538_5_, p_184538_6_); + float f = -MathHelper.sin(p_184538_3_ * ((float) Math.PI / 180F)) * MathHelper.cos(p_184538_2_ * ((float) Math.PI / 180F)); + float f1 = -MathHelper.sin((p_184538_2_ + p_184538_4_) * ((float) Math.PI / 180F)); + float f2 = MathHelper.cos(p_184538_3_ * ((float) Math.PI / 180F)) * MathHelper.cos(p_184538_2_ * ((float) Math.PI / 180F)); + this.shoot((double) f, (double) f1, (double) f2, p_184538_5_, p_184538_6_); Vec3d vec3d = p_184538_1_.getMotion(); this.setMotion(this.getMotion().add(vec3d.x, p_184538_1_.onGround ? 0.0D : vec3d.y, vec3d.z)); } @@ -80,11 +90,11 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction. */ public void shoot(double p_70186_1_, double p_70186_3_, double p_70186_5_, float p_70186_7_, float p_70186_8_) { - Vec3d vec3d = (new Vec3d(p_70186_1_, p_70186_3_, p_70186_5_)).normalize().add(this.rand.nextGaussian() * (double)0.0075F * (double)p_70186_8_, this.rand.nextGaussian() * (double)0.0075F * (double)p_70186_8_, this.rand.nextGaussian() * (double)0.0075F * (double)p_70186_8_).scale((double)p_70186_7_); + Vec3d vec3d = (new Vec3d(p_70186_1_, p_70186_3_, p_70186_5_)).normalize().add(this.rand.nextGaussian() * (double) 0.0075F * (double) p_70186_8_, this.rand.nextGaussian() * (double) 0.0075F * (double) p_70186_8_, this.rand.nextGaussian() * (double) 0.0075F * (double) p_70186_8_).scale((double) p_70186_7_); this.setMotion(vec3d); float f = MathHelper.sqrt(horizontalMag(vec3d)); - this.rotationYaw = (float)(MathHelper.atan2(vec3d.x, vec3d.z) * (double)(180F / (float)Math.PI)); - this.rotationPitch = (float)(MathHelper.atan2(vec3d.y, (double)f) * (double)(180F / (float)Math.PI)); + this.rotationYaw = (float) (MathHelper.atan2(vec3d.x, vec3d.z) * (double) (180F / (float) Math.PI)); + this.rotationPitch = (float) (MathHelper.atan2(vec3d.y, (double) f) * (double) (180F / (float) Math.PI)); this.prevRotationYaw = this.rotationYaw; this.prevRotationPitch = this.rotationPitch; } @@ -97,8 +107,8 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile this.setMotion(p_70016_1_, p_70016_3_, p_70016_5_); if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { float f = MathHelper.sqrt(p_70016_1_ * p_70016_1_ + p_70016_5_ * p_70016_5_); - this.rotationYaw = (float)(MathHelper.atan2(p_70016_1_, p_70016_5_) * (double)(180F / (float)Math.PI)); - this.rotationPitch = (float)(MathHelper.atan2(p_70016_3_, (double)f) * (double)(180F / (float)Math.PI)); + this.rotationYaw = (float) (MathHelper.atan2(p_70016_1_, p_70016_5_) * (double) (180F / (float) Math.PI)); + this.rotationPitch = (float) (MathHelper.atan2(p_70016_3_, (double) f) * (double) (180F / (float) Math.PI)); this.prevRotationYaw = this.rotationYaw; this.prevRotationPitch = this.rotationPitch; } @@ -116,12 +126,12 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile if (this.inGround) { this.inGround = false; - this.setMotion(this.getMotion().mul((double)(this.rand.nextFloat() * 0.2F), (double)(this.rand.nextFloat() * 0.2F), (double)(this.rand.nextFloat() * 0.2F))); + this.setMotion(this.getMotion().mul((double) (this.rand.nextFloat() * 0.2F), (double) (this.rand.nextFloat() * 0.2F), (double) (this.rand.nextFloat() * 0.2F))); } AxisAlignedBB axisalignedbb = this.getBoundingBox().expand(this.getMotion()).grow(1.0D); - for(Entity entity : this.world.getEntitiesInAABBexcluding(this, axisalignedbb, (p_213881_0_) -> { + for (Entity entity : this.world.getEntitiesInAABBexcluding(this, axisalignedbb, (p_213881_0_) -> { return !p_213881_0_.isSpectator() && p_213881_0_.canBeCollidedWith(); })) { if (entity == this.ignoreEntity) { @@ -144,9 +154,9 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile } if (raytraceresult.getType() != RayTraceResult.Type.MISS) { - if (raytraceresult.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)raytraceresult).getPos()).getBlock() == Blocks.NETHER_PORTAL) { - this.setPortal(((BlockRayTraceResult)raytraceresult).getPos()); - } else if (!net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, raytraceresult)){ + if (raytraceresult.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult) raytraceresult).getPos()).getBlock() == Blocks.NETHER_PORTAL) { + this.setPortal(((BlockRayTraceResult) raytraceresult).getPos()); + } else if (!net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, raytraceresult)) { this.onImpact(raytraceresult); } } @@ -156,21 +166,21 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile double d1 = this.getY() + vec3d.y; double d2 = this.getZ() + vec3d.z; float f = MathHelper.sqrt(horizontalMag(vec3d)); - this.rotationYaw = (float)(MathHelper.atan2(vec3d.x, vec3d.z) * (double)(180F / (float)Math.PI)); + this.rotationYaw = (float) (MathHelper.atan2(vec3d.x, vec3d.z) * (double) (180F / (float) Math.PI)); - for(this.rotationPitch = (float)(MathHelper.atan2(vec3d.y, (double)f) * (double)(180F / (float)Math.PI)); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) { + for (this.rotationPitch = (float) (MathHelper.atan2(vec3d.y, (double) f) * (double) (180F / (float) Math.PI)); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) { ; } - while(this.rotationPitch - this.prevRotationPitch >= 180.0F) { + while (this.rotationPitch - this.prevRotationPitch >= 180.0F) { this.prevRotationPitch += 360.0F; } - while(this.rotationYaw - this.prevRotationYaw < -180.0F) { + while (this.rotationYaw - this.prevRotationYaw < -180.0F) { this.prevRotationYaw -= 360.0F; } - while(this.rotationYaw - this.prevRotationYaw >= 180.0F) { + while (this.rotationYaw - this.prevRotationYaw >= 180.0F) { this.prevRotationYaw += 360.0F; } @@ -178,7 +188,7 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile this.rotationYaw = MathHelper.lerp(0.2F, this.prevRotationYaw, this.rotationYaw); float f1; if (this.isInWater()) { - for(int i = 0; i < 4; ++i) { + for (int i = 0; i < 4; ++i) { float f2 = 0.25F; this.world.addParticle(ParticleTypes.BUBBLE, d0 - vec3d.x * 0.25D, d1 - vec3d.y * 0.25D, d2 - vec3d.z * 0.25D, vec3d.x, vec3d.y, vec3d.z); } @@ -188,10 +198,10 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile f1 = 0.99F; } - this.setMotion(vec3d.scale((double)f1)); + this.setMotion(vec3d.scale((double) f1)); if (!this.hasNoGravity()) { Vec3d vec3d1 = this.getMotion(); - this.setMotion(vec3d1.x, vec3d1.y - (double)this.getGravityVelocity(), vec3d1.z); + this.setMotion(vec3d1.x, vec3d1.y - (double) this.getGravityVelocity(), vec3d1.z); } this.setPosition(d0, d1, d2); @@ -213,7 +223,7 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile p_213281_1_.putInt("xTile", this.xTile); p_213281_1_.putInt("yTile", this.yTile); p_213281_1_.putInt("zTile", this.zTile); - p_213281_1_.putByte("shake", (byte)this.throwableShake); + p_213281_1_.putByte("shake", (byte) this.throwableShake); p_213281_1_.putBoolean("inGround", this.inGround); if (this.ownerId != null) { p_213281_1_.put("owner", NBTUtil.writeUniqueId(this.ownerId)); @@ -240,9 +250,9 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile @Nullable public LivingEntity getThrower() { if ((this.owner == null || this.owner.removed) && this.ownerId != null && this.world instanceof ServerWorld) { - Entity entity = ((ServerWorld)this.world).getEntityByUuid(this.ownerId); + Entity entity = ((ServerWorld) this.world).getEntityByUuid(this.ownerId); if (entity instanceof LivingEntity) { - this.owner = (LivingEntity)entity; + this.owner = (LivingEntity) entity; } else { this.owner = null; } diff --git a/src/main/java/vazkii/botania/common/entity/EntityThrownItem.java b/src/main/java/vazkii/botania/common/entity/EntityThrownItem.java index 9405b4829..67b2e1061 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityThrownItem.java +++ b/src/main/java/vazkii/botania/common/entity/EntityThrownItem.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [? (GMT)] */ package vazkii.botania.common.entity; @@ -26,16 +24,17 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.List; import java.util.Optional; public class EntityThrownItem extends ItemEntity { - @ObjectHolder(LibMisc.MOD_ID + ":thrown_item") - public static EntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":thrown_item") public static EntityType TYPE; public EntityThrownItem(EntityType type, World world) { super(type, world); @@ -75,9 +74,7 @@ public class EntityThrownItem extends ItemEntity { RayTraceResult ray = world.rayTraceBlocks(new RayTraceContext(vec3, vec31, RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, this)); - - if (!world.isRemote) - { + if (!world.isRemote) { Entity entity = null; List list = world.getEntitiesWithinAABBExcludingEntity(this, getBoundingBox().offset(getMotion().scale(2)).grow(2)); double d0 = 0.0D; @@ -99,21 +96,16 @@ public class EntityThrownItem extends ItemEntity { } } - if (entity != null) - { + if (entity != null) { ray = new EntityRayTraceResult(entity); } } - if (ray != null) - { + if (ray != null) { if (ray.getType() == RayTraceResult.Type.BLOCK - && world.getBlockState(((BlockRayTraceResult) ray).getPos()).getBlock() == Blocks.NETHER_PORTAL) - { + && world.getBlockState(((BlockRayTraceResult) ray).getPos()).getBlock() == Blocks.NETHER_PORTAL) { setPortal(((BlockRayTraceResult) ray).getPos()); - } - else - { + } else { if (ray.getType() == RayTraceResult.Type.ENTITY) { ((EntityRayTraceResult) ray).getEntity().attackEntityFrom(DamageSource.MAGIC, 2.0F); if (!world.isRemote) { diff --git a/src/main/java/vazkii/botania/common/entity/EntityVineBall.java b/src/main/java/vazkii/botania/common/entity/EntityVineBall.java index e561d05f1..08788eb18 100644 --- a/src/main/java/vazkii/botania/common/entity/EntityVineBall.java +++ b/src/main/java/vazkii/botania/common/entity/EntityVineBall.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 26, 2014, 7:32:16 PM (GMT)] */ package vazkii.botania.common.entity; import com.google.common.collect.ImmutableMap; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.VineBlock; @@ -35,11 +34,13 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.Map; @OnlyIn( @@ -47,8 +48,7 @@ import java.util.Map; _interface = IRendersAsItem.class ) public class EntityVineBall extends ThrowableEntity implements IRendersAsItem { - @ObjectHolder(LibMisc.MOD_ID + ":vine_ball") - public static EntityType TYPE; + @ObjectHolder(LibMisc.MOD_ID + ":vine_ball") public static EntityType TYPE; private static final DataParameter GRAVITY = EntityDataManager.createKey(EntityVineBall.class, DataSerializers.FLOAT); private static final Map propMap = ImmutableMap.of(Direction.NORTH, VineBlock.NORTH, Direction.SOUTH, VineBlock.SOUTH, @@ -81,8 +81,8 @@ public class EntityVineBall extends ThrowableEntity implements IRendersAsItem { @OnlyIn(Dist.CLIENT) @Override public void handleStatusUpdate(byte id) { - if(id == 3) { - for(int j = 0; j < 16; j++) { + if (id == 3) { + for (int j = 0; j < 16; j++) { world.addParticle(new ItemParticleData(ParticleTypes.ITEM, new ItemStack(ModItems.vineBall)), getX(), getY(), getZ(), Math.random() * 0.2 - 0.1, Math.random() * 0.25, Math.random() * 0.2 - 0.1); } } @@ -90,32 +90,36 @@ public class EntityVineBall extends ThrowableEntity implements IRendersAsItem { @Override protected void onImpact(@Nonnull RayTraceResult rtr) { - if(!world.isRemote) { - if(rtr.getType() == RayTraceResult.Type.BLOCK) { + if (!world.isRemote) { + if (rtr.getType() == RayTraceResult.Type.BLOCK) { Direction dir = ((BlockRayTraceResult) rtr).getFace(); - if(dir.getAxis() != Direction.Axis.Y) { + if (dir.getAxis() != Direction.Axis.Y) { BlockPos pos = ((BlockRayTraceResult) rtr).getPos().offset(dir); boolean first = true; - while(pos.getY() > 0) { + while (pos.getY() > 0) { BlockState state = world.getBlockState(pos); Block block = state.getBlock(); - if(block.isAir(state, world, pos)) { + if (block.isAir(state, world, pos)) { BlockState stateSet = ModBlocks.solidVines.getDefaultState().with(propMap.get(dir.getOpposite()), true); - - if(first && !stateSet.isValidPosition(world, pos)) break; + + if (first && !stateSet.isValidPosition(world, pos)) { + break; + } first = false; - + world.setBlockState(pos, stateSet); world.playEvent(2001, pos, Block.getStateId(stateSet)); pos = pos.down(); - } else break; + } else { + break; + } } } } - this.world.setEntityState(this, (byte)3); + this.world.setEntityState(this, (byte) 3); remove(); } } diff --git a/src/main/java/vazkii/botania/common/entity/ModEntities.java b/src/main/java/vazkii/botania/common/entity/ModEntities.java index 304f4c330..d5f1c02c5 100644 --- a/src/main/java/vazkii/botania/common/entity/ModEntities.java +++ b/src/main/java/vazkii/botania/common/entity/ModEntities.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 26, 2014, 4:11:03 PM (GMT)] */ package vazkii.botania.common.entity; @@ -15,6 +13,7 @@ import net.minecraft.entity.EntityType; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.common.block.tile.TileLightRelay.EntityPlayerMover; import vazkii.botania.common.lib.LibEntityNames; import vazkii.botania.common.lib.LibMisc; diff --git a/src/main/java/vazkii/botania/common/integration/corporea/WrappedIInventory.java b/src/main/java/vazkii/botania/common/integration/corporea/WrappedIInventory.java index 2647c92af..52cf65970 100644 --- a/src/main/java/vazkii/botania/common/integration/corporea/WrappedIInventory.java +++ b/src/main/java/vazkii/botania/common/integration/corporea/WrappedIInventory.java @@ -1,15 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 - * */ package vazkii.botania.common.integration.corporea; import net.minecraft.item.ItemStack; + import vazkii.botania.api.corporea.CorporeaRequest; import vazkii.botania.api.corporea.ICorporeaSpark; import vazkii.botania.api.corporea.IWrappedInventory; @@ -49,20 +49,22 @@ public class WrappedIInventory extends WrappedInventoryBase { ItemStack stackAt = inv.handler.getStackInSlot(i); // WARNING: this code is very similar in all implementations of // IWrappedInventory - keep it synch - if(request.matcher.isStackValid(stackAt)) { + if (request.matcher.isStackValid(stackAt)) { int rem = Math.min(stackAt.getCount(), request.count == -1 ? stackAt.getCount() : request.count); request.foundItems += stackAt.getCount(); - if(rem > 0) { + if (rem > 0) { stacks.add(inv.handler.extractItem(i, rem, !doit)); - if(doit && spark != null) + if (doit && spark != null) { spark.onItemExtracted(stackAt); + } } request.extractedItems += rem; - if(request.count != -1) + if (request.count != -1) { request.count -= rem; + } } } diff --git a/src/main/java/vazkii/botania/common/integration/corporea/WrappedInventoryBase.java b/src/main/java/vazkii/botania/common/integration/corporea/WrappedInventoryBase.java index 79a86629e..46fcf1718 100644 --- a/src/main/java/vazkii/botania/common/integration/corporea/WrappedInventoryBase.java +++ b/src/main/java/vazkii/botania/common/integration/corporea/WrappedInventoryBase.java @@ -1,17 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 - * */ package vazkii.botania.common.integration.corporea; import net.minecraft.item.ItemStack; -import vazkii.botania.api.corporea.CorporeaHelper; -import vazkii.botania.api.corporea.ICorporeaRequestMatcher; + import vazkii.botania.api.corporea.ICorporeaSpark; import vazkii.botania.api.corporea.IWrappedInventory; @@ -36,7 +34,7 @@ public abstract class WrappedInventoryBase implements IWrappedInventory { List stacks = new ArrayList(); int additionalStacks = stack.getCount() / stack.getMaxStackSize(); int lastStackSize = stack.getCount() % stack.getMaxStackSize(); - if(additionalStacks > 0) { + if (additionalStacks > 0) { ItemStack fullStack = stack.copy(); fullStack.setCount(stack.getMaxStackSize()); for (int i = 0; i < additionalStacks; i++) { diff --git a/src/main/java/vazkii/botania/common/integration/curios/CurioIntegration.java b/src/main/java/vazkii/botania/common/integration/curios/CurioIntegration.java index da7224848..7fa521c06 100644 --- a/src/main/java/vazkii/botania/common/integration/curios/CurioIntegration.java +++ b/src/main/java/vazkii/botania/common/integration/curios/CurioIntegration.java @@ -1,7 +1,16 @@ +/* + * This class is 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 + */ package vazkii.botania.common.integration.curios; import com.google.common.collect.Multimap; import com.mojang.blaze3d.matrix.MatrixStack; + import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.ai.attributes.AttributeModifier; @@ -14,11 +23,14 @@ import net.minecraftforge.fml.InterModComms; import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent; import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.wrapper.CombinedInvWrapper; + import org.apache.commons.lang3.tuple.ImmutableTriple; + import top.theillusivec4.curios.api.CuriosAPI; import top.theillusivec4.curios.api.capability.CuriosCapability; import top.theillusivec4.curios.api.capability.ICurio; import top.theillusivec4.curios.api.imc.CurioIMCMessage; + import vazkii.botania.common.capability.SimpleCapProvider; import vazkii.botania.common.core.handler.EquipmentHandler; import vazkii.botania.common.core.handler.ModSounds; diff --git a/src/main/java/vazkii/botania/common/item/IFloatingFlowerVariant.java b/src/main/java/vazkii/botania/common/item/IFloatingFlowerVariant.java index c2e96e1c7..e4810dd5b 100644 --- a/src/main/java/vazkii/botania/common/item/IFloatingFlowerVariant.java +++ b/src/main/java/vazkii/botania/common/item/IFloatingFlowerVariant.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 13, 2016, 6:02:31 PM (GMT)] */ package vazkii.botania.common.item; import net.minecraft.item.ItemStack; + import vazkii.botania.api.item.IFloatingFlower.IslandType; public interface IFloatingFlowerVariant { diff --git a/src/main/java/vazkii/botania/common/item/Item16Colors.java b/src/main/java/vazkii/botania/common/item/Item16Colors.java index 3e522886b..12dcc88fc 100644 --- a/src/main/java/vazkii/botania/common/item/Item16Colors.java +++ b/src/main/java/vazkii/botania/common/item/Item16Colors.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 19, 2014, 4:09:57 PM (GMT)] */ package vazkii.botania.common.item; diff --git a/src/main/java/vazkii/botania/common/item/ItemAncientWill.java b/src/main/java/vazkii/botania/common/item/ItemAncientWill.java index b0f77137d..dfdd51e90 100644 --- a/src/main/java/vazkii/botania/common/item/ItemAncientWill.java +++ b/src/main/java/vazkii/botania/common/item/ItemAncientWill.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 30, 2015, 10:59:45 PM (GMT)] */ package vazkii.botania.common.item; @@ -19,6 +17,7 @@ import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.item.IAncientWillContainer; import java.util.List; diff --git a/src/main/java/vazkii/botania/common/item/ItemAstrolabe.java b/src/main/java/vazkii/botania/common/item/ItemAstrolabe.java index a451a2feb..ae3c914b1 100644 --- a/src/main/java/vazkii/botania/common/item/ItemAstrolabe.java +++ b/src/main/java/vazkii/botania/common/item/ItemAstrolabe.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [26/10/2016, 18:23:11 (GMT)] */ package vazkii.botania.common.item; @@ -28,7 +26,6 @@ import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceContext; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; @@ -36,6 +33,7 @@ import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.item.IBlockProvider; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.client.core.handler.ItemsRemainingRenderHandler; @@ -44,6 +42,7 @@ import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.item.rod.ItemExchangeRod; import javax.annotation.Nonnull; + import java.util.ArrayList; import java.util.List; @@ -63,14 +62,14 @@ public class ItemAstrolabe extends Item { BlockState state = ctx.getWorld().getBlockState(ctx.getPos()); PlayerEntity player = ctx.getPlayer(); - if(player != null && player.isSneaking()) { - if(setBlock(stack, state)) { + if (player != null && player.isSneaking()) { + if (setBlock(stack, state)) { displayRemainderCounter(player, stack); return ActionResultType.SUCCESS; } - } else if(player != null) { + } else if (player != null) { boolean did = placeAllBlocks(stack, player); - if(did) { + if (did) { displayRemainderCounter(player, stack); } @@ -84,13 +83,13 @@ public class ItemAstrolabe extends Item { @Override public ActionResult onItemRightClick(World worldIn, PlayerEntity playerIn, @Nonnull Hand hand) { ItemStack stack = playerIn.getHeldItem(hand); - if(playerIn.isSneaking()) { + if (playerIn.isSneaking()) { int size = getSize(stack); int newSize = size == 11 ? 3 : size + 2; setSize(stack, newSize); ItemsRemainingRenderHandler.set(stack, newSize + "x" + newSize); worldIn.playSound(playerIn, playerIn.getPosition(), SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.PLAYERS, 0.5F, 1F); - + return ActionResult.success(stack); } @@ -99,50 +98,56 @@ public class ItemAstrolabe extends Item { public boolean placeAllBlocks(ItemStack stack, PlayerEntity player) { List blocksToPlace = getBlocksToPlace(stack, player); - if(!hasBlocks(stack, player, blocksToPlace)) + if (!hasBlocks(stack, player, blocksToPlace)) { return false; + } int size = getSize(stack); int cost = size * 320; - if(!ManaItemHandler.requestManaExact(stack, player, cost, false)) + if (!ManaItemHandler.requestManaExact(stack, player, cost, false)) { return false; - + } + ItemStack stackToPlace = new ItemStack(getBlock(stack)); - for(BlockPos coords : blocksToPlace) + for (BlockPos coords : blocksToPlace) { placeBlockAndConsume(player, stack, stackToPlace, coords); + } ManaItemHandler.requestManaExact(stack, player, cost, true); - + return true; } private void placeBlockAndConsume(PlayerEntity player, ItemStack requestor, ItemStack blockToPlace, BlockPos coords) { - if(blockToPlace.isEmpty()) + if (blockToPlace.isEmpty()) { return; - + } + Block block = Block.getBlockFromItem(blockToPlace.getItem()); BlockState state = block.getDefaultState(); player.world.setBlockState(coords, state); player.world.playEvent(2001, coords, Block.getStateId(state)); - if(player.abilities.isCreativeMode) + if (player.abilities.isCreativeMode) { return; - + } + List stacksToCheck = new ArrayList<>(); - for(int i = 0; i < player.inventory.getSizeInventory(); i++) { + for (int i = 0; i < player.inventory.getSizeInventory(); i++) { ItemStack stackInSlot = player.inventory.getStackInSlot(i); - if(!stackInSlot.isEmpty() && stackInSlot.getItem() == blockToPlace.getItem()) { + if (!stackInSlot.isEmpty() && stackInSlot.getItem() == blockToPlace.getItem()) { stackInSlot.shrink(1); return; } - if (!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof IBlockProvider) + if (!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof IBlockProvider) { stacksToCheck.add(stackInSlot); + } } - for(ItemStack providerStack : stacksToCheck) { + for (ItemStack providerStack : stacksToCheck) { IBlockProvider prov = (IBlockProvider) providerStack.getItem(); - - if(prov.provideBlock(player, requestor, providerStack, block, false)) { + + if (prov.provideBlock(player, requestor, providerStack, block, false)) { prov.provideBlock(player, requestor, providerStack, block, true); return; } @@ -150,12 +155,13 @@ public class ItemAstrolabe extends Item { } public static boolean hasBlocks(ItemStack stack, PlayerEntity player, List blocks) { - if (player.abilities.isCreativeMode) + if (player.abilities.isCreativeMode) { return true; + } Block block = getBlock(stack); ItemStack reqStack = new ItemStack(block); - + int required = blocks.size(); int current = 0; List stacksToCheck = new ArrayList<>(); @@ -163,23 +169,27 @@ public class ItemAstrolabe extends Item { ItemStack stackInSlot = player.inventory.getStackInSlot(i); if (!stackInSlot.isEmpty() && stackInSlot.getItem() == reqStack.getItem()) { current += stackInSlot.getCount(); - if (current >= required) + if (current >= required) { return true; + } } - if(!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof IBlockProvider) + if (!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof IBlockProvider) { stacksToCheck.add(stackInSlot); + } } - - for(ItemStack providerStack : stacksToCheck) { + + for (ItemStack providerStack : stacksToCheck) { IBlockProvider prov = (IBlockProvider) providerStack.getItem(); int count = prov.getBlockCount(player, stack, providerStack, block); - if(count == -1) + if (count == -1) { return true; - - current += count; - - if(current >= required) + } + + current += count; + + if (current >= required) { return true; + } } return false; @@ -188,61 +198,64 @@ public class ItemAstrolabe extends Item { public static List getBlocksToPlace(ItemStack stack, PlayerEntity player) { List coords = new ArrayList<>(); BlockRayTraceResult rtr = ToolCommons.raytraceFromEntity(player, 5, true); - if(rtr.getType() == RayTraceResult.Type.BLOCK) { + if (rtr.getType() == RayTraceResult.Type.BLOCK) { BlockPos pos = rtr.getPos(); BlockState state = player.world.getBlockState(pos); - if(state.getMaterial().isReplaceable()) + if (state.getMaterial().isReplaceable()) { pos = pos.down(); + } int range = (getSize(stack) ^ 1) / 2; Direction dir = rtr.getFace(); Direction rotationDir = Direction.fromAngle(player.rotationYaw); - + boolean pitchedVertically = player.rotationPitch > 70 || player.rotationPitch < -70; - + boolean axisX = rotationDir.getAxis() == Axis.X; boolean axisZ = rotationDir.getAxis() == Axis.Z; - + int xOff = axisZ || pitchedVertically ? range : 0; int yOff = pitchedVertically ? 0 : range; int zOff = axisX || pitchedVertically ? range : 0; - - for(int x = -xOff; x < xOff + 1; x++) - for(int y = 0; y < yOff * 2 + 1; y++) { - for(int z = -zOff; z < zOff + 1; z++) { + + for (int x = -xOff; x < xOff + 1; x++) { + for (int y = 0; y < yOff * 2 + 1; y++) { + for (int z = -zOff; z < zOff + 1; z++) { int xp = pos.getX() + x + dir.getXOffset(); int yp = pos.getY() + y + dir.getYOffset(); int zp = pos.getZ() + z + dir.getZOffset(); BlockPos newPos = new BlockPos(xp, yp, zp); BlockState state1 = player.world.getBlockState(newPos); - if(player.world.getWorldBorder().contains(newPos) - && (state1.isAir(player.world, newPos) || state1.getMaterial().isReplaceable())) + if (player.world.getWorldBorder().contains(newPos) + && (state1.isAir(player.world, newPos) || state1.getMaterial().isReplaceable())) { coords.add(newPos); + } } } + } } return coords; } - public void displayRemainderCounter(PlayerEntity player, ItemStack stack) { Block block = getBlock(stack); int count = ItemExchangeRod.getInventoryItemCount(player, stack, block); - if(!player.world.isRemote) + if (!player.world.isRemote) { ItemsRemainingRenderHandler.set(new ItemStack(block), count); + } } private boolean setBlock(ItemStack stack, BlockState state) { - if(!state.isAir()) { + if (!state.isAir()) { ItemNBTHelper.setCompound(stack, TAG_BLOCKSTATE, NBTUtil.writeBlockState(state)); return true; } return false; - } + } private static void setSize(ItemStack stack, int size) { ItemNBTHelper.setInt(stack, TAG_SIZE, size | 1); @@ -267,8 +280,9 @@ public class ItemAstrolabe extends Item { int size = getSize(stack); tip.add(new StringTextComponent(size + " x " + size)); - if (block != Blocks.AIR) + if (block != Blocks.AIR) { tip.add(new ItemStack(block).getDisplayName().applyTextStyle(TextFormatting.GRAY)); + } } } diff --git a/src/main/java/vazkii/botania/common/item/ItemAutocraftingHalo.java b/src/main/java/vazkii/botania/common/item/ItemAutocraftingHalo.java index 3eb843375..a9831049a 100644 --- a/src/main/java/vazkii/botania/common/item/ItemAutocraftingHalo.java +++ b/src/main/java/vazkii/botania/common/item/ItemAutocraftingHalo.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 1, 2015, 2:23:26 AM (GMT)] */ package vazkii.botania.common.item; @@ -17,6 +15,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.items.IItemHandler; + import vazkii.botania.client.lib.LibResources; public class ItemAutocraftingHalo extends ItemCraftingHalo { @@ -31,12 +30,13 @@ public class ItemAutocraftingHalo extends ItemCraftingHalo { public void inventoryTick(ItemStack stack, World world, Entity entity, int pos, boolean equipped) { super.inventoryTick(stack, world, entity, pos, equipped); - if(entity instanceof PlayerEntity && !equipped) { + if (entity instanceof PlayerEntity && !equipped) { PlayerEntity player = (PlayerEntity) entity; IItemHandler inv = getFakeInv(player); - for(int i = 1; i < SEGMENTS; i++) + for (int i = 1; i < SEGMENTS; i++) { tryCraft(player, stack, i, false, inv, false); + } } } diff --git a/src/main/java/vazkii/botania/common/item/ItemBaubleBox.java b/src/main/java/vazkii/botania/common/item/ItemBaubleBox.java index 4c81e97c9..7b515f77a 100644 --- a/src/main/java/vazkii/botania/common/item/ItemBaubleBox.java +++ b/src/main/java/vazkii/botania/common/item/ItemBaubleBox.java @@ -1,19 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [25/11/2015, 19:46:11 (GMT)] */ package vazkii.botania.common.item; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.inventory.container.SimpleNamedContainerProvider; import net.minecraft.item.Item; @@ -21,10 +17,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.INBT; import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.Hand; -import net.minecraft.util.text.ITextComponent; import net.minecraft.world.World; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.ICapabilityProvider; @@ -34,6 +28,7 @@ import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemStackHandler; + import vazkii.botania.client.gui.box.ContainerBaubleBox; import vazkii.botania.common.core.handler.EquipmentHandler; @@ -58,9 +53,10 @@ public class ItemBaubleBox extends Item { @Nonnull @Override public ItemStack insertItem(int slot, @Nonnull ItemStack toInsert, boolean simulate) { - if(!toInsert.isEmpty()) { - if(EquipmentHandler.instance.isAccessory(toInsert)) + if (!toInsert.isEmpty()) { + if (EquipmentHandler.instance.isAccessory(toInsert)) { return super.insertItem(slot, toInsert, simulate); + } } return toInsert; } @@ -87,7 +83,7 @@ public class ItemBaubleBox extends Item { @Nonnull @Override public ActionResult onItemRightClick(World world, PlayerEntity player, @Nonnull Hand hand) { - if(!world.isRemote) { + if (!world.isRemote) { ItemStack stack = player.getHeldItem(hand); INamedContainerProvider container = new SimpleNamedContainerProvider((w, p, pl) -> new ContainerBaubleBox(w, p, stack), stack.getDisplayName()); NetworkHooks.openGui((ServerPlayerEntity) player, container, b -> { diff --git a/src/main/java/vazkii/botania/common/item/ItemBlackHoleTalisman.java b/src/main/java/vazkii/botania/common/item/ItemBlackHoleTalisman.java index 5af33ee9b..222e0348a 100644 --- a/src/main/java/vazkii/botania/common/item/ItemBlackHoleTalisman.java +++ b/src/main/java/vazkii/botania/common/item/ItemBlackHoleTalisman.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 31, 2015, 11:04:12 PM (GMT)] */ package vazkii.botania.common.item; @@ -37,6 +35,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.registries.ForgeRegistries; + import vazkii.botania.api.item.IBlockProvider; import vazkii.botania.client.core.handler.ItemsRemainingRenderHandler; import vazkii.botania.common.core.helper.ItemNBTHelper; @@ -45,6 +44,7 @@ import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; import javax.annotation.Nullable; + import java.util.List; public class ItemBlackHoleTalisman extends Item implements IBlockProvider { @@ -62,7 +62,7 @@ public class ItemBlackHoleTalisman extends Item implements IBlockProvider { @Override public ActionResult onItemRightClick(World world, PlayerEntity player, @Nonnull Hand hand) { ItemStack stack = player.getHeldItem(hand); - if(getBlock(stack) != null && player.isSneaking()) { + if (getBlock(stack) != null && player.isSneaking()) { ItemNBTHelper.setBoolean(stack, TAG_ACTIVE, !ItemNBTHelper.getBoolean(stack, TAG_ACTIVE, false)); player.playSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, 0.3F, 0.1F); return ActionResult.success(stack); @@ -86,24 +86,26 @@ public class ItemBlackHoleTalisman extends Item implements IBlockProvider { } else { Block bBlock = getBlock(stack); - if(bBlock == null) + if (bBlock == null) { return ActionResultType.PASS; + } TileEntity tile = world.getTileEntity(pos); - if(tile != null && tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side).isPresent()) { - if(!world.isRemote) { + if (tile != null && tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side).isPresent()) { + if (!world.isRemote) { tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side).ifPresent(inv -> { ItemStack toAdd = new ItemStack(bBlock); int maxSize = toAdd.getMaxStackSize(); toAdd.setCount(remove(stack, maxSize)); ItemStack remainder = ItemHandlerHelper.insertItemStacked(inv, toAdd, false); - if(!remainder.isEmpty()) + if (!remainder.isEmpty()) { add(stack, remainder.getCount()); + } }); } return ActionResultType.SUCCESS; } else { - if(player == null || player.abilities.isCreativeMode || getBlockCount(stack) > 0) { + if (player == null || player.abilities.isCreativeMode || getBlockCount(stack) > 0) { ItemStack toUse = new ItemStack(bBlock); ActionResultType result = PlayerHelper.substituteUse(ctx, toUse); @@ -122,27 +124,29 @@ public class ItemBlackHoleTalisman extends Item implements IBlockProvider { @Override public void inventoryTick(ItemStack itemstack, World world, Entity entity, int slot, boolean selected) { Block block = getBlock(itemstack); - if(!entity.world.isRemote && ItemNBTHelper.getBoolean(itemstack, TAG_ACTIVE, false) && block != null && entity instanceof PlayerEntity) { + if (!entity.world.isRemote && ItemNBTHelper.getBoolean(itemstack, TAG_ACTIVE, false) && block != null && entity instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity) entity; int highest = -1; int[] counts = new int[player.inventory.getSizeInventory() - player.inventory.armorInventory.size()]; - for(int i = 0; i < counts.length; i++) { + for (int i = 0; i < counts.length; i++) { ItemStack stack = player.inventory.getStackInSlot(i); - if(stack.isEmpty()) { + if (stack.isEmpty()) { continue; } - if(block.asItem() == stack.getItem()) { + if (block.asItem() == stack.getItem()) { counts[i] = stack.getCount(); - if(highest == -1) + if (highest == -1) { highest = i; - else highest = counts[i] > counts[highest] && highest > 8 ? i : highest; + } else { + highest = counts[i] > counts[highest] && highest > 8 ? i : highest; + } } } - if(highest == -1) { + if (highest == -1) { /*ItemStack heldItem = player.inventory.getItemStack(); if(hasFreeSlot && (heldItem == null || Item.getItemFromBlock(block) == heldItem.getItem() || heldItem.getItemDamage() != meta)) { ItemStack stack = new ItemStack(block, remove(itemstack, 64), meta); @@ -151,12 +155,13 @@ public class ItemBlackHoleTalisman extends Item implements IBlockProvider { }*/ // Used to keep one stack, disabled for now } else { - for(int i = 0; i < counts.length; i++) { + for (int i = 0; i < counts.length; i++) { int count = counts[i]; // highest is used to keep one stack, disabled for now - if(/*i == highest || */count == 0) + if (/*i == highest || */count == 0) { continue; + } add(itemstack, count); player.inventory.setInventorySlotContents(i, ItemStack.EMPTY); @@ -181,7 +186,7 @@ public class ItemBlackHoleTalisman extends Item implements IBlockProvider { ItemStack bstack = new ItemStack(block); ITextComponent cand = super.getDisplayName(stack); - if(!bstack.isEmpty()) { + if (!bstack.isEmpty()) { cand.appendText(" ("); cand.appendSibling(bstack.getDisplayName().applyTextStyle(TextFormatting.GREEN)); cand.appendText(")"); @@ -194,8 +199,9 @@ public class ItemBlackHoleTalisman extends Item implements IBlockProvider { @Override public ItemStack getContainerItem(@Nonnull ItemStack itemStack) { int count = getBlockCount(itemStack); - if(count == 0) + if (count == 0) { return ItemStack.EMPTY; + } int extract = Math.min(64, count); ItemStack copy = itemStack.copy(); @@ -211,7 +217,7 @@ public class ItemBlackHoleTalisman extends Item implements IBlockProvider { } private boolean setBlock(ItemStack stack, Block block) { - if(block.asItem() != Items.AIR && (getBlock(stack) == null || getBlockCount(stack) == 0)) { + if (block.asItem() != Items.AIR && (getBlock(stack) == null || getBlockCount(stack) == 0)) { ItemNBTHelper.setString(stack, TAG_BLOCK_NAME, block.getRegistryName().toString()); return true; } @@ -227,14 +233,16 @@ public class ItemBlackHoleTalisman extends Item implements IBlockProvider { @OnlyIn(Dist.CLIENT) public void addInformation(ItemStack stack, World world, List stacks, ITooltipFlag flags) { Block block = getBlock(stack); - if(block != null) { + if (block != null) { int count = getBlockCount(stack); stacks.add(new StringTextComponent(Integer.toString(count) + " ").appendSibling(new ItemStack(block).getDisplayName()).applyTextStyle(TextFormatting.GRAY)); } - if(ItemNBTHelper.getBoolean(stack, TAG_ACTIVE, false)) + if (ItemNBTHelper.getBoolean(stack, TAG_ACTIVE, false)) { stacks.add(new TranslationTextComponent("botaniamisc.active")); - else stacks.add(new TranslationTextComponent("botaniamisc.inactive")); + } else { + stacks.add(new TranslationTextComponent("botaniamisc.inactive")); + } } private static void setCount(ItemStack stack, int count) { @@ -255,7 +263,7 @@ public class ItemBlackHoleTalisman extends Item implements IBlockProvider { @Nullable public static Block getBlock(ItemStack stack) { ResourceLocation id = ResourceLocation.tryCreate(getBlockName(stack)); - if(id != null) { + if (id != null) { return ForgeRegistries.BLOCKS.getValue(id); } return null; @@ -268,11 +276,12 @@ public class ItemBlackHoleTalisman extends Item implements IBlockProvider { @Override public boolean provideBlock(PlayerEntity player, ItemStack requestor, ItemStack stack, Block block, boolean doit) { Block stored = getBlock(stack); - if(stored == block) { + if (stored == block) { int count = getBlockCount(stack); - if(count > 0) { - if(doit) + if (count > 0) { + if (doit) { setCount(stack, count - 1); + } return true; } } @@ -283,8 +292,9 @@ public class ItemBlackHoleTalisman extends Item implements IBlockProvider { @Override public int getBlockCount(PlayerEntity player, ItemStack requestor, ItemStack stack, Block block) { Block stored = getBlock(stack); - if(stored == block) + if (stored == block) { return getBlockCount(stack); + } return 0; } diff --git a/src/main/java/vazkii/botania/common/item/ItemBlackLotus.java b/src/main/java/vazkii/botania/common/item/ItemBlackLotus.java index 4f17170c4..f7d74b483 100644 --- a/src/main/java/vazkii/botania/common/item/ItemBlackLotus.java +++ b/src/main/java/vazkii/botania/common/item/ItemBlackLotus.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 18, 2015, 12:17:10 AM (GMT)] */ package vazkii.botania.common.item; @@ -21,6 +19,7 @@ import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.item.IManaDissolvable; import vazkii.botania.api.mana.IManaPool; @@ -46,13 +45,14 @@ public class ItemBlackLotus extends Item implements IManaDissolvable { @Override public void onDissolveTick(IManaPool pool, ItemStack stack, ItemEntity item) { - if(pool.isFull() || pool.getCurrentMana() == 0) + if (pool.isFull() || pool.getCurrentMana() == 0) { return; + } TileEntity tile = (TileEntity) pool; boolean t2 = stack.getItem() == ModItems.blackerLotus; - if(!item.world.isRemote) { + if (!item.world.isRemote) { pool.recieveMana(t2 ? MANA_PER_T2 : MANA_PER); stack.shrink(1); VanillaPacketDispatcher.dispatchTEToNearbyPlayers(item.world, tile.getPos()); diff --git a/src/main/java/vazkii/botania/common/item/ItemBottledMana.java b/src/main/java/vazkii/botania/common/item/ItemBottledMana.java index 31d89a250..045735916 100644 --- a/src/main/java/vazkii/botania/common/item/ItemBottledMana.java +++ b/src/main/java/vazkii/botania/common/item/ItemBottledMana.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 27, 2014, 2:41:19 AM (GMT)] */ package vazkii.botania.common.item; @@ -23,7 +21,6 @@ import net.minecraft.item.UseAction; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Effects; import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; import net.minecraft.util.DamageSource; import net.minecraft.util.Hand; import net.minecraft.util.ResourceLocation; @@ -38,12 +35,14 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.server.ServerLifecycleHooks; + import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.entity.EntityPixie; import vazkii.botania.common.entity.EntitySignalFlare; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.List; import java.util.Random; @@ -58,55 +57,62 @@ public class ItemBottledMana extends Item { } public void effect(ItemStack stack, LivingEntity living, int id) { - switch(id) { - case 0 : { // Random motion + switch (id) { + case 0: { // Random motion living.setMotion((Math.random() - 0.5) * 3, living.getMotion().getY(), (Math.random() - 0.5) * 3); break; } - case 1 : { // Water - if(!living.world.isRemote && !living.world.getDimension().doesWaterVaporize()) + case 1: { // Water + if (!living.world.isRemote && !living.world.getDimension().doesWaterVaporize()) { living.world.setBlockState(new BlockPos(living), Blocks.WATER.getDefaultState()); + } break; } - case 2 : { // Set on Fire - if(!living.world.isRemote) + case 2: { // Set on Fire + if (!living.world.isRemote) { living.setFire(4); + } break; } - case 3 : { // Mini Explosion - if(!living.world.isRemote) + case 3: { // Mini Explosion + if (!living.world.isRemote) { living.world.createExplosion(null, living.getX(), living.getY(), living.getZ(), 0.25F, Explosion.Mode.NONE); + } break; } - case 4 : { // Mega Jump - if(!living.world.getDimension().isNether()) { - if(!living.world.isRemote) + case 4: { // Mega Jump + if (!living.world.getDimension().isNether()) { + if (!living.world.isRemote) { living.addPotionEffect(new EffectInstance(Effects.RESISTANCE, 300, 5)); + } living.setMotion(living.getMotion().getX(), 6, living.getMotion().getZ()); } break; } - case 5 : { // Randomly set HP - if(!living.world.isRemote) + case 5: { // Randomly set HP + if (!living.world.isRemote) { living.setHealth(living.world.rand.nextInt(19) + 1); + } break; } - case 6 : { // Lots O' Hearts - if(!living.world.isRemote) + case 6: { // Lots O' Hearts + if (!living.world.isRemote) { living.addPotionEffect(new EffectInstance(Effects.ABSORPTION, 20 * 60 * 2, 9)); + } break; } - case 7 : { // All your inventory is belong to us - if(!living.world.isRemote && living instanceof PlayerEntity) { + case 7: { // All your inventory is belong to us + if (!living.world.isRemote && living instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity) living; - for(int i = 0; i < player.inventory.getSizeInventory(); i++) { + for (int i = 0; i < player.inventory.getSizeInventory(); i++) { ItemStack stackAt = player.inventory.getStackInSlot(i); - if(stackAt != stack) { - if(!stackAt.isEmpty()) + if (stackAt != stack) { + if (!stackAt.isEmpty()) { player.entityDropItem(stackAt, 0); + } player.inventory.setInventorySlotContents(i, ItemStack.EMPTY); } } @@ -114,19 +120,19 @@ public class ItemBottledMana extends Item { break; } - case 8 : { // Break your neck + case 8: { // Break your neck living.rotationPitch = (float) Math.random() * 360F; living.rotationYaw = (float) Math.random() * 180F; break; } - case 9 : { // Highest Possible + case 9: { // Highest Possible int x = MathHelper.floor(living.getX()); int z = MathHelper.floor(living.getZ()); - for(int i = 256; i > 0; i--) { + for (int i = 256; i > 0; i--) { Block block = living.world.getBlockState(new BlockPos(x, i, z)).getBlock(); - if(!block.isAir(living.world.getBlockState(new BlockPos(x, i, z)), living.world, new BlockPos(x, i, z))) { - if(living instanceof ServerPlayerEntity) { + if (!block.isAir(living.world.getBlockState(new BlockPos(x, i, z)), living.world, new BlockPos(x, i, z))) { + if (living instanceof ServerPlayerEntity) { ServerPlayerEntity mp = (ServerPlayerEntity) living; mp.connection.setPlayerLocation(living.getX(), i, living.getZ(), living.rotationYaw, living.rotationPitch); } @@ -136,18 +142,20 @@ public class ItemBottledMana extends Item { break; } - case 10 : { // HYPERSPEEEEEED - if(!living.world.isRemote) + case 10: { // HYPERSPEEEEEED + if (!living.world.isRemote) { living.addPotionEffect(new EffectInstance(Effects.SPEED, 60, 200)); + } break; } - case 11 : { // Night Vision - if(!living.world.isRemote) + case 11: { // Night Vision + if (!living.world.isRemote) { living.addPotionEffect(new EffectInstance(Effects.NIGHT_VISION, 6000, 0)); + } break; } - case 12 : { // Flare - if(!living.world.isRemote) { + case 12: { // Flare + if (!living.world.isRemote) { EntitySignalFlare flare = new EntitySignalFlare(living.world); flare.setPosition(living.getX(), living.getY(), living.getZ()); flare.setColor(living.world.rand.nextInt(16)); @@ -157,31 +165,33 @@ public class ItemBottledMana extends Item { int range = 5; List entities = living.world.getEntitiesWithinAABB(LivingEntity.class, new AxisAlignedBB(living.getX() - range, living.getY() - range, living.getZ() - range, living.getX() + range, living.getY() + range, living.getZ() + range)); - for(LivingEntity entity : entities) - if(entity != living && (!(entity instanceof PlayerEntity) || ServerLifecycleHooks.getCurrentServer() == null || ServerLifecycleHooks.getCurrentServer().isPVPEnabled())) + for (LivingEntity entity : entities) { + if (entity != living && (!(entity instanceof PlayerEntity) || ServerLifecycleHooks.getCurrentServer() == null || ServerLifecycleHooks.getCurrentServer().isPVPEnabled())) { entity.addPotionEffect(new EffectInstance(Effects.SLOWNESS, 50, 5)); + } + } } break; } - case 13 : { // Pixie Friend - if(!living.world.isRemote) { + case 13: { // Pixie Friend + if (!living.world.isRemote) { EntityPixie pixie = new EntityPixie(living.world); pixie.setPosition(living.getX(), living.getY() + 1.5, living.getZ()); living.world.addEntity(pixie); } break; } - case 14 : { // Nausea + Blindness :3 - if(!living.world.isRemote) { + case 14: { // Nausea + Blindness :3 + if (!living.world.isRemote) { living.addPotionEffect(new EffectInstance(Effects.NAUSEA, 160, 3)); living.addPotionEffect(new EffectInstance(Effects.BLINDNESS, 160, 0)); } break; } - case 15 : { // Drop own Head - if(!living.world.isRemote && living instanceof PlayerEntity) { + case 15: { // Drop own Head + if (!living.world.isRemote && living instanceof PlayerEntity) { living.attackEntityFrom(DamageSource.MAGIC, living.getHealth() - 1); ItemStack skull = new ItemStack(Items.PLAYER_HEAD); ItemNBTHelper.setString(skull, "SkullOwner", ((PlayerEntity) living).getGameProfile().getName()); @@ -198,8 +208,9 @@ public class ItemBottledMana extends Item { private long getSeed(ItemStack stack) { long seed = ItemNBTHelper.getLong(stack, TAG_SEED, -1); - if(seed == -1) + if (seed == -1) { return randomSeed(stack); + } return seed; } @@ -227,7 +238,7 @@ public class ItemBottledMana extends Item { public ItemStack onItemUseFinish(@Nonnull ItemStack stack, World world, LivingEntity living) { randomEffect(living, stack); int left = getSwigsLeft(stack); - if(left <= 1) { + if (left <= 1) { return new ItemStack(Items.GLASS_BOTTLE); } else { setSwigsLeft(stack, left - 1); diff --git a/src/main/java/vazkii/botania/common/item/ItemCacophonium.java b/src/main/java/vazkii/botania/common/item/ItemCacophonium.java index 81457a105..fee13fc68 100644 --- a/src/main/java/vazkii/botania/common/item/ItemCacophonium.java +++ b/src/main/java/vazkii/botania/common/item/ItemCacophonium.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 20, 2015, 9:53:57 PM (GMT)] */ package vazkii.botania.common.item; @@ -21,7 +19,6 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; -import net.minecraft.item.UseAction; import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; @@ -37,8 +34,8 @@ import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import net.minecraftforge.registries.ForgeRegistries; + import vazkii.botania.common.Botania; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.tile.TileCacophonium; @@ -48,8 +45,8 @@ import vazkii.botania.common.lib.LibObfuscation; import javax.annotation.Nonnull; import javax.annotation.Nullable; + import java.lang.invoke.MethodHandle; -import java.lang.reflect.InvocationTargetException; import java.util.List; public class ItemCacophonium extends Item { @@ -64,15 +61,15 @@ public class ItemCacophonium extends Item { @Override public boolean itemInteractionForEntity(ItemStack stack, PlayerEntity player, LivingEntity entity, Hand hand) { - if(entity instanceof MobEntity) { + if (entity instanceof MobEntity) { MobEntity living = (MobEntity) entity; SoundEvent sound = null; - if(living instanceof CreeperEntity) + if (living instanceof CreeperEntity) { sound = SoundEvents.ENTITY_CREEPER_PRIMED; - else if(living instanceof SlimeEntity) + } else if (living instanceof SlimeEntity) { sound = ((SlimeEntity) living).isSmallSlime() ? SoundEvents.ENTITY_SLIME_SQUISH_SMALL : SoundEvents.ENTITY_SLIME_SQUISH; - else { + } else { try { sound = (SoundEvent) GET_AMBIENT_SOUND.invokeExact(living); } catch (Throwable ex) { @@ -80,13 +77,14 @@ public class ItemCacophonium extends Item { } } - if(sound != null) { + if (sound != null) { ItemNBTHelper.setString(stack, TAG_SOUND, sound.getRegistryName().toString()); ItemNBTHelper.setString(stack, TAG_SOUND_NAME, entity.getType().getTranslationKey()); player.setHeldItem(hand, stack); - if(player.world.isRemote) + if (player.world.isRemote) { player.swingArm(hand); + } return true; } @@ -99,12 +97,12 @@ public class ItemCacophonium extends Item { @Override public ActionResultType onItemUse(ItemUseContext ctx) { ItemStack stack = ctx.getItem(); - if(getSound(stack) != null) { + if (getSound(stack) != null) { World world = ctx.getWorld(); BlockPos pos = ctx.getPos(); Block block = world.getBlockState(pos).getBlock(); - if(block instanceof NoteBlock) { + if (block instanceof NoteBlock) { world.setBlockState(pos, ModBlocks.cacophonium.getDefaultState()); ((TileCacophonium) world.getTileEntity(pos)).stack = stack.copy(); stack.shrink(1); @@ -118,10 +116,11 @@ public class ItemCacophonium extends Item { @OnlyIn(Dist.CLIENT) @Override public void addInformation(ItemStack stack, World world, List list, ITooltipFlag flags) { - if(isDOIT(stack)) + if (isDOIT(stack)) { list.add(new TranslationTextComponent("botaniamisc.justDoIt").applyTextStyle(TextFormatting.GRAY)); - else if(getSound(stack) != null) + } else if (getSound(stack) != null) { list.add(new TranslationTextComponent(ItemNBTHelper.getString(stack, TAG_SOUND_NAME, "")).applyTextStyle(TextFormatting.GRAY)); + } } @Override @@ -133,32 +132,36 @@ public class ItemCacophonium extends Item { @Override public ActionResult onItemRightClick(World world, PlayerEntity player, @Nonnull Hand hand) { ItemStack stack = player.getHeldItem(hand); - if(getSound(stack) != null) + if (getSound(stack) != null) { player.setActiveHand(hand); + } return ActionResult.success(stack); } @Override public void onUsingTick(ItemStack stack, LivingEntity player, int count) { - if(count % (isDOIT(stack) ? 20 : 6) == 0) + if (count % (isDOIT(stack) ? 20 : 6) == 0) { playSound(player.world, stack, player.getX(), player.getY(), player.getZ(), SoundCategory.PLAYERS, 0.9F); + } } public static void playSound(World world, ItemStack stack, double x, double y, double z, SoundCategory category, float volume) { - if(stack.isEmpty()) + if (stack.isEmpty()) { return; + } SoundEvent sound = getSound(stack); - if(sound != null) + if (sound != null) { world.playSound(null, x, y, z, sound, category, volume, sound == ModSounds.doit ? 1F : (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F + 1.0F); + } } @Nullable private static SoundEvent getSound(ItemStack stack) { - if(isDOIT(stack)) + if (isDOIT(stack)) { return ModSounds.doit; - else { + } else { try { return ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ItemNBTHelper.getString(stack, TAG_SOUND, ""))); } catch (ResourceLocationException ex) { diff --git a/src/main/java/vazkii/botania/common/item/ItemCorporeaSpark.java b/src/main/java/vazkii/botania/common/item/ItemCorporeaSpark.java index 66f9613b7..a1a0f19d0 100644 --- a/src/main/java/vazkii/botania/common/item/ItemCorporeaSpark.java +++ b/src/main/java/vazkii/botania/common/item/ItemCorporeaSpark.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 13, 2015, 10:25:32 PM (GMT)] */ package vazkii.botania.common.item; @@ -18,6 +16,7 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.items.CapabilityItemHandler; + import vazkii.botania.api.corporea.CorporeaHelper; import vazkii.botania.common.entity.EntityCorporeaSpark; @@ -36,15 +35,16 @@ public class ItemCorporeaSpark extends Item { BlockPos pos = ctx.getPos(); TileEntity tile = world.getTileEntity(pos); - if(tile != null + if (tile != null && (tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP).isPresent() - || tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).isPresent()) + || tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).isPresent()) && !CorporeaHelper.doesBlockHaveSpark(world, pos)) { ctx.getItem().shrink(1); - if(!world.isRemote) { + if (!world.isRemote) { EntityCorporeaSpark spark = new EntityCorporeaSpark(world); - if(this == ModItems.corporeaSparkMaster) + if (this == ModItems.corporeaSparkMaster) { spark.setMaster(true); + } spark.setPosition(pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5); world.addEntity(spark); } diff --git a/src/main/java/vazkii/botania/common/item/ItemCraftPattern.java b/src/main/java/vazkii/botania/common/item/ItemCraftPattern.java index d5280d100..ca527cf82 100644 --- a/src/main/java/vazkii/botania/common/item/ItemCraftPattern.java +++ b/src/main/java/vazkii/botania/common/item/ItemCraftPattern.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 28, 2015, 2:59:06 PM (GMT)] */ package vazkii.botania.common.item; @@ -16,6 +14,7 @@ import net.minecraft.item.ItemUseContext; import net.minecraft.util.ActionResultType; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.api.state.enums.CratePattern; import vazkii.botania.common.block.ModBlocks; @@ -37,8 +36,8 @@ public class ItemCraftPattern extends Item { BlockPos pos = ctx.getPos(); BlockState state = world.getBlockState(pos); - if(state.getBlock() == ModBlocks.craftCrate) { - if(pattern != state.get(BotaniaStateProps.CRATE_PATTERN)) { + if (state.getBlock() == ModBlocks.craftCrate) { + if (pattern != state.get(BotaniaStateProps.CRATE_PATTERN)) { world.setBlockState(pos, state.with(BotaniaStateProps.CRATE_PATTERN, this.pattern)); return ActionResultType.SUCCESS; } diff --git a/src/main/java/vazkii/botania/common/item/ItemCraftingHalo.java b/src/main/java/vazkii/botania/common/item/ItemCraftingHalo.java index cdb1642c4..6b119da28 100644 --- a/src/main/java/vazkii/botania/common/item/ItemCraftingHalo.java +++ b/src/main/java/vazkii/botania/common/item/ItemCraftingHalo.java @@ -1,31 +1,25 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Dec 15, 2014, 3:53:30 PM (GMT)] */ package vazkii.botania.common.item; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; -import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.block.Blocks; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.AbstractGui; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.Matrix4f; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.model.ItemCameraTransforms; -import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.resources.I18n; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; @@ -38,7 +32,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipeType; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.Hand; import net.minecraft.util.IWorldPosCallable; @@ -61,7 +54,7 @@ import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemStackHandler; import net.minecraftforge.items.wrapper.EmptyHandler; -import org.lwjgl.opengl.GL11; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.helper.RenderHelper; import vazkii.botania.client.fx.WispParticleData; @@ -72,6 +65,7 @@ import vazkii.botania.common.core.helper.PlayerHelper; import vazkii.botania.common.core.helper.Vector3; import javax.annotation.Nonnull; + import java.util.Arrays; import java.util.Optional; @@ -103,26 +97,27 @@ public class ItemCraftingHalo extends Item { int segment = getSegmentLookedAt(stack, player); ItemStack itemForPos = getItemForSlot(stack, segment); - if(!world.isRemote) { - if(segment == 0) { + if (!world.isRemote) { + if (segment == 0) { IWorldPosCallable wp = IWorldPosCallable.of(world, BlockPos.ZERO); // pos is never used by workbench player.openContainer(new SimpleNamedContainerProvider( (windowId, playerInv, p) -> new ContainerCraftingHalo(windowId, playerInv, wp), stack.getDisplayName())); } else { - if(itemForPos.isEmpty()) + if (itemForPos.isEmpty()) { assignRecipe(stack, itemForPos, segment); - else tryCraft(player, stack, segment, true, getFakeInv(player), true); + } else { + tryCraft(player, stack, segment, true, getFakeInv(player), true); + } } } - return ActionResult.success(stack); } public static IItemHandler getFakeInv(PlayerEntity player) { ItemStackHandler ret = new ItemStackHandler(player.inventory.mainInventory.size()); - for(int i = 0; i < player.inventory.mainInventory.size(); i++) { + for (int i = 0; i < player.inventory.mainInventory.size(); i++) { ret.setStackInSlot(i, player.inventory.mainInventory.get(i).copy()); } @@ -131,19 +126,22 @@ public class ItemCraftingHalo extends Item { @Override public void inventoryTick(ItemStack stack, World world, Entity entity, int pos, boolean equipped) { - if (!(entity instanceof LivingEntity)) + if (!(entity instanceof LivingEntity)) { return; + } LivingEntity living = (LivingEntity) entity; boolean eqLastTick = wasEquipped(stack); - if (!equipped && living.getHeldItemOffhand() == stack) + if (!equipped && living.getHeldItemOffhand() == stack) { equipped = true; + } - if(eqLastTick != equipped) + if (eqLastTick != equipped) { setEquipped(stack, equipped); + } - if(!equipped) { + if (!equipped) { int angles = 360; int segAngles = angles / SEGMENTS; float shift = segAngles / 2.0F; @@ -153,32 +151,36 @@ public class ItemCraftingHalo extends Item { void tryCraft(PlayerEntity player, ItemStack stack, int slot, boolean particles, IItemHandler inv, boolean validate) { ItemStack itemForPos = getItemForSlot(stack, slot); - if(itemForPos.isEmpty()) + if (itemForPos.isEmpty()) { return; + } ItemStack[] recipe = getCraftingItems(stack, slot); - if(validate) + if (validate) { recipe = validateRecipe(player, stack, recipe, slot); + } - if(canCraft(recipe, inv)) + if (canCraft(recipe, inv)) { doCraft(player, recipe, particles); + } } private static ItemStack[] validateRecipe(PlayerEntity player, ItemStack stack, ItemStack[] recipe, int slot) { CraftingInventory fakeInv = new CraftingInventory(new WorkbenchContainer(-1, player.inventory), 3, 3); - for(int i = 0; i < 9; i++) + for (int i = 0; i < 9; i++) { fakeInv.setInventorySlotContents(i, recipe[i]); + } ItemStack result = player.world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, fakeInv, player.world) .map(r -> r.getCraftingResult(fakeInv)) .orElse(ItemStack.EMPTY); - if(result.isEmpty()) { + if (result.isEmpty()) { assignRecipe(stack, recipe[9], slot); return null; } - if(!result.isItemEqual(recipe[9]) || result.getCount() != recipe[9].getCount() || !ItemStack.areItemStackTagsEqual(recipe[9], result)) { + if (!result.isItemEqual(recipe[9]) || result.getCount() != recipe[9].getCount() || !ItemStack.areItemStackTagsEqual(recipe[9], result)) { assignRecipe(stack, recipe[9], slot); return null; } @@ -187,11 +189,13 @@ public class ItemCraftingHalo extends Item { } private static boolean canCraft(ItemStack[] recipe, IItemHandler inv) { - if(recipe == null) + if (recipe == null) { return false; + } - if(!ItemHandlerHelper.insertItemStacked(inv, recipe[9], true).isEmpty()) + if (!ItemHandlerHelper.insertItemStacked(inv, recipe[9], true).isEmpty()) { return false; + } return consumeRecipeIngredients(recipe, inv, null); } @@ -200,48 +204,52 @@ public class ItemCraftingHalo extends Item { consumeRecipeIngredients(recipe, player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP).orElse(EmptyHandler.INSTANCE), player); ItemHandlerHelper.giveItemToPlayer(player, recipe[9]); - if(!particles) + if (!particles) { return; + } Vec3d lookVec3 = player.getLookVec(); Vector3 centerVector = Vector3.fromEntityCenter(player).add(lookVec3.x * 3, 1.3, lookVec3.z * 3); float m = 0.1F; - for(int i = 0; i < 4; i++) { - WispParticleData data = WispParticleData.wisp(0.2F + 0.2F * (float) Math.random(), 1F, 0F, 1F); - player.world.addParticle(data, centerVector.x, centerVector.y, centerVector.z, ((float) Math.random() - 0.5F) * m, ((float) Math.random() - 0.5F) * m, ((float) Math.random() - 0.5F) * m); - } + for (int i = 0; i < 4; i++) { + WispParticleData data = WispParticleData.wisp(0.2F + 0.2F * (float) Math.random(), 1F, 0F, 1F); + player.world.addParticle(data, centerVector.x, centerVector.y, centerVector.z, ((float) Math.random() - 0.5F) * m, ((float) Math.random() - 0.5F) * m, ((float) Math.random() - 0.5F) * m); + } } private static boolean consumeRecipeIngredients(ItemStack[] recipe, IItemHandler inv, PlayerEntity player) { - for(int i = 0; i < 9; i++) { + for (int i = 0; i < 9; i++) { ItemStack ingredient = recipe[i]; - if(!ingredient.isEmpty() && !consumeFromInventory(ingredient, inv, player)) + if (!ingredient.isEmpty() && !consumeFromInventory(ingredient, inv, player)) { return false; + } } return true; } private static boolean consumeFromInventory(ItemStack stack, IItemHandler inv, PlayerEntity player) { - for(int i = 0; i < inv.getSlots(); i++) { + for (int i = 0; i < inv.getSlots(); i++) { ItemStack stackAt = inv.getStackInSlot(i); - if(!stackAt.isEmpty() && stack.isItemEqual(stackAt) && ItemStack.areItemStackTagsEqual(stack, stackAt)) { + if (!stackAt.isEmpty() && stack.isItemEqual(stackAt) && ItemStack.areItemStackTagsEqual(stack, stackAt)) { boolean consume = true; ItemStack container = stackAt.getItem().getContainerItem(stackAt); - if(!container.isEmpty()) { - if(container == stackAt) + if (!container.isEmpty()) { + if (container == stackAt) { consume = false; - else { - if(player == null) + } else { + if (player == null) { ItemHandlerHelper.insertItem(inv, container, false); - else + } else { ItemHandlerHelper.giveItemToPlayer(player, container); + } } } - if(consume) + if (consume) { inv.extractItem(i, 1, false); + } return true; } @@ -253,12 +261,13 @@ public class ItemCraftingHalo extends Item { @Override public boolean onEntitySwing(ItemStack stack, LivingEntity player) { int segment = getSegmentLookedAt(stack, player); - if(segment == 0) + if (segment == 0) { return false; + } ItemStack itemForPos = getItemForSlot(stack, segment); - if(!itemForPos.isEmpty() && player.isSneaking()) { + if (!itemForPos.isEmpty() && player.isSneaking()) { assignRecipe(stack, itemForPos, segment); return true; } @@ -271,10 +280,11 @@ public class ItemCraftingHalo extends Item { int angles = 360; int segAngles = angles / SEGMENTS; - for(int seg = 0; seg < SEGMENTS; seg++) { + for (int seg = 0; seg < SEGMENTS; seg++) { float calcAngle = (float) seg * segAngles; - if(yaw >= calcAngle && yaw < calcAngle + segAngles) + if (yaw >= calcAngle && yaw < calcAngle + segAngles) { return seg; + } } return -1; } @@ -291,64 +301,71 @@ public class ItemCraftingHalo extends Item { int segAngles = angles / SEGMENTS; float shift = segAngles / 2; - if(yaw < 0) + if (yaw < 0) { yaw = 180F + (180F + yaw); + } yaw -= 360F - base; float angle = 360F - yaw + shift; - if(angle < 0) + if (angle < 0) { angle = 360F + angle; + } return angle; } private static ItemStack getItemForSlot(ItemStack stack, int slot) { - if(slot == 0) + if (slot == 0) { return craftingTable; - else if(slot >= SEGMENTS) + } else if (slot >= SEGMENTS) { return ItemStack.EMPTY; - else { + } else { CompoundNBT cmp = getStoredRecipeCompound(stack, slot); - if(cmp != null) { + if (cmp != null) { return getLastCraftingItem(cmp, 9); - } else return ItemStack.EMPTY; + } else { + return ItemStack.EMPTY; + } } } private static void assignRecipe(ItemStack stack, ItemStack itemForPos, int pos) { - if(!itemForPos.isEmpty()) + if (!itemForPos.isEmpty()) { ItemNBTHelper.setCompound(stack, TAG_STORED_RECIPE_PREFIX + pos, new CompoundNBT()); - else + } else { ItemNBTHelper.setCompound(stack, TAG_STORED_RECIPE_PREFIX + pos, getLastCraftingCompound(stack, false)); + } } private void onItemCrafted(PlayerEvent.ItemCraftedEvent event) { - if(!(event.getPlayer().openContainer instanceof ContainerCraftingHalo) || !(event.getInventory() instanceof CraftingInventory)) + if (!(event.getPlayer().openContainer instanceof ContainerCraftingHalo) || !(event.getInventory() instanceof CraftingInventory)) { return; + } - for(int i = 0; i < event.getPlayer().inventory.getSizeInventory(); i++) { + for (int i = 0; i < event.getPlayer().inventory.getSizeInventory(); i++) { ItemStack stack = event.getPlayer().inventory.getStackInSlot(i); - if(!stack.isEmpty() && stack.getItem() instanceof ItemCraftingHalo) + if (!stack.isEmpty() && stack.getItem() instanceof ItemCraftingHalo) { saveRecipeToStack(event, stack); + } } } private void saveRecipeToStack(PlayerEvent.ItemCraftedEvent event, ItemStack stack) { CompoundNBT cmp = new CompoundNBT(); - if(event.getInventory() instanceof CraftingInventory) { + if (event.getInventory() instanceof CraftingInventory) { Optional result = event.getPlayer().world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, (CraftingInventory) event.getInventory(), event.getPlayer().world) .map(r -> r.getCraftingResult((CraftingInventory) event.getInventory())); - if(result.isPresent() && !result.get().isEmpty()) { + if (result.isPresent() && !result.get().isEmpty()) { cmp.put(TAG_ITEM_PREFIX + 9, result.get().write(new CompoundNBT())); - for(int i = 0; i < 9; i++) { + for (int i = 0; i < 9; i++) { CompoundNBT ingr = new CompoundNBT(); ItemStack stackSlot = event.getInventory().getStackInSlot(i); - if(!stackSlot.isEmpty()) { + if (!stackSlot.isEmpty()) { ItemStack writeStack = stackSlot.copy(); writeStack.setCount(1); ingr = writeStack.write(new CompoundNBT()); @@ -366,9 +383,11 @@ public class ItemCraftingHalo extends Item { Arrays.fill(stackArray, ItemStack.EMPTY); CompoundNBT cmp = getStoredRecipeCompound(stack, slot); - if(cmp != null) - for(int i = 0; i < stackArray.length; i++) + if (cmp != null) { + for (int i = 0; i < stackArray.length; i++) { stackArray[i] = getLastCraftingItem(cmp, i); + } + } return stackArray; } @@ -382,8 +401,9 @@ public class ItemCraftingHalo extends Item { } private static ItemStack getLastCraftingItem(CompoundNBT cmp, int pos) { - if(cmp == null) + if (cmp == null) { return ItemStack.EMPTY; + } return ItemStack.read(cmp.getCompound(TAG_ITEM_PREFIX + pos)); } @@ -408,8 +428,9 @@ public class ItemCraftingHalo extends Item { private void onRenderWorldLast(RenderWorldLastEvent event) { PlayerEntity player = Minecraft.getInstance().player; ItemStack stack = PlayerHelper.getFirstHeldItemClass(player, ItemCraftingHalo.class); - if(!stack.isEmpty()) + if (!stack.isEmpty()) { render(stack, player, event.getMatrixStack(), event.getPartialTicks()); + } } @OnlyIn(Dist.CLIENT) @@ -447,18 +468,19 @@ public class ItemCraftingHalo extends Item { ItemCraftingHalo item = (ItemCraftingHalo) stack.getItem(); RenderType layer = RenderHelper.getHaloLayer(item.getGlowResource()); - for(int seg = 0; seg < SEGMENTS; seg++) { + for (int seg = 0; seg < SEGMENTS; seg++) { boolean inside = false; float rotationAngle = (seg + 0.5F) * segAngles + shift; ms.push(); ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(rotationAngle)); ms.translate(s * m, -0.75F, 0F); - if(segmentLookedAt == seg) + if (segmentLookedAt == seg) { inside = true; + } ItemStack slotStack = getItemForSlot(stack, seg); - if(!slotStack.isEmpty()) { + if (!slotStack.isEmpty()) { float scale = seg == 0 ? 0.9F : 0.8F; ms.scale(scale, scale, scale); ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(180F)); @@ -472,17 +494,17 @@ public class ItemCraftingHalo extends Item { ms.push(); ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(180)); float r = 1, g = 1, b = 1, a = alpha; - if(inside) { + if (inside) { a += 0.3F; y0 = -y; } - if(seg % 2 == 0) { + if (seg % 2 == 0) { r = g = b = 0.6F; } IVertexBuilder buffer = buffers.getBuffer(layer); - for(int i = 0; i < segAngles; i++) { + for (int i = 0; i < segAngles; i++) { Matrix4f mat = ms.peek().getModel(); float ang = i + seg * segAngles + shift; float xp = (float) Math.cos(ang * Math.PI / 180F) * s; @@ -514,7 +536,7 @@ public class ItemCraftingHalo extends Item { Minecraft mc = Minecraft.getInstance(); int slot = getSegmentLookedAt(stack, player); - if(slot == 0) { + if (slot == 0) { String name = craftingTable.getDisplayName().getString(); int l = mc.fontRenderer.getStringWidth(name); int x = mc.getWindow().getScaledWidth() / 2 - l / 2; @@ -530,9 +552,9 @@ public class ItemCraftingHalo extends Item { ITextComponent label = new TranslationTextComponent("botaniamisc.unsetRecipe"); boolean setRecipe = false; - if(recipe[9].isEmpty()) + if (recipe[9].isEmpty()) { recipe = getCraftingItems(stack, SEGMENTS); - else { + } else { label = recipe[9].getDisplayName(); setRecipe = true; } @@ -545,7 +567,7 @@ public class ItemCraftingHalo extends Item { private static void renderRecipe(ITextComponent label, ItemStack[] recipe, PlayerEntity player, boolean setRecipe) { Minecraft mc = Minecraft.getInstance(); - if(!recipe[9].isEmpty()) { + if (!recipe[9].isEmpty()) { int x = mc.getWindow().getScaledWidth() / 2 - 45; int y = mc.getWindow().getScaledHeight() / 2 - 90; @@ -555,9 +577,9 @@ public class ItemCraftingHalo extends Item { AbstractGui.fill(x + 66, y + 14, x + 92, y + 40, 0x22000000); AbstractGui.fill(x - 2, y - 2, x + 56, y + 56, 0x22000000); - for(int i = 0; i < 9; i++) { + for (int i = 0; i < 9; i++) { ItemStack stack = recipe[i]; - if(!stack.isEmpty()) { + if (!stack.isEmpty()) { int xpos = x + i % 3 * 18; int ypos = y + i / 3 * 18; AbstractGui.fill(xpos, ypos, xpos + 16, ypos + 16, 0x22000000); @@ -572,7 +594,7 @@ public class ItemCraftingHalo extends Item { } int yoff = 110; - if(setRecipe && !canCraft(recipe, getFakeInv(player))) { + if (setRecipe && !canCraft(recipe, getFakeInv(player))) { String warning = TextFormatting.RED + I18n.format("botaniamisc.cantCraft"); mc.fontRenderer.drawStringWithShadow(warning, mc.getWindow().getScaledWidth() / 2.0F - mc.fontRenderer.getStringWidth(warning) / 2.0F, mc.getWindow().getScaledHeight() / 2.0F - yoff, 0xFFFFFF); yoff += 12; diff --git a/src/main/java/vazkii/botania/common/item/ItemElven.java b/src/main/java/vazkii/botania/common/item/ItemElven.java index 08af9a8ba..bbaca4884 100644 --- a/src/main/java/vazkii/botania/common/item/ItemElven.java +++ b/src/main/java/vazkii/botania/common/item/ItemElven.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 11, 2014, 2:16:47 AM (GMT)] */ package vazkii.botania.common.item; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; + import vazkii.botania.api.recipe.IElvenItem; public class ItemElven extends Item implements IElvenItem { diff --git a/src/main/java/vazkii/botania/common/item/ItemEnderHand.java b/src/main/java/vazkii/botania/common/item/ItemEnderHand.java index ecec7a55e..9a3137278 100644 --- a/src/main/java/vazkii/botania/common/item/ItemEnderHand.java +++ b/src/main/java/vazkii/botania/common/item/ItemEnderHand.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 31, 2014, 7:19:26 PM (GMT)] */ package vazkii.botania.common.item; @@ -19,11 +17,11 @@ import net.minecraft.inventory.container.SimpleNamedContainerProvider; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.SoundEvents; import net.minecraft.world.World; import net.minecraftforge.items.wrapper.InvWrapper; + import vazkii.botania.api.item.IBlockProvider; import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; @@ -46,8 +44,8 @@ public class ItemEnderHand extends Item implements IManaUsingItem, IBlockProvide @Override public ActionResult onItemRightClick(World world, PlayerEntity player, @Nonnull Hand hand) { ItemStack stack = player.getHeldItem(hand); - if(ManaItemHandler.requestManaExact(stack, player, COST_SELF, false)) { - if(!player.world.isRemote) { + if (ManaItemHandler.requestManaExact(stack, player, COST_SELF, false)) { + if (!player.world.isRemote) { player.openContainer(new SimpleNamedContainerProvider((windowId, playerInv, p) -> { return ChestContainer.createGeneric9X3(windowId, playerInv, p.getInventoryEnderChest()); }, EnderChestBlock.field_220115_d)); @@ -61,8 +59,8 @@ public class ItemEnderHand extends Item implements IManaUsingItem, IBlockProvide @Override public boolean itemInteractionForEntity(ItemStack stack, PlayerEntity player, LivingEntity entity, Hand hand) { - if(ConfigHandler.COMMON.enderPickpocketEnabled.get() && entity instanceof PlayerEntity && ManaItemHandler.requestManaExact(stack, player, COST_OTHER, false)) { - if(!player.world.isRemote) { + if (ConfigHandler.COMMON.enderPickpocketEnabled.get() && entity instanceof PlayerEntity && ManaItemHandler.requestManaExact(stack, player, COST_OTHER, false)) { + if (!player.world.isRemote) { PlayerEntity other = (PlayerEntity) entity; player.openContainer(new SimpleNamedContainerProvider((windowId, playerInv, p) -> { return ChestContainer.createGeneric9X3(windowId, playerInv, other.getInventoryEnderChest()); @@ -83,14 +81,15 @@ public class ItemEnderHand extends Item implements IManaUsingItem, IBlockProvide @Override public boolean provideBlock(PlayerEntity player, ItemStack requestor, ItemStack stack, Block block, boolean doit) { - if(!requestor.isEmpty() && requestor.getItem() == this) + if (!requestor.isEmpty() && requestor.getItem() == this) { return false; + } ItemStack istack = ItemExchangeRod.removeFromInventory(player, new InvWrapper(player.getInventoryEnderChest()), stack, block, false); - if(!istack.isEmpty()) { + if (!istack.isEmpty()) { boolean mana = ManaItemHandler.requestManaExact(stack, player, COST_PROVIDE, false); - if(mana) { - if(doit) { + if (mana) { + if (doit) { ManaItemHandler.requestManaExact(stack, player, COST_PROVIDE, true); ItemExchangeRod.removeFromInventory(player, new InvWrapper(player.getInventoryEnderChest()), stack, block, true); } @@ -104,8 +103,9 @@ public class ItemEnderHand extends Item implements IManaUsingItem, IBlockProvide @Override public int getBlockCount(PlayerEntity player, ItemStack requestor, ItemStack stack, Block block) { - if(!requestor.isEmpty() && requestor.getItem() == this) + if (!requestor.isEmpty() && requestor.getItem() == this) { return 0; + } return ItemExchangeRod.getInventoryItemCount(player, new InvWrapper(player.getInventoryEnderChest()), stack, block); } diff --git a/src/main/java/vazkii/botania/common/item/ItemFertilizer.java b/src/main/java/vazkii/botania/common/item/ItemFertilizer.java index d6fc1cd2c..18aa88909 100644 --- a/src/main/java/vazkii/botania/common/item/ItemFertilizer.java +++ b/src/main/java/vazkii/botania/common/item/ItemFertilizer.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 29, 2014, 10:41:52 PM (GMT)] */ package vazkii.botania.common.item; @@ -16,10 +14,12 @@ import net.minecraft.item.ItemUseContext; import net.minecraft.util.ActionResultType; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import vazkii.botania.client.fx.WispParticleData; import vazkii.botania.common.block.ModBlocks; import javax.annotation.Nonnull; + import java.util.ArrayList; import java.util.List; @@ -35,37 +35,39 @@ public class ItemFertilizer extends Item { World world = ctx.getWorld(); BlockPos pos = ctx.getPos(); final int range = 3; - if(!world.isRemote) { + if (!world.isRemote) { List validCoords = new ArrayList<>(); - for(int i = -range - 1; i < range; i++) - for(int j = -range - 1; j < range; j++) { - for(int k = 2; k >= -2; k--) { + for (int i = -range - 1; i < range; i++) { + for (int j = -range - 1; j < range; j++) { + for (int k = 2; k >= -2; k--) { BlockPos pos_ = pos.add(i + 1, k + 1, j + 1); - if(world.isAirBlock(pos_) && (!world.getDimension().isNether() || pos_.getY() < 255) - && ModBlocks.whiteFlower.getDefaultState().isValidPosition(world, pos_)) + if (world.isAirBlock(pos_) && (!world.getDimension().isNether() || pos_.getY() < 255) + && ModBlocks.whiteFlower.getDefaultState().isValidPosition(world, pos_)) { validCoords.add(pos_); + } } } + } int flowerCount = Math.min(validCoords.size(), world.rand.nextBoolean() ? 3 : 4); - for(int i = 0; i < flowerCount; i++) { + for (int i = 0; i < flowerCount; i++) { BlockPos coords = validCoords.get(world.rand.nextInt(validCoords.size())); validCoords.remove(coords); world.setBlockState(coords, ModBlocks.getFlower(DyeColor.byId(world.rand.nextInt(16))).getDefaultState()); } ctx.getItem().shrink(1); } else { - for(int i = 0; i < 15; i++) { + for (int i = 0; i < 15; i++) { double x = pos.getX() - range + world.rand.nextInt(range * 2 + 1) + Math.random(); double y = pos.getY() + 1; double z = pos.getZ() - range + world.rand.nextInt(range * 2 + 1) + Math.random(); float red = (float) Math.random(); float green = (float) Math.random(); float blue = (float) Math.random(); - WispParticleData data = WispParticleData.wisp(0.15F + (float) Math.random() * 0.25F, red, green, blue, 1); - world.addParticle(data, x, y, z, 0, (float) Math.random() * 0.1F - 0.05F, 0); - } + WispParticleData data = WispParticleData.wisp(0.15F + (float) Math.random() * 0.25F, red, green, blue, 1); + world.addParticle(data, x, y, z, 0, (float) Math.random() * 0.1F - 0.05F, 0); + } } return ActionResultType.SUCCESS; diff --git a/src/main/java/vazkii/botania/common/item/ItemFlowerBag.java b/src/main/java/vazkii/botania/common/item/ItemFlowerBag.java index 2c906ab3a..7e57f5a95 100644 --- a/src/main/java/vazkii/botania/common/item/ItemFlowerBag.java +++ b/src/main/java/vazkii/botania/common/item/ItemFlowerBag.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 16, 2015, 6:43:33 PM (GMT)] */ package vazkii.botania.common.item; @@ -44,6 +42,7 @@ import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemStackHandler; import net.minecraftforge.items.wrapper.InvWrapper; + import vazkii.botania.client.gui.bag.ContainerFlowerBag; import vazkii.botania.common.block.BlockModFlower; @@ -94,15 +93,16 @@ public class ItemFlowerBag extends Item { private void onPickupItem(EntityItemPickupEvent event) { ItemStack entityStack = event.getItem().getItem(); - if(Block.getBlockFromItem(entityStack.getItem()) instanceof BlockModFlower && entityStack.getCount() > 0) { + if (Block.getBlockFromItem(entityStack.getItem()) instanceof BlockModFlower && entityStack.getCount() > 0) { int color = ((BlockModFlower) Block.getBlockFromItem(entityStack.getItem())).color.getId(); - for(int i = 0; i < event.getPlayer().inventory.getSizeInventory(); i++) { - if(i == event.getPlayer().inventory.currentItem) + for (int i = 0; i < event.getPlayer().inventory.getSizeInventory(); i++) { + if (i == event.getPlayer().inventory.currentItem) { continue; // prevent item deletion + } ItemStack bag = event.getPlayer().inventory.getStackInSlot(i); - if(!bag.isEmpty() && bag.getItem() == this) { + if (!bag.isEmpty() && bag.getItem() == this) { IItemHandler bagInv = bag.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElseThrow(NullPointerException::new); ItemStack result = bagInv.insertItem(color, entityStack, false); @@ -110,7 +110,7 @@ public class ItemFlowerBag extends Item { event.getItem().setItem(result); - if(numPickedUp > 0) { + if (numPickedUp > 0) { event.setCanceled(true); if (!event.getItem().isSilent()) { event.getItem().world.playSound(null, event.getPlayer().getX(), event.getPlayer().getY(), event.getPlayer().getZ(), @@ -130,7 +130,7 @@ public class ItemFlowerBag extends Item { @Nonnull @Override public ActionResult onItemRightClick(World world, PlayerEntity player, @Nonnull Hand hand) { - if(!world.isRemote) { + if (!world.isRemote) { ItemStack stack = player.getHeldItem(hand); INamedContainerProvider container = new SimpleNamedContainerProvider((w, p, pl) -> new ContainerFlowerBag(w, p, stack), stack.getDisplayName()); NetworkHooks.openGui((ServerPlayerEntity) player, container, buf -> { @@ -148,17 +148,19 @@ public class ItemFlowerBag extends Item { Direction side = ctx.getFace(); TileEntity tile = world.getTileEntity(pos); - if(tile != null) { - if(!world.isRemote) { + if (tile != null) { + if (!world.isRemote) { IItemHandler tileInv; - if(tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side).isPresent()) + if (tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side).isPresent()) { tileInv = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side).orElseThrow(NullPointerException::new); - else if(tile instanceof IInventory) + } else if (tile instanceof IInventory) { tileInv = new InvWrapper((IInventory) tile); - else return ActionResultType.FAIL; + } else { + return ActionResultType.FAIL; + } ctx.getItem().getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent(bagInv -> { - for(int i = 0; i < bagInv.getSlots(); i++) { + for (int i = 0; i < bagInv.getSlots(); i++) { ItemStack flower = bagInv.getStackInSlot(i); ((IItemHandlerModifiable) bagInv).setStackInSlot(i, ItemHandlerHelper.insertItemStacked(tileInv, flower, false)); } diff --git a/src/main/java/vazkii/botania/common/item/ItemGaiaHead.java b/src/main/java/vazkii/botania/common/item/ItemGaiaHead.java index 35c93df72..0a9d7f6ff 100644 --- a/src/main/java/vazkii/botania/common/item/ItemGaiaHead.java +++ b/src/main/java/vazkii/botania/common/item/ItemGaiaHead.java @@ -1,26 +1,17 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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, 2015, 11:40:51 PM (GMT)] */ package vazkii.botania.common.item; import net.minecraft.block.Block; -import net.minecraft.client.renderer.entity.model.BipedModel; -import net.minecraft.entity.LivingEntity; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ItemStack; import net.minecraft.item.WallOrFloorItem; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import vazkii.botania.common.Botania; - -import javax.annotation.Nonnull; public class ItemGaiaHead extends WallOrFloorItem { diff --git a/src/main/java/vazkii/botania/common/item/ItemGrassSeeds.java b/src/main/java/vazkii/botania/common/item/ItemGrassSeeds.java index 3523a7d07..cc235c618 100644 --- a/src/main/java/vazkii/botania/common/item/ItemGrassSeeds.java +++ b/src/main/java/vazkii/botania/common/item/ItemGrassSeeds.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 9, 2014, 5:11:34 PM (GMT)] */ package vazkii.botania.common.item; import com.google.common.collect.ImmutableMap; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -25,12 +24,14 @@ import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.LogicalSide; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.api.item.IFloatingFlower.IslandType; import vazkii.botania.client.fx.WispParticleData; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -47,15 +48,15 @@ public class ItemGrassSeeds extends Item implements IFloatingFlowerVariant { */ private static final Map> blockSwappers = new HashMap<>(); private static final Map COLORS = ImmutableMap.builder() - .put(IslandType.GRASS, new float[] {0F, 0.4F, 0F}) - .put(IslandType.PODZOL, new float[] {0.5F, 0.37F, 0F}) - .put(IslandType.MYCEL, new float[] {0.27F, 0F, 0.33F}) - .put(IslandType.DRY, new float[] {0.4F, 0.5F, 0.05F}) - .put(IslandType.GOLDEN, new float[] {0.75F, 0.7F, 0F}) - .put(IslandType.VIVID, new float[] {0F, 0.5F, 0.1F}) - .put(IslandType.SCORCHED, new float[] {0.75F, 0F, 0F}) - .put(IslandType.INFUSED, new float[] {0F, 0.55F, 0.55F}) - .put(IslandType.MUTATED, new float[] {0.4F, 0.1F, 0.4F}) + .put(IslandType.GRASS, new float[] { 0F, 0.4F, 0F }) + .put(IslandType.PODZOL, new float[] { 0.5F, 0.37F, 0F }) + .put(IslandType.MYCEL, new float[] { 0.27F, 0F, 0.33F }) + .put(IslandType.DRY, new float[] { 0.4F, 0.5F, 0.05F }) + .put(IslandType.GOLDEN, new float[] { 0.75F, 0.7F, 0F }) + .put(IslandType.VIVID, new float[] { 0F, 0.5F, 0.1F }) + .put(IslandType.SCORCHED, new float[] { 0.75F, 0F, 0F }) + .put(IslandType.INFUSED, new float[] { 0F, 0.55F, 0.55F }) + .put(IslandType.MUTATED, new float[] { 0.4F, 0.1F, 0.4F }) .build(); private final IslandType type; @@ -73,8 +74,8 @@ public class ItemGrassSeeds extends Item implements IFloatingFlowerVariant { BlockState state = world.getBlockState(pos); ItemStack stack = ctx.getItem(); - if(state.getBlock() == Blocks.DIRT || state.getBlock() == Blocks.GRASS_BLOCK && type != IslandType.GRASS) { - if(!world.isRemote) { + if (state.getBlock() == Blocks.DIRT || state.getBlock() == Blocks.GRASS_BLOCK && type != IslandType.GRASS) { + if (!world.isRemote) { BlockSwapper swapper = addBlockSwapper(world, pos, type); world.setBlockState(pos, swapper.stateToSet); stack.shrink(1); @@ -83,25 +84,25 @@ public class ItemGrassSeeds extends Item implements IFloatingFlowerVariant { float g = 0.4F; float b = 0F; - if(COLORS.containsKey(type)) { + if (COLORS.containsKey(type)) { float[] colors = COLORS.get(type); r = colors[0]; g = colors[1]; b = colors[2]; } - for(int i = 0; i < 50; i++) { + for (int i = 0; i < 50; i++) { double x = (Math.random() - 0.5) * 3; double y = Math.random() - 0.5 + 1; double z = (Math.random() - 0.5) * 3; float velMul = 0.025F; - float motionx = (float) -x * velMul; - float motiony = (float) -y * velMul; - float motionz = (float) -z * velMul; - WispParticleData data = WispParticleData.wisp((float) Math.random() * 0.15F + 0.15F, r, g, b); - world.addParticle(data, pos.getX() + 0.5 + x, pos.getY() + 0.5 + y, pos.getZ() + 0.5 + z, motionx, motiony, motionz); - } + float motionx = (float) -x * velMul; + float motiony = (float) -y * velMul; + float motionz = (float) -z * velMul; + WispParticleData data = WispParticleData.wisp((float) Math.random() * 0.15F + 0.15F, r, g, b); + world.addParticle(data, pos.getX() + 0.5 + x, pos.getY() + 0.5 + y, pos.getZ() + 0.5 + z, motionx, motiony, motionz); + } } return ActionResultType.SUCCESS; @@ -112,9 +113,9 @@ public class ItemGrassSeeds extends Item implements IFloatingFlowerVariant { @SubscribeEvent public static void onTickEnd(TickEvent.WorldTickEvent event) { - if(event.side == LogicalSide.SERVER && event.phase == TickEvent.Phase.END) { + if (event.side == LogicalSide.SERVER && event.phase == TickEvent.Phase.END) { DimensionType dim = event.world.getDimension().getType(); - if(blockSwappers.containsKey(dim)) { + if (blockSwappers.containsKey(dim)) { blockSwappers.get(dim).removeIf(next -> next == null || !next.tick()); } } @@ -124,14 +125,14 @@ public class ItemGrassSeeds extends Item 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 pos The position of the swapper. - * @param type The IslandType of the grass seed - * @return The created block swapper. + * + * @param world The world the swapper will be in. + * @param pos The position of the swapper. + * @param type The IslandType of the grass seed + * @return The created block swapper. */ private static BlockSwapper addBlockSwapper(World world, BlockPos pos, IslandType type) { BlockSwapper swapper = new BlockSwapper(world, pos, stateForType(type)); @@ -143,23 +144,25 @@ public class ItemGrassSeeds extends Item implements IFloatingFlowerVariant { } private static BlockState stateForType(IslandType type) { - if(type == IslandType.PODZOL) + if (type == IslandType.PODZOL) { return Blocks.PODZOL.getDefaultState(); - else if(type == IslandType.MYCEL) + } else if (type == IslandType.MYCEL) { return Blocks.MYCELIUM.getDefaultState(); - else if(type == IslandType.DRY) + } else if (type == IslandType.DRY) { return ModBlocks.dryGrass.getDefaultState(); - else if(type == IslandType.GOLDEN) + } else if (type == IslandType.GOLDEN) { return ModBlocks.goldenGrass.getDefaultState(); - else if(type == IslandType.VIVID) + } else if (type == IslandType.VIVID) { return ModBlocks.vividGrass.getDefaultState(); - else if(type == IslandType.SCORCHED) + } else if (type == IslandType.SCORCHED) { return ModBlocks.scorchedGrass.getDefaultState(); - else if(type == IslandType.INFUSED) + } else if (type == IslandType.INFUSED) { return ModBlocks.infusedGrass.getDefaultState(); - else if(type == IslandType.MUTATED) + } else if (type == IslandType.MUTATED) { return ModBlocks.mutatedGrass.getDefaultState(); - else return Blocks.GRASS_BLOCK.getDefaultState(); + } else { + return Blocks.GRASS_BLOCK.getDefaultState(); + } } /** @@ -188,9 +191,10 @@ public class ItemGrassSeeds extends Item implements IFloatingFlowerVariant { /** * Constructs a new block swapper with the provided world, starting * coordinates, target block, and target metadata. - * @param world The world to swap blocks in. + * + * @param world The world to swap blocks in. * @param coords The central coordinates to swap blocks around. - * @param state The target blockstate to swap dirt and grass to. + * @param state The target blockstate to swap dirt and grass to. */ public BlockSwapper(World world, BlockPos coords, BlockState state) { this.world = world; @@ -203,15 +207,17 @@ public class ItemGrassSeeds extends Item implements IFloatingFlowerVariant { * Ticks this block swapper, allowing it to make an action during * this game tick. This method should return "false" when the swapper * has finished operation and should be removed from the world. + * * @return true if the swapper should continue to exist, false if it - * should be removed. + * should be removed. */ public boolean tick() { - if(++ticksExisted % 20 == 0) { - for(BlockPos pos : BlockPos.getAllInBoxMutable(startCoords.add(-RANGE, 0, -RANGE), + if (++ticksExisted % 20 == 0) { + for (BlockPos pos : BlockPos.getAllInBoxMutable(startCoords.add(-RANGE, 0, -RANGE), startCoords.add(RANGE, 0, RANGE))) { - if(world.getBlockState(pos) == stateToSet) + if (world.getBlockState(pos) == stateToSet) { tickBlock(pos); + } } } @@ -222,25 +228,29 @@ public class ItemGrassSeeds extends Item implements IFloatingFlowerVariant { /** * Tick a specific block position, finding the valid blocks * immediately adjacent to it and then replacing one at random. + * * @param pos The positions to use. */ public void tickBlock(BlockPos pos) { List validCoords = new ArrayList<>(); // Go around this block and aggregate valid blocks. - for(int xOffset = -TICK_RANGE; xOffset <= TICK_RANGE; xOffset++) { - for(int zOffset = -TICK_RANGE; zOffset <= TICK_RANGE; zOffset++) { + for (int xOffset = -TICK_RANGE; xOffset <= TICK_RANGE; xOffset++) { + for (int zOffset = -TICK_RANGE; zOffset <= TICK_RANGE; zOffset++) { // Skip the current block - if(xOffset == 0 && zOffset == 0) continue; + if (xOffset == 0 && zOffset == 0) { + continue; + } - if(isValidSwapPosition(pos.add(xOffset, 0, zOffset))) + if (isValidSwapPosition(pos.add(xOffset, 0, zOffset))) { validCoords.add(pos.add(xOffset, 0, zOffset)); + } } } // If we can make changes, and have at least 1 block to swap, // then swap a random block from the valid blocks we could swap. - if(!validCoords.isEmpty()) { + if (!validCoords.isEmpty()) { BlockPos toSwap = validCoords.get(rand.nextInt(validCoords.size())); world.setBlockState(toSwap, stateToSet); @@ -251,8 +261,9 @@ public class ItemGrassSeeds extends Item implements IFloatingFlowerVariant { * Determines if a given position is a valid location to spread to, which * means that the block must be either dirt or grass (with meta 0), * and have a block above it which does not block grass growth. - * @param pos The position to check. - * @return True if the position is valid to swap, false otherwise. + * + * @param pos The position to check. + * @return True if the position is valid to swap, false otherwise. */ public boolean isValidSwapPosition(BlockPos pos) { BlockState state = world.getBlockState(pos); diff --git a/src/main/java/vazkii/botania/common/item/ItemHorn.java b/src/main/java/vazkii/botania/common/item/ItemHorn.java index c5162ae5e..76f798a3b 100644 --- a/src/main/java/vazkii/botania/common/item/ItemHorn.java +++ b/src/main/java/vazkii/botania/common/item/ItemHorn.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 11, 2014, 2:57:30 PM (GMT)] */ package vazkii.botania.common.item; @@ -21,19 +19,20 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.UseAction; import net.minecraft.tags.BlockTags; import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import vazkii.botania.api.item.IHornHarvestable; import vazkii.botania.api.item.IHornHarvestable.EnumHornType; import vazkii.botania.common.lib.LibMisc; import vazkii.botania.common.lib.ModTags; import javax.annotation.Nonnull; + import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -66,9 +65,10 @@ public class ItemHorn extends Item { @Override public void onUsingTick(ItemStack stack, LivingEntity player, int time) { - if(!player.world.isRemote) { - if(time != getUseDuration(stack) && time % 5 == 0) + if (!player.world.isRemote) { + if (time != getUseDuration(stack) && time % 5 == 0) { breakGrass(player.world, stack, new BlockPos(player)); + } player.world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.BLOCK_NOTE_BLOCK_BASS, SoundCategory.BLOCKS, 1F, 0.001F); } } @@ -87,28 +87,29 @@ public class ItemHorn extends Item { int rangeY = 3 + type.ordinal() * 4; List coords = new ArrayList<>(); - for(BlockPos pos : BlockPos.getAllInBoxMutable(srcPos.add(-range, -rangeY, -range), + for (BlockPos pos : BlockPos.getAllInBoxMutable(srcPos.add(-range, -rangeY, -range), srcPos.add(range, rangeY, range))) { Block block = world.getBlockState(pos).getBlock(); - if(block instanceof IHornHarvestable + if (block instanceof IHornHarvestable ? ((IHornHarvestable) block).canHornHarvest(world, pos, stack, type) - : type == EnumHornType.WILD && block instanceof BushBlock && !block.isIn(ModTags.Blocks.SPECIAL_FLOWERS) + : type == EnumHornType.WILD && block instanceof BushBlock && !block.isIn(ModTags.Blocks.SPECIAL_FLOWERS) || type == EnumHornType.CANOPY && BlockTags.LEAVES.contains(block) - || type == EnumHornType.COVERING && block == Blocks.SNOW) + || type == EnumHornType.COVERING && block == Blocks.SNOW) { coords.add(pos.toImmutable()); + } } Collections.shuffle(coords, world.rand); int count = Math.min(coords.size(), 32 + type.ordinal() * 16); - for(int i = 0; i < count; i++) { + for (int i = 0; i < count; i++) { BlockPos currCoords = coords.get(i); BlockState state = world.getBlockState(currCoords); Block block = state.getBlock(); - if(block instanceof IHornHarvestable && ((IHornHarvestable) block).hasSpecialHornHarvest(world, currCoords, stack, type)) + if (block instanceof IHornHarvestable && ((IHornHarvestable) block).hasSpecialHornHarvest(world, currCoords, stack, type)) { ((IHornHarvestable) block).harvestByHorn(world, currCoords, stack, type); - else { + } else { world.destroyBlock(currCoords, true); } } diff --git a/src/main/java/vazkii/botania/common/item/ItemKeepIvy.java b/src/main/java/vazkii/botania/common/item/ItemKeepIvy.java index dbe2ac369..3167bf410 100644 --- a/src/main/java/vazkii/botania/common/item/ItemKeepIvy.java +++ b/src/main/java/vazkii/botania/common/item/ItemKeepIvy.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 31, 2015, 9:11:23 PM (GMT)] */ package vazkii.botania.common.item; @@ -20,6 +18,7 @@ import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.lib.LibMisc; @@ -41,24 +40,26 @@ public class ItemKeepIvy extends Item { @SubscribeEvent(priority = EventPriority.LOWEST) public static void onPlayerDrops(LivingDropsEvent event) { - if(!(event.getEntityLiving() instanceof PlayerEntity)) + if (!(event.getEntityLiving() instanceof PlayerEntity)) { return; - - List keeps = new ArrayList<>(); - for(ItemEntity item : event.getDrops()) { - ItemStack stack = item.getItem(); - if(!stack.isEmpty() && stack.hasTag() && ItemNBTHelper.getBoolean(stack, TAG_KEEP, false)) - keeps.add(item); } - if(keeps.size() > 0) { + List keeps = new ArrayList<>(); + for (ItemEntity item : event.getDrops()) { + ItemStack stack = item.getItem(); + if (!stack.isEmpty() && stack.hasTag() && ItemNBTHelper.getBoolean(stack, TAG_KEEP, false)) { + keeps.add(item); + } + } + + if (keeps.size() > 0) { event.getDrops().removeAll(keeps); CompoundNBT cmp = new CompoundNBT(); cmp.putInt(TAG_DROP_COUNT, keeps.size()); int i = 0; - for(ItemEntity keep : keeps) { + for (ItemEntity keep : keeps) { ItemStack stack = keep.getItem(); CompoundNBT cmp1 = stack.write(new CompoundNBT()); cmp.put(TAG_DROP_PREFIX + i, cmp1); @@ -66,8 +67,9 @@ public class ItemKeepIvy extends Item { } CompoundNBT data = event.getEntityLiving().getPersistentData(); - if(!data.contains(PlayerEntity.PERSISTED_NBT_TAG)) + if (!data.contains(PlayerEntity.PERSISTED_NBT_TAG)) { data.put(PlayerEntity.PERSISTED_NBT_TAG, new CompoundNBT()); + } CompoundNBT persist = data.getCompound(PlayerEntity.PERSISTED_NBT_TAG); persist.put(TAG_PLAYER_KEPT_DROPS, cmp); @@ -77,15 +79,15 @@ public class ItemKeepIvy extends Item { @SubscribeEvent public static void onPlayerRespawn(PlayerEvent.PlayerRespawnEvent event) { CompoundNBT data = event.getPlayer().getPersistentData(); - if(data.contains(PlayerEntity.PERSISTED_NBT_TAG)) { + if (data.contains(PlayerEntity.PERSISTED_NBT_TAG)) { CompoundNBT cmp = data.getCompound(PlayerEntity.PERSISTED_NBT_TAG); CompoundNBT cmp1 = cmp.getCompound(TAG_PLAYER_KEPT_DROPS); int count = cmp1.getInt(TAG_DROP_COUNT); - for(int i = 0; i < count; i++) { + for (int i = 0; i < count; i++) { CompoundNBT cmp2 = cmp1.getCompound(TAG_DROP_PREFIX + i); ItemStack stack = ItemStack.read(cmp2); - if(!stack.isEmpty()) { + if (!stack.isEmpty()) { ItemStack copy = stack.copy(); ItemNBTHelper.setBoolean(copy, TAG_KEEP, false); event.getPlayer().inventory.addItemStackToInventory(copy); diff --git a/src/main/java/vazkii/botania/common/item/ItemLaputaShard.java b/src/main/java/vazkii/botania/common/item/ItemLaputaShard.java index 34ad37df5..11d0e7db1 100644 --- a/src/main/java/vazkii/botania/common/item/ItemLaputaShard.java +++ b/src/main/java/vazkii/botania/common/item/ItemLaputaShard.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 19, 2014, 10:46:14 PM (GMT)] */ package vazkii.botania.common.item; @@ -38,6 +36,7 @@ import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.api.mana.BurstProperties; import vazkii.botania.api.mana.ILaputaImmobile; @@ -50,6 +49,7 @@ import vazkii.botania.common.core.helper.MathHelper; import vazkii.botania.common.entity.EntityManaBurst; import javax.annotation.Nonnull; + import java.util.List; public class ItemLaputaShard extends Item implements ILensEffect, ITinyPlanetExcempt { @@ -76,8 +76,8 @@ public class ItemLaputaShard extends Item implements ILensEffect, ITinyPlanetExc @Override public void fillItemGroup(@Nonnull ItemGroup tab, @Nonnull NonNullList list) { - if(isInGroup(tab)) { - for(int i = 0; i <= 20; i += 5) { + if (isInGroup(tab)) { + for (int i = 0; i <= 20; i += 5) { ItemStack s = new ItemStack(this); s.getOrCreateTag().putInt(TAG_LEVEL, i); list.add(s); @@ -98,11 +98,11 @@ public class ItemLaputaShard extends Item implements ILensEffect, ITinyPlanetExc public ActionResultType onItemUse(ItemUseContext ctx) { World world = ctx.getWorld(); BlockPos pos = ctx.getPos(); - if(!world.isRemote && pos.getY() < 160 && !world.getDimension().isNether()) { + if (!world.isRemote && pos.getY() < 160 && !world.getDimension().isNether()) { world.playSound(null, pos, ModSounds.laputaStart, SoundCategory.BLOCKS, 1.0F + world.rand.nextFloat(), world.rand.nextFloat() * 0.7F + 1.3F); ItemStack stack = ctx.getItem(); spawnBurstFirst(world, pos, stack); - if(ctx.getPlayer() != null) { + if (ctx.getPlayer() != null) { UseItemSuccessTrigger.INSTANCE.trigger((ServerPlayerEntity) ctx.getPlayer(), stack, (ServerWorld) world, pos.getX(), pos.getY(), pos.getZ()); } stack.shrink(1); @@ -114,7 +114,7 @@ public class ItemLaputaShard extends Item implements ILensEffect, ITinyPlanetExc public void spawnBurstFirst(World world, BlockPos pos, ItemStack shard) { int range = BASE_RANGE + getShardLevel(shard); boolean pointy = world.rand.nextDouble() < 0.25; - double heightscale = (world.rand.nextDouble() + 0.5) * ((double)BASE_RANGE / (double)range); + double heightscale = (world.rand.nextDouble() + 0.5) * ((double) BASE_RANGE / (double) range); spawnBurst(world, pos, shard, pointy, heightscale); } @@ -132,24 +132,26 @@ public class ItemLaputaShard extends Item implements ILensEffect, ITinyPlanetExc int j = ItemNBTHelper.getInt(shard, TAG_ITERATION_J, BASE_OFFSET - BASE_RANGE / 2); int k = ItemNBTHelper.getInt(shard, TAG_ITERATION_K, 0); - if(j <= -BASE_RANGE * 2) + if (j <= -BASE_RANGE * 2) { j = BASE_OFFSET - BASE_RANGE / 2; - if(k >= range * 2 + 1) + } + if (k >= range * 2 + 1) { k = 0; + } - if(!world.isRemote) { - for(; i < range * 2 + 1; i++) { - for(; j > -BASE_RANGE * 2; j--) { - for(; k < range * 2 + 1; k++) { + if (!world.isRemote) { + for (; i < range * 2 + 1; i++) { + for (; j > -BASE_RANGE * 2; j--) { + for (; k < range * 2 + 1; k++) { BlockPos pos_ = pos.add(-range + i, -BASE_RANGE + j, -range + k); - if(inRange(pos_, pos, range, heightscale, pointy)) { + if (inRange(pos_, pos, range, heightscale, pointy)) { BlockState state = world.getBlockState(pos_); Block block = state.getBlock(); - if(!block.isAir(state, world, pos_) && !(block instanceof FallingBlock) && (!(block instanceof ILaputaImmobile) || ((ILaputaImmobile) block).canMove(world, pos_)) && state.getBlockHardness(world, pos_) != -1) { + if (!block.isAir(state, world, pos_) && !(block instanceof FallingBlock) && (!(block instanceof ILaputaImmobile) || ((ILaputaImmobile) block).canMove(world, pos_)) && state.getBlockHardness(world, pos_) != -1) { TileEntity tile = world.getTileEntity(pos_); - if(tile != null) { + if (tile != null) { // Reset the TE so e.g. chests don't spawn their drops TileEntity newTile = block.createTileEntity(state, world); world.setTileEntity(pos_, newTile); @@ -160,8 +162,9 @@ public class ItemLaputaShard extends Item implements ILensEffect, ITinyPlanetExc copyLens.getOrCreateTag().putInt(TAG_LEVEL, getShardLevel(shard)); copyLens.getTag().put(TAG_STATE, NBTUtil.writeBlockState(state)); CompoundNBT cmp = new CompoundNBT(); - if(tile != null) + if (tile != null) { cmp = tile.write(cmp); + } ItemNBTHelper.setCompound(copyLens, TAG_TILE, cmp); ItemNBTHelper.setInt(copyLens, TAG_X, pos.getX()); ItemNBTHelper.setInt(copyLens, TAG_Y, pos.getY()); @@ -191,11 +194,13 @@ public class ItemLaputaShard extends Item implements ILensEffect, ITinyPlanetExc } private boolean inRange(BlockPos pos, BlockPos srcPos, int range, double heightscale, boolean pointy) { - if(pos.getY() >= srcPos.getY()) + if (pos.getY() >= srcPos.getY()) { return MathHelper.pointDistanceSpace(pos.getX(), 0, pos.getZ(), srcPos.getX(), 0, srcPos.getZ()) < range; - else if(!pointy) + } else if (!pointy) { return MathHelper.pointDistanceSpace(pos.getX(), pos.getY() / heightscale, pos.getZ(), srcPos.getX(), srcPos.getY() / heightscale, srcPos.getZ()) < range; - else return MathHelper.pointDistanceSpace(pos.getX(), 0, pos.getZ(), srcPos.getX(), 0, srcPos.getZ()) < range - (srcPos.getY() - pos.getY()) / heightscale; + } else { + return MathHelper.pointDistanceSpace(pos.getX(), 0, pos.getZ(), srcPos.getX(), 0, srcPos.getZ()) < range - (srcPos.getY() - pos.getY()) / heightscale; + } } public EntityManaBurst getBurst(World world, BlockPos pos, ItemStack stack) { @@ -227,7 +232,7 @@ public class ItemLaputaShard extends Item implements ILensEffect, ITinyPlanetExc double speed = 0.35; int targetDistance = BASE_OFFSET; ThrowableEntity entity = (ThrowableEntity) burst; - if(!entity.world.isRemote) { + if (!entity.world.isRemote) { entity.setMotion(0, speed, 0); final int spawnTicks = 2; @@ -235,20 +240,21 @@ public class ItemLaputaShard extends Item implements ILensEffect, ITinyPlanetExc ItemStack lens = burst.getSourceLens(); - if(burst.getTicksExisted() == spawnTicks) { + if (burst.getTicksExisted() == spawnTicks) { int x = ItemNBTHelper.getInt(lens, TAG_X, 0); int y = ItemNBTHelper.getInt(lens, TAG_Y, -1); int z = ItemNBTHelper.getInt(lens, TAG_Z, 0); - if(y != -1) + if (y != -1) { spawnBurst(entity.world, new BlockPos(x, y, z), lens); - } else if(burst.getTicksExisted() == placeTicks) { + } + } else if (burst.getTicksExisted() == placeTicks) { int x = net.minecraft.util.math.MathHelper.floor(entity.getX()); int y = ItemNBTHelper.getInt(lens, TAG_Y_START, -1) + targetDistance; int z = net.minecraft.util.math.MathHelper.floor(entity.getZ()); BlockPos pos = new BlockPos(x, y, z); - if(entity.world.isAirBlock(pos)) { + if (entity.world.isAirBlock(pos)) { BlockState state = Blocks.AIR.getDefaultState(); if (lens.hasTag() && lens.getTag().contains(TAG_STATE)) { state = NBTUtil.readBlockState(lens.getTag().getCompound(TAG_STATE)); @@ -256,12 +262,13 @@ public class ItemLaputaShard extends Item implements ILensEffect, ITinyPlanetExc TileEntity tile = null; CompoundNBT tilecmp = ItemNBTHelper.getCompound(lens, TAG_TILE, false); - if(tilecmp.contains("id")) + if (tilecmp.contains("id")) { tile = TileEntity.create(tilecmp); + } entity.world.setBlockState(pos, state); entity.world.playEvent(2001, pos, Block.getStateId(state)); - if(tile != null) { + if (tile != null) { tile.setPos(pos); entity.world.setTileEntity(pos, tile); } diff --git a/src/main/java/vazkii/botania/common/item/ItemLexicon.java b/src/main/java/vazkii/botania/common/item/ItemLexicon.java index 3a5671b91..4e7bfad2c 100644 --- a/src/main/java/vazkii/botania/common/item/ItemLexicon.java +++ b/src/main/java/vazkii/botania/common/item/ItemLexicon.java @@ -1,17 +1,14 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 14, 2014, 5:53:00 PM (GMT)] */ package vazkii.botania.common.item; import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.resources.I18n; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity; @@ -23,7 +20,6 @@ import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvent; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; @@ -32,9 +28,9 @@ import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.recipe.IElvenItem; import vazkii.botania.common.advancements.UseItemSuccessTrigger; -import vazkii.botania.common.core.helper.MathHelper; import vazkii.botania.common.lib.LibMisc; import vazkii.patchouli.common.base.PatchouliSounds; import vazkii.patchouli.common.book.Book; @@ -43,11 +39,12 @@ import vazkii.patchouli.common.network.NetworkHandler; import vazkii.patchouli.common.network.message.MessageOpenBookGui; import javax.annotation.Nonnull; + import java.util.List; public class ItemLexicon extends Item implements IElvenItem { - public static final String TAG_ELVEN_UNLOCK = "botania:elven_unlock"; + public static final String TAG_ELVEN_UNLOCK = "botania:elven_unlock"; public ItemLexicon(Properties props) { super(props); @@ -60,7 +57,7 @@ public class ItemLexicon extends Item implements IElvenItem { @Override public void fillItemGroup(@Nonnull ItemGroup tab, @Nonnull NonNullList list) { - if(isInGroup(tab)) { + if (isInGroup(tab)) { list.add(new ItemStack(this)); ItemStack creative = new ItemStack(this); creative.getOrCreateTag().putBoolean(TAG_ELVEN_UNLOCK, true); @@ -75,8 +72,9 @@ public class ItemLexicon extends Item implements IElvenItem { if (Screen.hasShiftDown()) { Book book = getBook(); - if(book.contents != null) + if (book.contents != null) { tooltip.add(new StringTextComponent(book.contents.getSubtitle()).applyTextStyle(TextFormatting.GRAY)); + } } else { tooltip.add(new TranslationTextComponent("botaniamisc.shiftinfo")); } @@ -88,8 +86,8 @@ public class ItemLexicon extends Item implements IElvenItem { ItemStack stack = playerIn.getHeldItem(handIn); Book book = getBook(); - if(playerIn instanceof ServerPlayerEntity) { - ServerPlayerEntity player= (ServerPlayerEntity) playerIn; + if (playerIn instanceof ServerPlayerEntity) { + ServerPlayerEntity player = (ServerPlayerEntity) playerIn; UseItemSuccessTrigger.INSTANCE.trigger(player, stack, player.getServerWorld(), player.getX(), player.getY(), player.getZ()); NetworkHandler.sendToPlayer(new MessageOpenBookGui(book.id), (ServerPlayerEntity) playerIn); SoundEvent sfx = PatchouliSounds.getSound(book.openSound, PatchouliSounds.book_open); @@ -107,15 +105,15 @@ public class ItemLexicon extends Item implements IElvenItem { ITextComponent title = stack.getDisplayName(); String akashicTomeNBT = "akashictome:displayName"; - if(stack.hasTag() && stack.getTag().contains(akashicTomeNBT)) { + if (stack.hasTag() && stack.getTag().contains(akashicTomeNBT)) { title = new StringTextComponent(stack.getTag().getString(akashicTomeNBT)); } - + return title; } - + @Override public boolean isElvenItem(ItemStack stack) { - return stack.hasTag() && stack.getTag().getBoolean(TAG_ELVEN_UNLOCK); + return stack.hasTag() && stack.getTag().getBoolean(TAG_ELVEN_UNLOCK); } } diff --git a/src/main/java/vazkii/botania/common/item/ItemManaCookie.java b/src/main/java/vazkii/botania/common/item/ItemManaCookie.java index 49b07927f..cea65083a 100644 --- a/src/main/java/vazkii/botania/common/item/ItemManaCookie.java +++ b/src/main/java/vazkii/botania/common/item/ItemManaCookie.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 21, 2014, 8:44:35 PM (GMT)] */ package vazkii.botania.common.item; import net.minecraft.item.Item; import net.minecraft.util.ResourceLocation; + import vazkii.botania.common.lib.LibMisc; import java.util.Locale; diff --git a/src/main/java/vazkii/botania/common/item/ItemManaGun.java b/src/main/java/vazkii/botania/common/item/ItemManaGun.java index 98e04acce..0324ed958 100644 --- a/src/main/java/vazkii/botania/common/item/ItemManaGun.java +++ b/src/main/java/vazkii/botania/common/item/ItemManaGun.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 13, 2014, 4:30:27 PM (GMT)] */ package vazkii.botania.common.item; @@ -22,7 +20,6 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Effects; import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; @@ -31,9 +28,9 @@ import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.mana.BurstProperties; import vazkii.botania.api.mana.ILens; import vazkii.botania.api.mana.IManaUsingItem; @@ -45,6 +42,7 @@ import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.entity.EntityManaBurst; import javax.annotation.Nonnull; + import java.util.ArrayList; import java.util.List; @@ -73,22 +71,24 @@ public class ItemManaGun extends Item implements IManaUsingItem { ItemStack stack = player.getHeldItem(hand); int effCd = COOLDOWN; EffectInstance effect = player.getActivePotionEffect(Effects.HASTE); - if(effect != null) + if (effect != null) { effCd -= (effect.getAmplifier() + 1) * 8; + } - if(player.isSneaking() && hasClip(stack)) { + if (player.isSneaking() && hasClip(stack)) { rotatePos(stack); world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.BLOCK_STONE_BUTTON_CLICK_ON, SoundCategory.PLAYERS, 0.6F, (1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F); - if(world.isRemote) + if (world.isRemote) { player.swingArm(hand); + } ItemStack lens = getLens(stack); ItemsRemainingRenderHandler.set(lens, -2); stack.setDamage(effCd); return ActionResult.success(stack); - } else if(stack.getDamage() == 0) { + } else if (stack.getDamage() == 0) { EntityManaBurst burst = getBurst(player, stack, true, hand); - if(burst != null && ManaItemHandler.requestManaExact(stack, player, burst.getMana(), true)) { - if(!world.isRemote) { + if (burst != null && ManaItemHandler.requestManaExact(stack, player, burst.getMana(), true)) { + if (!world.isRemote) { world.playSound(null, player.getX(), player.getY(), player.getZ(), ModSounds.manaBlaster, SoundCategory.PLAYERS, 0.6F, 1); world.addEntity(burst); ManaGunTrigger.INSTANCE.trigger((ServerPlayerEntity) player, stack); @@ -97,8 +97,9 @@ public class ItemManaGun extends Item implements IManaUsingItem { player.setMotion(player.getMotion().subtract(burst.getMotion().mul(0.1, 0.3, 0.1))); } stack.setDamage(effCd); - } else if(!world.isRemote) + } else if (!world.isRemote) { world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.BLOCK_LEVER_CLICK, SoundCategory.PLAYERS, 0.6F, (1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F); + } return ActionResult.success(stack); } @@ -145,8 +146,9 @@ public class ItemManaGun extends Item implements IManaUsingItem { BurstProperties props = new BurstProperties(maxMana, ticksBeforeManaLoss, manaLossPerTick, gravity, motionModifier, color); ItemStack lens = getLens(stack); - if(!lens.isEmpty()) + if (!lens.isEmpty()) { ((ILens) lens.getItem()).apply(lens, props); + } return props; } @@ -155,7 +157,7 @@ public class ItemManaGun extends Item implements IManaUsingItem { BurstProperties props = getBurstProps(player, stack, request, hand); burst.setSourceLens(getLens(stack)); - if(!request || ManaItemHandler.requestManaExact(stack, player, props.maxMana, false)) { + if (!request || ManaItemHandler.requestManaExact(stack, player, props.maxMana, false)) { burst.setColor(props.color); burst.setMana(props.maxMana); burst.setStartingMana(props.maxMana); @@ -175,28 +177,31 @@ public class ItemManaGun extends Item implements IManaUsingItem { @Override public void addInformation(ItemStack stack, World world, List stacks, ITooltipFlag flags) { boolean clip = hasClip(stack); - if(clip && !Screen.hasShiftDown()) { + if (clip && !Screen.hasShiftDown()) { stacks.add(new TranslationTextComponent("botaniamisc.shiftinfo")); return; } ItemStack lens = getLens(stack); - if(!lens.isEmpty()) { + if (!lens.isEmpty()) { List tooltip = lens.getTooltip(Minecraft.getInstance().player, ITooltipFlag.TooltipFlags.NORMAL); - if(tooltip.size() > 1) + if (tooltip.size() > 1) { stacks.addAll(tooltip.subList(1, tooltip.size())); + } } - if(clip) { + if (clip) { int pos = getClipPos(stack); stacks.add(new TranslationTextComponent("botaniamisc.hasClip")); - for(int i = 0; i < CLIP_SLOTS; i++) { + for (int i = 0; i < CLIP_SLOTS; i++) { ItemStack lensAt = getLensAtPos(stack, i); ITextComponent name; - if(lensAt.isEmpty()) + if (lensAt.isEmpty()) { name = new TranslationTextComponent("botaniamisc.clipEmpty"); - else name = lensAt.getDisplayName(); + } else { + name = lensAt.getDisplayName(); + } ITextComponent tip = new StringTextComponent(" - ").appendSibling(name); tip.getStyle().setColor(i == pos ? TextFormatting.GREEN : TextFormatting.GRAY); @@ -240,14 +245,16 @@ public class ItemManaGun extends Item implements IManaUsingItem { int[] slots = new int[CLIP_SLOTS - 1]; int index = 0; - for(int i = currPos + 1; i < CLIP_SLOTS; i++, index++) + for (int i = currPos + 1; i < CLIP_SLOTS; i++, index++) { slots[index] = i; - for(int i = 0; i < currPos; i++, index++) + } + for (int i = 0; i < currPos; i++, index++) { slots[index] = i; + } - for(int i : slots) { + for (int i : slots) { ItemStack lensAt = getLensAtPos(stack, i); - if(acceptEmpty || !lensAt.isEmpty()) { + if (acceptEmpty || !lensAt.isEmpty()) { setClipPos(stack, i); return; } @@ -256,7 +263,7 @@ public class ItemManaGun extends Item implements IManaUsingItem { public static ItemStack getLensAtPos(ItemStack stack, int pos) { CompoundNBT cmp = ItemNBTHelper.getCompound(stack, TAG_LENS + pos, true); - if(cmp != null) { + if (cmp != null) { return ItemStack.read(cmp); } return ItemStack.EMPTY; @@ -264,27 +271,31 @@ public class ItemManaGun extends Item implements IManaUsingItem { public static void setLensAtPos(ItemStack stack, ItemStack lens, int pos) { CompoundNBT cmp = new CompoundNBT(); - if(lens != null) + if (lens != null) { cmp = lens.write(cmp); + } ItemNBTHelper.setCompound(stack, TAG_LENS + pos, cmp); } public static void setLens(ItemStack stack, ItemStack lens) { - if(hasClip(stack)) + if (hasClip(stack)) { setLensAtPos(stack, lens, getClipPos(stack)); + } CompoundNBT cmp = new CompoundNBT(); - if(!lens.isEmpty()) + if (!lens.isEmpty()) { cmp = lens.write(cmp); + } ItemNBTHelper.setCompound(stack, TAG_LENS, cmp); } public static ItemStack getLens(ItemStack stack) { - if(hasClip(stack)) + if (hasClip(stack)) { return getLensAtPos(stack, getClipPos(stack)); + } CompoundNBT cmp = ItemNBTHelper.getCompound(stack, TAG_LENS, true); - if(cmp != null) { + if (cmp != null) { return ItemStack.read(cmp); } return ItemStack.EMPTY; @@ -302,8 +313,9 @@ public class ItemManaGun extends Item implements IManaUsingItem { @Override public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) { - if(stack.isDamaged()) + if (stack.isDamaged()) { stack.setDamage(stack.getDamage() - 1); + } } @Override diff --git a/src/main/java/vazkii/botania/common/item/ItemManaMirror.java b/src/main/java/vazkii/botania/common/item/ItemManaMirror.java index 495c8c1ca..0d4eee2e3 100644 --- a/src/main/java/vazkii/botania/common/item/ItemManaMirror.java +++ b/src/main/java/vazkii/botania/common/item/ItemManaMirror.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 13, 2014, 5:39:24 PM (GMT)] */ package vazkii.botania.common.item; @@ -25,6 +23,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.dimension.DimensionType; import net.minecraftforge.fml.server.ServerLifecycleHooks; + import vazkii.botania.api.mana.IManaItem; import vazkii.botania.api.mana.IManaPool; import vazkii.botania.api.mana.IManaTooltipDisplay; @@ -63,14 +62,15 @@ public class ItemManaMirror extends Item implements IManaItem, ICoordBoundItem, @Override public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) { - if(world.isRemote) + if (world.isRemote) { return; + } IManaPool pool = getManaPool(stack); - if(!(pool instanceof DummyPool)) { - if(pool == null) + if (!(pool instanceof DummyPool)) { + if (pool == null) { setMana(stack, 0); - else { + } else { pool.recieveMana(getManaBacklog(stack)); setManaBacklog(stack, 0); setMana(stack, pool.getCurrentMana()); @@ -84,9 +84,9 @@ public class ItemManaMirror extends Item implements IManaItem, ICoordBoundItem, World world = ctx.getWorld(); PlayerEntity player = ctx.getPlayer(); - if(player != null && player.isSneaking() && !world.isRemote) { + if (player != null && player.isSneaking() && !world.isRemote) { TileEntity tile = world.getTileEntity(ctx.getPos()); - if(tile instanceof IManaPool) { + if (tile instanceof IManaPool) { bindPool(ctx.getItem(), tile); world.playSound(null, player.getX(), player.getY(), player.getZ(), ModSounds.ding, SoundCategory.PLAYERS, 1F, 1F); return ActionResultType.SUCCESS; @@ -144,20 +144,23 @@ public class ItemManaMirror extends Item implements IManaItem, ICoordBoundItem, public IManaPool getManaPool(ItemStack stack) { MinecraftServer server = ServerLifecycleHooks.getCurrentServer(); - if(server == null) + if (server == null) { return fallbackPool; + } BlockPos coords = getPoolCoords(stack); - if(coords.getY() == -1) + if (coords.getY() == -1) { return null; + } ResourceLocation dim = new ResourceLocation(getDimension(stack)); DimensionType type = DimensionType.byName(dim); if (type != null) { World world = server.getWorld(type); TileEntity tile = world.getTileEntity(coords); - if(tile instanceof IManaPool) + if (tile instanceof IManaPool) { return (IManaPool) tile; + } } return null; diff --git a/src/main/java/vazkii/botania/common/item/ItemManaTablet.java b/src/main/java/vazkii/botania/common/item/ItemManaTablet.java index 58b2148ab..ccc3be433 100644 --- a/src/main/java/vazkii/botania/common/item/ItemManaTablet.java +++ b/src/main/java/vazkii/botania/common/item/ItemManaTablet.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 7, 2014, 7:06:20 PM (GMT)] */ package vazkii.botania.common.item; @@ -23,12 +21,14 @@ import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.mana.ICreativeManaProvider; import vazkii.botania.api.mana.IManaItem; import vazkii.botania.api.mana.IManaTooltipDisplay; import vazkii.botania.common.core.helper.ItemNBTHelper; import javax.annotation.Nonnull; + import java.util.List; public class ItemManaTablet extends Item implements IManaItem, ICreativeManaProvider, IManaTooltipDisplay { @@ -45,7 +45,7 @@ public class ItemManaTablet extends Item implements IManaItem, ICreativeManaProv @Override public void fillItemGroup(@Nonnull ItemGroup tab, @Nonnull NonNullList stacks) { - if(isInGroup(tab)) { + if (isInGroup(tab)) { stacks.add(new ItemStack(this)); ItemStack fullPower = new ItemStack(this); @@ -62,8 +62,9 @@ public class ItemManaTablet extends Item implements IManaItem, ICreativeManaProv @OnlyIn(Dist.CLIENT) @Override public void addInformation(ItemStack stack, World world, List stacks, ITooltipFlag flags) { - if(isStackCreative(stack)) + if (isStackCreative(stack)) { stacks.add(new TranslationTextComponent("botaniamisc.creative").applyTextStyle(TextFormatting.GRAY)); + } } @Override @@ -95,8 +96,9 @@ public class ItemManaTablet extends Item implements IManaItem, ICreativeManaProv @Override public void addMana(ItemStack stack, int mana) { - if(!isStackCreative(stack)) + if (!isStackCreative(stack)) { setMana(stack, Math.min(getMana(stack) + mana, MAX_MANA)); + } } @Override @@ -134,7 +136,6 @@ public class ItemManaTablet extends Item implements IManaItem, ICreativeManaProv return (float) getMana(stack) / (float) getMaxMana(stack); } - @Override public boolean showDurabilityBar(ItemStack stack) { return !isStackCreative(stack); diff --git a/src/main/java/vazkii/botania/common/item/ItemObedienceStick.java b/src/main/java/vazkii/botania/common/item/ItemObedienceStick.java index d0f782bc8..0461dda73 100644 --- a/src/main/java/vazkii/botania/common/item/ItemObedienceStick.java +++ b/src/main/java/vazkii/botania/common/item/ItemObedienceStick.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 20, 2015, 7:26:14 PM (GMT)] */ package vazkii.botania.common.item; @@ -16,14 +14,15 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ActionResultType; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import vazkii.botania.api.mana.IManaCollector; import vazkii.botania.api.mana.IManaPool; import vazkii.botania.api.subtile.TileEntityFunctionalFlower; import vazkii.botania.api.subtile.TileEntityGeneratingFlower; import vazkii.botania.api.subtile.TileEntitySpecialFlower; -import vazkii.botania.common.core.helper.Vector3; import javax.annotation.Nonnull; + import java.util.function.BiFunction; public class ItemObedienceStick extends Item { @@ -39,20 +38,21 @@ public class ItemObedienceStick extends Item { BlockPos pos = ctx.getPos(); TileEntity tileAt = world.getTileEntity(pos); - if(tileAt instanceof IManaPool || tileAt instanceof IManaCollector) { + if (tileAt instanceof IManaPool || tileAt instanceof IManaCollector) { boolean pool = tileAt instanceof IManaPool; BiFunction act = pool ? functionalActuator : generatingActuator; int range = pool ? TileEntityFunctionalFlower.LINK_RANGE : TileEntityGeneratingFlower.LINK_RANGE; - for(BlockPos iterPos : BlockPos.getAllInBoxMutable(pos.add(-range, -range, -range), + for (BlockPos iterPos : BlockPos.getAllInBoxMutable(pos.add(-range, -range, -range), pos.add(range, range, range))) { - if(iterPos.distanceSq(pos) > range * range) + if (iterPos.distanceSq(pos) > range * range) { continue; + } TileEntity tile = world.getTileEntity(iterPos); - if(tile instanceof TileEntitySpecialFlower) { + if (tile instanceof TileEntitySpecialFlower) { TileEntitySpecialFlower subtile = ((TileEntitySpecialFlower) tile); - if(act.apply(subtile, tileAt)) { + if (act.apply(subtile, tileAt)) { ItemTwigWand.doParticleBeamWithOffset(world, iterPos, pos); } } @@ -65,7 +65,7 @@ public class ItemObedienceStick extends Item { } private static final BiFunction generatingActuator = (flower, tile) -> { - if(flower instanceof TileEntityGeneratingFlower) { + if (flower instanceof TileEntityGeneratingFlower) { ((TileEntityGeneratingFlower) flower).linkToForcefully(tile); return true; } @@ -73,7 +73,7 @@ public class ItemObedienceStick extends Item { }; private static final BiFunction functionalActuator = (flower, tile) -> { - if(flower instanceof TileEntityFunctionalFlower) { + if (flower instanceof TileEntityFunctionalFlower) { ((TileEntityFunctionalFlower) flower).linkToForcefully(tile); return true; } diff --git a/src/main/java/vazkii/botania/common/item/ItemOpenBucket.java b/src/main/java/vazkii/botania/common/item/ItemOpenBucket.java index e8d9fcc1e..aac91c0cd 100644 --- a/src/main/java/vazkii/botania/common/item/ItemOpenBucket.java +++ b/src/main/java/vazkii/botania/common/item/ItemOpenBucket.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 20, 2014, 12:12:58 AM (GMT)] */ package vazkii.botania.common.item; @@ -47,28 +45,31 @@ public class ItemOpenBucket extends Item { ItemStack itemstack = playerIn.getHeldItem(handIn); RayTraceResult raytraceresult = rayTrace(worldIn, playerIn, RayTraceContext.FluidMode.SOURCE_ONLY); ActionResult ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(playerIn, worldIn, itemstack, raytraceresult); - if (ret != null) return ret; + if (ret != null) { + return ret; + } if (raytraceresult.getType() == RayTraceResult.Type.MISS) { return new ActionResult<>(ActionResultType.PASS, itemstack); } else if (raytraceresult.getType() != RayTraceResult.Type.BLOCK) { return new ActionResult<>(ActionResultType.PASS, itemstack); } else { - BlockRayTraceResult blockraytraceresult = (BlockRayTraceResult)raytraceresult; + BlockRayTraceResult blockraytraceresult = (BlockRayTraceResult) raytraceresult; BlockPos blockpos = blockraytraceresult.getPos(); if (worldIn.isBlockModifiable(playerIn, blockpos) && playerIn.canPlayerEdit(blockpos, blockraytraceresult.getFace(), itemstack)) { BlockState blockstate1 = worldIn.getBlockState(blockpos); if (blockstate1.getBlock() instanceof IBucketPickupHandler) { - Fluid fluid = ((IBucketPickupHandler)blockstate1.getBlock()).pickupFluid(worldIn, blockpos, blockstate1); + Fluid fluid = ((IBucketPickupHandler) blockstate1.getBlock()).pickupFluid(worldIn, blockpos, blockstate1); if (fluid != Fluids.EMPTY) { playerIn.addStat(Stats.ITEM_USED.get(this)); playerIn.playSound(fluid.isIn(FluidTags.LAVA) ? SoundEvents.ITEM_BUCKET_FILL_LAVA : SoundEvents.ITEM_BUCKET_FILL, 1.0F, 1.0F); // Botania: some particles - for(int x = 0; x < 5; x++) + for (int x = 0; x < 5; x++) { worldIn.addParticle(ParticleTypes.POOF, blockpos.getX() + Math.random(), blockpos.getY() + Math.random(), blockpos.getZ() + Math.random(), 0, 0, 0); + } ItemStack itemstack1 = itemstack; // this.fillBucket(itemstack, playerIn, fluid.getFilledBucket()); if (!worldIn.isRemote) { - CriteriaTriggers.FILLED_BUCKET.trigger((ServerPlayerEntity)playerIn, new ItemStack(fluid.getFilledBucket())); + CriteriaTriggers.FILLED_BUCKET.trigger((ServerPlayerEntity) playerIn, new ItemStack(fluid.getFilledBucket())); } return new ActionResult<>(ActionResultType.SUCCESS, itemstack1); @@ -82,6 +83,4 @@ public class ItemOpenBucket extends Item { } } - - } diff --git a/src/main/java/vazkii/botania/common/item/ItemOvergrowthSeed.java b/src/main/java/vazkii/botania/common/item/ItemOvergrowthSeed.java index 83d6fd46b..91315b791 100644 --- a/src/main/java/vazkii/botania/common/item/ItemOvergrowthSeed.java +++ b/src/main/java/vazkii/botania/common/item/ItemOvergrowthSeed.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 26, 2015, 5:59:21 PM (GMT)] */ package vazkii.botania.common.item; @@ -18,6 +16,7 @@ import net.minecraft.item.ItemUseContext; import net.minecraft.util.ActionResultType; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import vazkii.botania.common.block.ModBlocks; import javax.annotation.Nonnull; @@ -36,8 +35,8 @@ public class ItemOvergrowthSeed extends Item { // todo 1.13 grass tag BlockState state = world.getBlockState(pos); - if(state.getBlock() == Blocks.GRASS_BLOCK) { - if(!world.isRemote) { + if (state.getBlock() == Blocks.GRASS_BLOCK) { + if (!world.isRemote) { world.playEvent(2001, pos, Block.getStateId(state)); world.setBlockState(pos, ModBlocks.enchantedSoil.getDefaultState()); ctx.getItem().shrink(1); diff --git a/src/main/java/vazkii/botania/common/item/ItemPinkinator.java b/src/main/java/vazkii/botania/common/item/ItemPinkinator.java index d730889b7..531398a97 100644 --- a/src/main/java/vazkii/botania/common/item/ItemPinkinator.java +++ b/src/main/java/vazkii/botania/common/item/ItemPinkinator.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 25, 2015, 6:03:28 PM (GMT)] */ package vazkii.botania.common.item; @@ -18,7 +16,6 @@ import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.SoundEvents; import net.minecraft.util.math.AxisAlignedBB; @@ -30,10 +27,12 @@ import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.common.advancements.UseItemSuccessTrigger; import vazkii.botania.common.entity.EntityPinkWither; import javax.annotation.Nonnull; + import java.util.List; public class ItemPinkinator extends Item { @@ -48,8 +47,8 @@ public class ItemPinkinator extends Item { ItemStack stack = player.getHeldItem(hand); int range = 16; List withers = world.getEntitiesWithinAABB(WitherEntity.class, new AxisAlignedBB(player.getX() - range, player.getY() - range, player.getZ() - range, player.getX() + range, player.getY() + range, player.getZ() + range)); - for(WitherEntity wither : withers) - if(!world.isRemote && wither.isAlive() && !(wither instanceof EntityPinkWither)) { + for (WitherEntity wither : withers) { + if (!world.isRemote && wither.isAlive() && !(wither instanceof EntityPinkWither)) { wither.remove(); EntityPinkWither pink = new EntityPinkWither(world); pink.setLocationAndAngles(wither.getX(), wither.getY(), wither.getZ(), wither.rotationYaw, wither.rotationPitch); @@ -66,6 +65,7 @@ public class ItemPinkinator extends Item { stack.shrink(1); return ActionResult.success(stack); } + } return ActionResult.pass(stack); } diff --git a/src/main/java/vazkii/botania/common/item/ItemPoolMinecart.java b/src/main/java/vazkii/botania/common/item/ItemPoolMinecart.java index 509a91004..81a98762d 100644 --- a/src/main/java/vazkii/botania/common/item/ItemPoolMinecart.java +++ b/src/main/java/vazkii/botania/common/item/ItemPoolMinecart.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 17, 2015, 6:48:29 PM (GMT)] */ package vazkii.botania.common.item; @@ -21,6 +19,7 @@ import net.minecraft.tags.BlockTags; import net.minecraft.util.ActionResultType; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import vazkii.botania.common.entity.EntityPoolMinecart; import javax.annotation.Nonnull; @@ -43,7 +42,7 @@ public class ItemPoolMinecart extends Item { } else { ItemStack itemstack = context.getItem(); if (!world.isRemote) { - RailShape railshape = iblockstate.getBlock() instanceof AbstractRailBlock ? ((AbstractRailBlock)iblockstate.getBlock()).getRailDirection(iblockstate, world, blockpos, null) : RailShape.NORTH_SOUTH; + RailShape railshape = iblockstate.getBlock() instanceof AbstractRailBlock ? ((AbstractRailBlock) iblockstate.getBlock()).getRailDirection(iblockstate, world, blockpos, null) : RailShape.NORTH_SOUTH; double d0 = 0.0D; if (railshape.isAscending()) { d0 = 0.5D; diff --git a/src/main/java/vazkii/botania/common/item/ItemSextant.java b/src/main/java/vazkii/botania/common/item/ItemSextant.java index dff3d50c6..549e8ae1d 100644 --- a/src/main/java/vazkii/botania/common/item/ItemSextant.java +++ b/src/main/java/vazkii/botania/common/item/ItemSextant.java @@ -1,17 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [01/11/2015, 18:25:54 (GMT)] */ package vazkii.botania.common.item; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.block.Blocks; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; @@ -23,19 +21,19 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.UseAction; import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceContext; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import org.lwjgl.opengl.GL11; + import vazkii.botania.client.fx.WispParticleData; import vazkii.botania.common.Botania; import vazkii.botania.common.core.helper.ItemNBTHelper; @@ -47,6 +45,7 @@ import vazkii.patchouli.api.PatchouliAPI; import vazkii.patchouli.common.multiblock.AbstractMultiblock; import javax.annotation.Nonnull; + import java.util.HashMap; import java.util.Map; @@ -76,19 +75,20 @@ public class ItemSextant extends Item { @Override public void onUsingTick(ItemStack stack, LivingEntity living, int count) { - if(getUseDuration(stack) - count < 10 - || !(living instanceof PlayerEntity)) + if (getUseDuration(stack) - count < 10 + || !(living instanceof PlayerEntity)) { return; + } int x = ItemNBTHelper.getInt(stack, TAG_SOURCE_X, 0); int y = ItemNBTHelper.getInt(stack, TAG_SOURCE_Y, -1); int z = ItemNBTHelper.getInt(stack, TAG_SOURCE_Z, 0); - if(y != -1) { + if (y != -1) { Vector3 source = new Vector3(x, y, z); double radius = calculateRadius(stack, (PlayerEntity) living); - if(count % 10 == 0) { + if (count % 10 == 0) { WispParticleData data = WispParticleData.wisp(0.3F, 0F, 1F, 1F, 1); for (int i = 0; i < 360; i++) { float radian = (float) (i * Math.PI / 180); @@ -102,25 +102,29 @@ public class ItemSextant extends Item { @Override public void onPlayerStoppedUsing(ItemStack stack, World world, LivingEntity living, int time) { - if(!(living instanceof PlayerEntity)) return; + if (!(living instanceof PlayerEntity)) { + return; + } double radius = calculateRadius(stack, (PlayerEntity) living); - if(1 < radius && radius <= MAX_RADIUS) { + if (1 < radius && radius <= MAX_RADIUS) { IStateMatcher matcher = PatchouliAPI.instance.predicateMatcher(Blocks.COBBLESTONE, s -> !s.isAir()); int x = ItemNBTHelper.getInt(stack, TAG_SOURCE_X, 0); int y = ItemNBTHelper.getInt(stack, TAG_SOURCE_Y, -1); int z = ItemNBTHelper.getInt(stack, TAG_SOURCE_Z, 0); int iradius = (int) radius + 1; - if(y != -1) { + if (y != -1) { Map map = new HashMap<>(); - for(int i = 0; i < iradius * 2 + 1; i++) - for(int j = 0; j < iradius * 2 + 1; j++) { + for (int i = 0; i < iradius * 2 + 1; i++) { + for (int j = 0; j < iradius * 2 + 1; j++) { int xp = x + i - iradius; int zp = z + j - iradius; - if((int) Math.floor(MathHelper.pointDistancePlane(xp, zp, x, z)) == iradius - 1) + if ((int) Math.floor(MathHelper.pointDistancePlane(xp, zp, x, z)) == iradius - 1) { map.put(new BlockPos(xp - x, 0, zp - z), matcher); + } } + } AbstractMultiblock sparse = (AbstractMultiblock) PatchouliAPI.instance.makeSparseMultiblock(map).setId(MULTIBLOCK_ID); Botania.proxy.showMultiblock(sparse, "r = " + (int) radius, new BlockPos(x, y, z), Rotation.NONE); } @@ -138,10 +142,10 @@ public class ItemSextant extends Item { @Override public ActionResult onItemRightClick(World world, PlayerEntity player, @Nonnull Hand hand) { ItemStack stack = player.getHeldItem(hand); - if(!player.isSneaking()) { + if (!player.isSneaking()) { BlockRayTraceResult rtr = ToolCommons.raytraceFromEntity(player, 128, false); - if(rtr.getType() == RayTraceResult.Type.BLOCK) { - if(!world.isRemote) { + if (rtr.getType() == RayTraceResult.Type.BLOCK) { + if (!world.isRemote) { BlockPos pos = rtr.getPos(); ItemNBTHelper.setInt(stack, TAG_SOURCE_X, pos.getX()); ItemNBTHelper.setInt(stack, TAG_SOURCE_Y, pos.getY()); @@ -164,7 +168,7 @@ public class ItemSextant extends Item { WispParticleData data = WispParticleData.wisp(0.2F, 1F, 0F, 0F, 1); player.world.addParticle(data, source.x + 0.5, source.y + 1, source.z + 0.5, 0, - -0.1F, 0); - Vector3 centerVec = Vector3.fromEntityCenter(player); + Vector3 centerVec = Vector3.fromEntityCenter(player); Vector3 diffVec = source.subtract(centerVec); Vector3 lookVec = new Vector3(player.getLookVec()); double mul = diffVec.y / lookVec.y; @@ -182,7 +186,7 @@ public class ItemSextant extends Item { ItemStack onUse = player.getActiveItemStack(); int time = player.getItemInUseCount(); - if(onUse == stack && stack.getItem().getUseDuration(stack) - time >= 10) { + if (onUse == stack && stack.getItem().getUseDuration(stack) - time >= 10) { double radius = calculateRadius(stack, player); FontRenderer font = Minecraft.getInstance().fontRenderer; int x = Minecraft.getInstance().getWindow().getScaledWidth() / 2 + 30; @@ -190,18 +194,19 @@ public class ItemSextant extends Item { String s = Integer.toString((int) radius); boolean inRange = 0 < radius && radius <= MAX_RADIUS; - if (!inRange) + if (!inRange) { s = TextFormatting.RED + s; + } font.drawStringWithShadow(s, x - font.getStringWidth(s) / 2, y - 4, 0xFFFFFF); - if(inRange) { + if (inRange) { radius += 4; RenderSystem.disableTexture(); RenderSystem.lineWidth(3F); Tessellator.getInstance().getBuffer().begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION); RenderSystem.color4f(0F, 1F, 1F, 1F); - for(int i = 0; i < 361; i++) { + for (int i = 0; i < 361; i++) { float radian = (float) (i * Math.PI / 180); double xp = x + Math.cos(radian) * radius; double yp = y + Math.sin(radian) * radius; diff --git a/src/main/java/vazkii/botania/common/item/ItemSlimeBottle.java b/src/main/java/vazkii/botania/common/item/ItemSlimeBottle.java index bc64e1273..c2dcdde15 100644 --- a/src/main/java/vazkii/botania/common/item/ItemSlimeBottle.java +++ b/src/main/java/vazkii/botania/common/item/ItemSlimeBottle.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 17, 2015, 1:32:58 AM (GMT)] */ package vazkii.botania.common.item; @@ -16,6 +14,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import vazkii.botania.common.block.subtile.generating.SubTileNarslimmus; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.lib.LibMisc; @@ -30,7 +29,7 @@ public class ItemSlimeBottle extends Item { @Override public void inventoryTick(ItemStack stack, World world, Entity entity, int something, boolean somethingelse) { - if(!world.isRemote) { + if (!world.isRemote) { boolean slime = SubTileNarslimmus.isSlimeChunk(world, new BlockPos(entity)); ItemNBTHelper.setBoolean(stack, TAG_ACTIVE, slime); } diff --git a/src/main/java/vazkii/botania/common/item/ItemSlingshot.java b/src/main/java/vazkii/botania/common/item/ItemSlingshot.java index b861dd6e9..949c135d9 100644 --- a/src/main/java/vazkii/botania/common/item/ItemSlingshot.java +++ b/src/main/java/vazkii/botania/common/item/ItemSlingshot.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 27, 2014, 12:38:58 AM (GMT)] */ package vazkii.botania.common.item; @@ -16,15 +14,16 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.UseAction; import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; import net.minecraft.world.World; + import vazkii.botania.common.core.helper.PlayerHelper; import vazkii.botania.common.entity.EntityVineBall; import javax.annotation.Nonnull; + import java.util.function.Predicate; public class ItemSlingshot extends Item { @@ -39,15 +38,17 @@ public class ItemSlingshot extends Item { public void onPlayerStoppedUsing(ItemStack stack, World world, LivingEntity living, int duration) { int j = getUseDuration(stack) - duration; - if(!world.isRemote && (!(living instanceof PlayerEntity) || ((PlayerEntity) living).abilities.isCreativeMode || PlayerHelper.hasAmmo((PlayerEntity) living, AMMO_FUNC))) { + if (!world.isRemote && (!(living instanceof PlayerEntity) || ((PlayerEntity) living).abilities.isCreativeMode || PlayerHelper.hasAmmo((PlayerEntity) living, AMMO_FUNC))) { float f = j / 20.0F; f = (f * f + f * 2.0F) / 3.0F; - if(f < 1F) + if (f < 1F) { return; + } - if(living instanceof PlayerEntity && !((PlayerEntity) living).abilities.isCreativeMode) + if (living instanceof PlayerEntity && !((PlayerEntity) living).abilities.isCreativeMode) { PlayerHelper.consumeAmmo((PlayerEntity) living, AMMO_FUNC); + } EntityVineBall ball = new EntityVineBall(living, false); ball.shoot(living, living.rotationPitch, living.rotationYaw, 0F, 1.5F, 1F); @@ -72,7 +73,7 @@ public class ItemSlingshot extends Item { @Override public ActionResult onItemRightClick(World world, PlayerEntity player, @Nonnull Hand hand) { ItemStack stack = player.getHeldItem(hand); - if(player.abilities.isCreativeMode || PlayerHelper.hasAmmo(player, AMMO_FUNC)) { + if (player.abilities.isCreativeMode || PlayerHelper.hasAmmo(player, AMMO_FUNC)) { player.setActiveHand(hand); return ActionResult.success(stack); } diff --git a/src/main/java/vazkii/botania/common/item/ItemSpark.java b/src/main/java/vazkii/botania/common/item/ItemSpark.java index 50145a8e0..b4567114b 100644 --- a/src/main/java/vazkii/botania/common/item/ItemSpark.java +++ b/src/main/java/vazkii/botania/common/item/ItemSpark.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 21, 2014, 5:24:55 PM (GMT)] */ package vazkii.botania.common.item; @@ -17,6 +15,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ActionResultType; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.mana.IManaGivingItem; import vazkii.botania.api.mana.spark.ISparkAttachable; @@ -36,11 +35,11 @@ public class ItemSpark extends Item implements IManaGivingItem { World world = ctx.getWorld(); BlockPos pos = ctx.getPos(); TileEntity tile = world.getTileEntity(pos); - if(tile instanceof ISparkAttachable) { + if (tile instanceof ISparkAttachable) { ISparkAttachable attach = (ISparkAttachable) tile; ItemStack stack = ctx.getItem(); - if(attach.canAttachSpark(stack) && attach.getAttachedSpark() == null) { - if(!world.isRemote) { + if (attach.canAttachSpark(stack) && attach.getAttachedSpark() == null) { + if (!world.isRemote) { stack.shrink(1); EntitySpark spark = new EntitySpark(world); spark.setPosition(pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5); diff --git a/src/main/java/vazkii/botania/common/item/ItemSparkUpgrade.java b/src/main/java/vazkii/botania/common/item/ItemSparkUpgrade.java index 69fcfa94a..9fec989ff 100644 --- a/src/main/java/vazkii/botania/common/item/ItemSparkUpgrade.java +++ b/src/main/java/vazkii/botania/common/item/ItemSparkUpgrade.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 21, 2014, 5:32:06 PM (GMT)] */ package vazkii.botania.common.item; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; + import vazkii.botania.api.mana.spark.SparkUpgradeType; public class ItemSparkUpgrade extends Item { @@ -23,12 +22,17 @@ public class ItemSparkUpgrade extends Item { } public static ItemStack getByType(SparkUpgradeType type) { - switch(type) { - case DOMINANT: return new ItemStack(ModItems.sparkUpgradeDominant); - case RECESSIVE: return new ItemStack(ModItems.sparkUpgradeRecessive); - case DISPERSIVE: return new ItemStack(ModItems.sparkUpgradeDispersive); - case ISOLATED: return new ItemStack(ModItems.sparkUpgradeIsolated); - default: return ItemStack.EMPTY; + switch (type) { + case DOMINANT: + return new ItemStack(ModItems.sparkUpgradeDominant); + case RECESSIVE: + return new ItemStack(ModItems.sparkUpgradeRecessive); + case DISPERSIVE: + return new ItemStack(ModItems.sparkUpgradeDispersive); + case ISOLATED: + return new ItemStack(ModItems.sparkUpgradeIsolated); + default: + return ItemStack.EMPTY; } } diff --git a/src/main/java/vazkii/botania/common/item/ItemSpawnerMover.java b/src/main/java/vazkii/botania/common/item/ItemSpawnerMover.java index 77bb32d5e..c267c7e29 100644 --- a/src/main/java/vazkii/botania/common/item/ItemSpawnerMover.java +++ b/src/main/java/vazkii/botania/common/item/ItemSpawnerMover.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [? (GMT)] */ package vazkii.botania.common.item; @@ -19,7 +17,6 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.MobSpawnerTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ActionResultType; import net.minecraft.util.ResourceLocation; @@ -30,7 +27,7 @@ import net.minecraft.world.server.ServerWorld; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.registries.ForgeRegistries; -import vazkii.botania.api.internal.VanillaPacketDispatcher; + import vazkii.botania.client.fx.SparkleParticleData; import vazkii.botania.client.fx.WispParticleData; import vazkii.botania.common.advancements.UseItemSuccessTrigger; @@ -38,6 +35,7 @@ import vazkii.botania.common.core.helper.PlayerHelper; import javax.annotation.Nonnull; import javax.annotation.Nullable; + import java.util.List; public class ItemSpawnerMover extends Item { @@ -54,9 +52,9 @@ public class ItemSpawnerMover extends Item { @Nullable private static ResourceLocation getEntityId(ItemStack stack) { CompoundNBT tag = stack.getChildTag(TAG_SPAWNER); - if(tag != null && tag.contains(TAG_SPAWN_DATA)) { + if (tag != null && tag.contains(TAG_SPAWN_DATA)) { tag = tag.getCompound(TAG_SPAWN_DATA); - if(tag.contains(TAG_ID)) { + if (tag.contains(TAG_ID)) { return ResourceLocation.tryCreate(tag.getString(TAG_ID)); } } @@ -83,7 +81,7 @@ public class ItemSpawnerMover extends Item { @Nonnull @Override public ActionResultType onItemUse(ItemUseContext ctx) { - if(getEntityId(ctx.getItem()) == null) { + if (getEntityId(ctx.getItem()) == null) { return captureSpawner(ctx) ? ActionResultType.SUCCESS : ActionResultType.PASS; } else { return placeSpawner(ctx); @@ -95,17 +93,18 @@ public class ItemSpawnerMover extends Item { useStack.getOrCreateTag().put("BlockEntityTag", ctx.getItem().getChildTag(TAG_SPAWNER)); ActionResultType res = PlayerHelper.substituteUse(ctx, useStack); - if(res == ActionResultType.SUCCESS) { + if (res == ActionResultType.SUCCESS) { World world = ctx.getWorld(); BlockPos pos = ctx.getPos(); ItemStack mover = ctx.getItem(); - if(!world.isRemote) { - if(ctx.getPlayer() != null) + if (!world.isRemote) { + if (ctx.getPlayer() != null) { ctx.getPlayer().sendBreakAnimation(ctx.getHand()); + } mover.shrink(1); } else { - for(int i = 0; i < 100; i++) { + for (int i = 0; i < 100; i++) { SparkleParticleData data = SparkleParticleData.sparkle(0.45F + 0.2F * (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), 6); world.addParticle(data, pos.getX() + Math.random(), pos.getY() + Math.random(), pos.getZ() + Math.random(), 0, 0, 0); } @@ -121,18 +120,18 @@ public class ItemSpawnerMover extends Item { ItemStack stack = ctx.getItem(); PlayerEntity player = ctx.getPlayer(); - if(world.getBlockState(pos).getBlock() == Blocks.SPAWNER) { - if(!world.isRemote) { + if (world.getBlockState(pos).getBlock() == Blocks.SPAWNER) { + if (!world.isRemote) { TileEntity te = world.getTileEntity(pos); stack.getOrCreateTag().put(TAG_SPAWNER, te.write(new CompoundNBT())); world.destroyBlock(pos, false); - if(player != null) { + if (player != null) { player.getCooldownTracker().setCooldown(this, 20); UseItemSuccessTrigger.INSTANCE.trigger((ServerPlayerEntity) player, stack, (ServerWorld) world, pos.getX(), pos.getY(), pos.getZ()); player.sendBreakAnimation(ctx.getHand()); } } else { - for(int i = 0; i < 50; i++) { + for (int i = 0; i < 50; i++) { float red = (float) Math.random(); float green = (float) Math.random(); float blue = (float) Math.random(); @@ -141,6 +140,8 @@ public class ItemSpawnerMover extends Item { } } return true; - } else return false; + } else { + return false; + } } } diff --git a/src/main/java/vazkii/botania/common/item/ItemSpellCloth.java b/src/main/java/vazkii/botania/common/item/ItemSpellCloth.java index 9b63c6528..4adf2a856 100644 --- a/src/main/java/vazkii/botania/common/item/ItemSpellCloth.java +++ b/src/main/java/vazkii/botania/common/item/ItemSpellCloth.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 25, 2015, 6:14:13 PM (GMT)] */ package vazkii.botania.common.item; diff --git a/src/main/java/vazkii/botania/common/item/ItemTemperanceStone.java b/src/main/java/vazkii/botania/common/item/ItemTemperanceStone.java index c07a763fc..1b2f60432 100644 --- a/src/main/java/vazkii/botania/common/item/ItemTemperanceStone.java +++ b/src/main/java/vazkii/botania/common/item/ItemTemperanceStone.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 12, 2015, 5:56:45 PM (GMT)] */ package vazkii.botania.common.item; @@ -16,7 +14,6 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundCategory; @@ -26,10 +23,12 @@ import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.List; public class ItemTemperanceStone extends Item { @@ -53,17 +52,20 @@ public class ItemTemperanceStone extends Item { @Override @OnlyIn(Dist.CLIENT) public void addInformation(ItemStack stack, World world, List stacks, ITooltipFlag flags) { - if(ItemNBTHelper.getBoolean(stack, TAG_ACTIVE, false)) + if (ItemNBTHelper.getBoolean(stack, TAG_ACTIVE, false)) { stacks.add(new TranslationTextComponent("botaniamisc.active")); - else stacks.add(new TranslationTextComponent("botaniamisc.inactive")); + } else { + stacks.add(new TranslationTextComponent("botaniamisc.inactive")); + } } public static boolean hasTemperanceActive(PlayerEntity player) { IInventory inv = player.inventory; - for(int i = 0; i < inv.getSizeInventory(); i++) { + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(!stack.isEmpty() && stack.getItem() == ModItems.temperanceStone && ItemNBTHelper.getBoolean(stack, TAG_ACTIVE, false)) + if (!stack.isEmpty() && stack.getItem() == ModItems.temperanceStone && ItemNBTHelper.getBoolean(stack, TAG_ACTIVE, false)) { return true; + } } return false; diff --git a/src/main/java/vazkii/botania/common/item/ItemThornChakram.java b/src/main/java/vazkii/botania/common/item/ItemThornChakram.java index d5aca1a9c..9ead5c0c8 100644 --- a/src/main/java/vazkii/botania/common/item/ItemThornChakram.java +++ b/src/main/java/vazkii/botania/common/item/ItemThornChakram.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 25, 2015, 6:42:47 PM (GMT)] */ package vazkii.botania.common.item; @@ -14,11 +12,11 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; import net.minecraft.world.World; + import vazkii.botania.common.entity.EntityThornChakram; import javax.annotation.Nonnull; @@ -31,16 +29,17 @@ public class ItemThornChakram extends Item { @Nonnull @Override - public ActionResult onItemRightClick(World world, PlayerEntity player, @Nonnull Hand hand) { + public ActionResult onItemRightClick(World world, PlayerEntity player, @Nonnull Hand hand) { ItemStack stack = player.getHeldItem(hand); - if(!world.isRemote) { + if (!world.isRemote) { ItemStack copy = stack.copy(); copy.setCount(1); EntityThornChakram c = new EntityThornChakram(player, world, copy); c.shoot(player, player.rotationPitch, player.rotationYaw, 0.0F, 1.5F, 1.0F); - if(stack.getItem() == ModItems.flareChakram) + if (stack.getItem() == ModItems.flareChakram) { c.setFire(true); + } world.addEntity(c); world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F)); stack.shrink(1); diff --git a/src/main/java/vazkii/botania/common/item/ItemTwigWand.java b/src/main/java/vazkii/botania/common/item/ItemTwigWand.java index 0ca7741a5..2a84d66cf 100644 --- a/src/main/java/vazkii/botania/common/item/ItemTwigWand.java +++ b/src/main/java/vazkii/botania/common/item/ItemTwigWand.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 20, 2014, 7:42:46 PM (GMT)] */ package vazkii.botania.common.item; @@ -23,9 +21,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; -import net.minecraft.item.Rarity; import net.minecraft.state.IProperty; -import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResultType; @@ -48,6 +44,7 @@ import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.api.wand.ICoordBoundItem; @@ -69,6 +66,7 @@ import vazkii.botania.common.network.PacketBotaniaEffect; import vazkii.botania.common.network.PacketHandler; import javax.annotation.Nonnull; + import java.util.List; import java.util.Optional; @@ -89,12 +87,12 @@ public class ItemTwigWand extends Item implements ICoordBoundItem { private static boolean tryCompleteBinding(BlockPos src, ItemStack stack, ItemUseContext ctx) { BlockPos dest = ctx.getPos(); - if(!dest.equals(src)) { + if (!dest.equals(src)) { setBindingAttempt(stack, UNBOUND_POS); TileEntity srcTile = ctx.getWorld().getTileEntity(src); if (srcTile instanceof IWandBindable) { - if(((IWandBindable) srcTile).bindTo(ctx.getPlayer(), stack, dest, ctx.getFace())) { + if (((IWandBindable) srcTile).bindTo(ctx.getPlayer(), stack, dest, ctx.getFace())) { doParticleBeamWithOffset(ctx.getWorld(), src, dest); VanillaPacketDispatcher.dispatchTEToNearbyPlayers(ctx.getWorld(), src); setBindingAttempt(stack, UNBOUND_POS); @@ -110,13 +108,13 @@ public class ItemTwigWand extends Item implements ICoordBoundItem { BlockPos pos = ctx.getPos(); Direction.Axis axis = TileEnchanter.canEnchanterExist(world, pos); - if(axis != null) { - if(!world.isRemote) { + if (axis != null) { + if (!world.isRemote) { world.setBlockState(pos, ModBlocks.enchanter.getDefaultState().with(BotaniaStateProps.ENCHANTER_DIRECTION, axis)); world.playSound(null, pos, ModSounds.enchanterForm, SoundCategory.BLOCKS, 0.5F, 0.6F); PlayerHelper.grantCriterion((ServerPlayerEntity) ctx.getPlayer(), new ResourceLocation(LibMisc.MOD_ID, "main/enchanter_make"), "code_triggered"); } else { - for(int i = 0; i < 50; i++) { + for (int i = 0; i < 50; i++) { float red = (float) Math.random(); float green = (float) Math.random(); float blue = (float) Math.random(); @@ -146,7 +144,7 @@ public class ItemTwigWand extends Item implements ICoordBoundItem { PlayerEntity player = ctx.getPlayer(); GlobalPos bindPos = ((BlockPistonRelay) ModBlocks.pistonRelay).activeBindingAttempts.get(player.getUniqueID()); - if(bindPos != null && bindPos.getDimension() == world.getDimension().getType()) { + if (bindPos != null && bindPos.getDimension() == world.getDimension().getType()) { ((BlockPistonRelay) ModBlocks.pistonRelay).activeBindingAttempts.remove(player.getUniqueID()); BlockPistonRelay.WorldData data = BlockPistonRelay.WorldData.get(world); data.mapping.put(bindPos.getPos(), pos.toImmutable()); @@ -175,39 +173,42 @@ public class ItemTwigWand extends Item implements ICoordBoundItem { Direction side = ctx.getFace(); Optional boundPos = getBindingAttempt(stack); - if(player == null) + if (player == null) { return ActionResultType.PASS; + } - if(player.isSneaking()) { + if (player.isSneaking()) { if (boundPos.isPresent() && tryCompleteBinding(boundPos.get(), stack, ctx)) { return ActionResultType.SUCCESS; } - if(player.canPlayerEdit(pos, side, stack) + if (player.canPlayerEdit(pos, side, stack) && (!(block instanceof CommandBlockBlock) || player.canUseCommandBlock())) { BlockState newState = rotate(state, side.getAxis()); - if(newState != state) { + if (newState != state) { world.setBlockState(pos, newState); return ActionResultType.SUCCESS; } } } - if(block == Blocks.LAPIS_BLOCK && ConfigHandler.COMMON.enchanterEnabled.get() && tryFormEnchanter(ctx)) { + if (block == Blocks.LAPIS_BLOCK && ConfigHandler.COMMON.enchanterEnabled.get() && tryFormEnchanter(ctx)) { return ActionResultType.SUCCESS; } - if(block instanceof IWandable) { + if (block instanceof IWandable) { TileEntity tile = world.getTileEntity(pos); boolean bindable = tile instanceof IWandBindable; boolean wanded; - if(getBindMode(stack) && bindable && player.isSneaking() && ((IWandBindable) tile).canSelect(player, stack, pos, side)) { - if(boundPos.isPresent() && boundPos.get().equals(pos)) + if (getBindMode(stack) && bindable && player.isSneaking() && ((IWandBindable) tile).canSelect(player, stack, pos, side)) { + if (boundPos.isPresent() && boundPos.get().equals(pos)) { setBindingAttempt(stack, UNBOUND_POS); - else setBindingAttempt(stack, pos); + } else { + setBindingAttempt(stack, pos); + } - if(world.isRemote) { + if (world.isRemote) { player.playSound(ModSounds.ding, 0.11F, 1F); } @@ -219,7 +220,7 @@ public class ItemTwigWand extends Item implements ICoordBoundItem { return wanded ? ActionResultType.SUCCESS : ActionResultType.FAIL; } - if(!world.isRemote && getBindMode(stack) && tryCompletePistonRelayBinding(ctx)) { + if (!world.isRemote && getBindMode(stack) && tryCompletePistonRelayBinding(ctx)) { return ActionResultType.SUCCESS; } @@ -229,9 +230,9 @@ public class ItemTwigWand extends Item implements ICoordBoundItem { private static BlockState rotate(BlockState old, Direction.Axis axis) { for (IProperty prop : old.getProperties()) { if (prop.getName().equals("facing") && prop.getValueClass() == Direction.class) { - IProperty facingProp = (IProperty) prop; + IProperty facingProp = (IProperty) prop; - Direction oldDir = old.get(facingProp); + Direction oldDir = old.get(facingProp); Direction newDir = rotateAround(oldDir, axis); if (oldDir != newDir && facingProp.getAllowedValues().contains(newDir)) { return old.with(facingProp, newDir); @@ -244,33 +245,45 @@ public class ItemTwigWand extends Item implements ICoordBoundItem { private static Direction rotateAround(Direction old, Direction.Axis axis) { switch (axis) { - case X: { - switch (old) { - case DOWN: return Direction.SOUTH; - case SOUTH: return Direction.UP; - case UP: return Direction.NORTH; - case NORTH: return Direction.DOWN; - } - break; + case X: { + switch (old) { + case DOWN: + return Direction.SOUTH; + case SOUTH: + return Direction.UP; + case UP: + return Direction.NORTH; + case NORTH: + return Direction.DOWN; } - case Y: { - switch (old) { - case NORTH: return Direction.EAST; - case EAST: return Direction.SOUTH; - case SOUTH: return Direction.WEST; - case WEST: return Direction.NORTH; - } - break; + break; + } + case Y: { + switch (old) { + case NORTH: + return Direction.EAST; + case EAST: + return Direction.SOUTH; + case SOUTH: + return Direction.WEST; + case WEST: + return Direction.NORTH; } - case Z: { - switch (old) { - case DOWN: return Direction.WEST; - case WEST: return Direction.UP; - case UP: return Direction.EAST; - case EAST: return Direction.DOWN; - } - break; + break; + } + case Z: { + switch (old) { + case DOWN: + return Direction.WEST; + case WEST: + return Direction.UP; + case UP: + return Direction.EAST; + case EAST: + return Direction.DOWN; } + break; + } } return old; @@ -285,8 +298,9 @@ public class ItemTwigWand extends Item implements ICoordBoundItem { } public static void doParticleBeam(World world, Vector3 orig, Vector3 end) { - if(!world.isRemote) + if (!world.isRemote) { return; + } Vector3 diff = end.subtract(orig); Vector3 movement = diff.normalize().multiply(0.05); @@ -295,7 +309,7 @@ public class ItemTwigWand extends Item implements ICoordBoundItem { float hueSum = (float) Math.random(); Vector3 currentPos = orig; - for(int i = 0; i < iters; i++) { + for (int i = 0; i < iters; i++) { float hue = i * huePer + hueSum; int color = MathHelper.hsvToRGB(hue, 1F, 1F); float r = (color >> 16 & 0xFF) / 255F; @@ -312,8 +326,9 @@ public class ItemTwigWand extends Item implements ICoordBoundItem { public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) { getBindingAttempt(stack).ifPresent(coords -> { TileEntity tile = world.getTileEntity(coords); - if(!(tile instanceof IWandBindable)) + if (!(tile instanceof IWandBindable)) { setBindingAttempt(stack, UNBOUND_POS); + } }); } @@ -321,10 +336,12 @@ public class ItemTwigWand extends Item implements ICoordBoundItem { @Override public ActionResult onItemRightClick(World world, PlayerEntity player, @Nonnull Hand hand) { ItemStack stack = player.getHeldItem(hand); - if(player.isSneaking()) { - if(!world.isRemote) + if (player.isSneaking()) { + if (!world.isRemote) { setBindMode(stack, !getBindMode(stack)); - else player.playSound(ModSounds.ding, 0.1F, 1F); + } else { + player.playSound(ModSounds.ding, 0.1F, 1F); + } } return ActionResult.success(stack); @@ -332,9 +349,10 @@ public class ItemTwigWand extends Item implements ICoordBoundItem { @Override public void fillItemGroup(@Nonnull ItemGroup group, @Nonnull NonNullList stacks) { - if(isInGroup(group)) { - for(int i = 0; i < 16; i++) + if (isInGroup(group)) { + for (int i = 0; i < 16; i++) { stacks.add(forColors(i, i)); + } } } @@ -396,13 +414,14 @@ public class ItemTwigWand extends Item implements ICoordBoundItem { @Override public BlockPos getBinding(ItemStack stack) { Optional bound = getBindingAttempt(stack); - if(bound.isPresent()) + if (bound.isPresent()) { return bound.get(); + } RayTraceResult pos = Minecraft.getInstance().objectMouseOver; - if(pos != null && pos.getType() == RayTraceResult.Type.BLOCK) { + if (pos != null && pos.getType() == RayTraceResult.Type.BLOCK) { TileEntity tile = Minecraft.getInstance().world.getTileEntity(((BlockRayTraceResult) pos).getPos()); - if(tile instanceof ITileBound) { + if (tile instanceof ITileBound) { return ((ITileBound) tile).getBinding(); } } diff --git a/src/main/java/vazkii/botania/common/item/ItemVineBall.java b/src/main/java/vazkii/botania/common/item/ItemVineBall.java index becbd84d0..252cf4d2e 100644 --- a/src/main/java/vazkii/botania/common/item/ItemVineBall.java +++ b/src/main/java/vazkii/botania/common/item/ItemVineBall.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 26, 2014, 7:50:37 PM (GMT)] */ package vazkii.botania.common.item; @@ -14,11 +12,11 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; import net.minecraft.world.World; + import vazkii.botania.common.entity.EntityVineBall; import javax.annotation.Nonnull; @@ -32,12 +30,13 @@ public class ItemVineBall extends Item { @Nonnull @Override public ActionResult onItemRightClick(World world, PlayerEntity player, @Nonnull Hand hand) { - if(!player.abilities.isCreativeMode) + if (!player.abilities.isCreativeMode) { player.getHeldItem(hand).shrink(1); + } world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F)); - if(!world.isRemote) { + if (!world.isRemote) { EntityVineBall ball = new EntityVineBall(player, true); ball.shoot(player, player.rotationPitch, player.rotationYaw, 0.0F, 1.5F, 1.0F); world.addEntity(ball); diff --git a/src/main/java/vazkii/botania/common/item/ItemVirus.java b/src/main/java/vazkii/botania/common/item/ItemVirus.java index 48b23b1bb..87fdcc686 100644 --- a/src/main/java/vazkii/botania/common/item/ItemVirus.java +++ b/src/main/java/vazkii/botania/common/item/ItemVirus.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 21, 2014, 4:46:17 PM (GMT)] */ package vazkii.botania.common.item; @@ -36,6 +34,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; + import vazkii.botania.common.lib.LibMisc; @Mod.EventBusSubscriber(modid = LibMisc.MOD_ID) @@ -46,26 +45,30 @@ public class ItemVirus extends Item { @Override public boolean itemInteractionForEntity(ItemStack stack, PlayerEntity player, LivingEntity living, Hand hand) { - if(living instanceof AbstractHorseEntity && !(living instanceof LlamaEntity)) { - if(player.world.isRemote) + if (living instanceof AbstractHorseEntity && !(living instanceof LlamaEntity)) { + if (player.world.isRemote) { return true; + } AbstractHorseEntity horse = (AbstractHorseEntity) living; - if(horse.isTame()) { + if (horse.isTame()) { IItemHandler inv = horse.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElseThrow(NullPointerException::new); ItemStack saddle = inv.getStackInSlot(0); // Not all AbstractHorse's have saddles in slot 0 - if(!saddle.isEmpty() && saddle.getItem() != Items.SADDLE) { + if (!saddle.isEmpty() && saddle.getItem() != Items.SADDLE) { horse.entityDropItem(saddle, 0); saddle = ItemStack.EMPTY; } - for (int i = 1; i < inv.getSlots(); i++) - if(!inv.getStackInSlot(i).isEmpty()) + for (int i = 1; i < inv.getSlots(); i++) { + if (!inv.getStackInSlot(i).isEmpty()) { horse.entityDropItem(inv.getStackInSlot(i), 0); + } + } - if (horse instanceof AbstractChestedHorseEntity && ((AbstractChestedHorseEntity) horse).hasChest()) + if (horse instanceof AbstractChestedHorseEntity && ((AbstractChestedHorseEntity) horse).hasChest()) { horse.entityDropItem(new ItemStack(Blocks.CHEST), 0); + } horse.remove(); @@ -76,8 +79,9 @@ public class ItemVirus extends Item { newHorse.setPositionAndRotation(horse.getX(), horse.getY(), horse.getZ(), horse.rotationYaw, horse.rotationPitch); // Put the saddle back - if(!saddle.isEmpty()) + if (!saddle.isEmpty()) { newHorse.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElseThrow(NullPointerException::new).insertItem(0, saddle, false); + } AbstractAttributeMap oldAttributes = horse.getAttributes(); AbstractAttributeMap attributes = newHorse.getAttributes(); @@ -110,10 +114,11 @@ public class ItemVirus extends Item { @SubscribeEvent public static void onLivingHurt(LivingHurtEvent event) { LivingEntity entity = event.getEntityLiving(); - if(entity.isPassenger() && entity.getRidingEntity() instanceof LivingEntity) + if (entity.isPassenger() && entity.getRidingEntity() instanceof LivingEntity) { entity = (LivingEntity) entity.getRidingEntity(); + } - if((entity instanceof ZombieHorseEntity || entity instanceof SkeletonHorseEntity) + if ((entity instanceof ZombieHorseEntity || entity instanceof SkeletonHorseEntity) && event.getSource() == DamageSource.FALL && ((AbstractHorseEntity) entity).isTame()) { event.setCanceled(true); diff --git a/src/main/java/vazkii/botania/common/item/ItemWaterBowl.java b/src/main/java/vazkii/botania/common/item/ItemWaterBowl.java index 0653388b8..19dbb8ea9 100644 --- a/src/main/java/vazkii/botania/common/item/ItemWaterBowl.java +++ b/src/main/java/vazkii/botania/common/item/ItemWaterBowl.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 8, 2015, 9:07:35 PM (GMT)] */ package vazkii.botania.common.item; @@ -28,7 +26,6 @@ public class ItemWaterBowl extends Item { super(builder); } - @Nonnull @Override public ICapabilityProvider initCapabilities(ItemStack stack, CompoundNBT nbt) { diff --git a/src/main/java/vazkii/botania/common/item/ItemWorldSeed.java b/src/main/java/vazkii/botania/common/item/ItemWorldSeed.java index 755805963..bc4cae060 100644 --- a/src/main/java/vazkii/botania/common/item/ItemWorldSeed.java +++ b/src/main/java/vazkii/botania/common/item/ItemWorldSeed.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 25, 2015, 12:27:31 AM (GMT)] */ package vazkii.botania.common.item; @@ -20,8 +18,8 @@ import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.server.ServerWorld; + import vazkii.botania.client.fx.SparkleParticleData; import vazkii.botania.common.core.helper.MathHelper; @@ -37,21 +35,23 @@ public class ItemWorldSeed extends Item { @Override public ActionResult onItemRightClick(World world, PlayerEntity player, @Nonnull Hand hand) { ItemStack stack = player.getHeldItem(hand); - if (world.isRemote) + if (world.isRemote) { return new ActionResult<>(ActionResultType.SUCCESS, stack); + } BlockPos coords = world.getSpawnPoint(); - if(world.getDimension().canRespawnHere() && MathHelper.pointDistanceSpace(coords.getX() + 0.5, coords.getY() + 0.5, coords.getZ() + 0.5, player.getX(), player.getY(), player.getZ()) > 24) { + if (world.getDimension().canRespawnHere() && MathHelper.pointDistanceSpace(coords.getX() + 0.5, coords.getY() + 0.5, coords.getZ() + 0.5, player.getX(), player.getY(), player.getZ()) > 24) { player.rotationPitch = 0F; player.rotationYaw = 0F; player.setPositionAndUpdate(coords.getX() + 0.5, coords.getY() + 0.5, coords.getZ() + 0.5); - while(!world.doesNotCollide(player, player.getBoundingBox())) + while (!world.doesNotCollide(player, player.getBoundingBox())) { player.setPositionAndUpdate(player.getX(), player.getY() + 1, player.getZ()); + } world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 1F, 1F); SparkleParticleData data = SparkleParticleData.sparkle(1F, 0.25F, 1F, 0.25F, 10); - ((ServerWorld) world).spawnParticle(data, player.getX(), player.getY()+ player.getHeight() / 2, player.getZ(), 50, player.getWidth() / 8, player.getHeight() / 4, player.getWidth() / 8, 0); + ((ServerWorld) world).spawnParticle(data, player.getX(), player.getY() + player.getHeight() / 2, player.getZ(), 50, player.getWidth() / 8, player.getHeight() / 4, player.getWidth() / 8, 0); stack.shrink(1); return new ActionResult<>(ActionResultType.SUCCESS, stack); diff --git a/src/main/java/vazkii/botania/common/item/ModItems.java b/src/main/java/vazkii/botania/common/item/ModItems.java index 48c144ee8..b0f647ca1 100644 --- a/src/main/java/vazkii/botania/common/item/ModItems.java +++ b/src/main/java/vazkii/botania/common/item/ModItems.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 14, 2014, 5:17:47 PM (GMT)] */ package vazkii.botania.common.item; @@ -28,6 +26,7 @@ import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.ObjectHolder; + import vazkii.botania.api.item.IAncientWillContainer; import vazkii.botania.api.item.IFloatingFlower; import vazkii.botania.api.mana.spark.SparkUpgradeType; @@ -152,7 +151,7 @@ public final class ModItems { @ObjectHolder(LibItemNames.PESTLE_AND_MORTAR) public static Item pestleAndMortar; @ObjectHolder(LibItemNames.TWIG_WAND) public static Item twigWand; - + @ObjectHolder(LibItemNames.MANASTEEL_INGOT) public static Item manaSteel; @ObjectHolder(LibItemNames.MANA_PEARL) public static Item manaPearl; @ObjectHolder(LibItemNames.MANA_DIAMOND) public static Item manaDiamond; @@ -176,7 +175,7 @@ public final class ModItems { @ObjectHolder(LibItemNames.PEBBLE) public static Item pebble; @ObjectHolder(LibItemNames.MANAWEAVE_CLOTH) public static Item manaweaveCloth; @ObjectHolder(LibItemNames.MANA_POWDER) public static Item manaPowder; - + @ObjectHolder(LibItemNames.LENS_NORMAL) public static Item lensNormal; @ObjectHolder(LibItemNames.LENS_SPEED) public static Item lensSpeed; @ObjectHolder(LibItemNames.LENS_POWER) public static Item lensPower; @@ -202,7 +201,7 @@ public final class ModItems { @ObjectHolder(LibItemNames.LENS_MESSENGER) public static Item lensMessenger; @ObjectHolder(LibItemNames.LENS_TRIPWIRE) public static Item lensTripwire; @ObjectHolder(LibItemNames.LENS_STORM) public static Item lensStorm; - + @ObjectHolder(LibItemNames.RUNE_WATER) public static Item runeWater; @ObjectHolder(LibItemNames.RUNE_FIRE) public static Item runeFire; @ObjectHolder(LibItemNames.RUNE_EARTH) public static Item runeEarth; @@ -393,7 +392,7 @@ public final class ModItems { @ObjectHolder(LibItemNames.COSMETIC_PREFIX + "tiny_potato_mask") public static Item tinyPotatoMask; @ObjectHolder(LibItemNames.COSMETIC_PREFIX + "questgiver_mark") public static Item questgiverMark; @ObjectHolder(LibItemNames.COSMETIC_PREFIX + "thinking_hand") public static Item thinkingHand; - + @ObjectHolder(LibItemNames.SWAP_RING) public static Item swapRing; @ObjectHolder(LibItemNames.FLOWER_BAG) public static Item flowerBag; @ObjectHolder(LibItemNames.PHANTOM_INK) public static Item phantomInk; @@ -449,7 +448,7 @@ public final class ModItems { IForgeRegistry r = evt.getRegistry(); register(r, new ItemLexicon(unstackable().rarity(Rarity.UNCOMMON)), LibItemNames.LEXICON); - for(DyeColor color : DyeColor.values()) { + 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); } @@ -657,10 +656,10 @@ public final class ModItems { register(r, new ItemLivingwoodBow(defaultBuilder().defaultMaxDamage(500)), LibItemNames.LIVINGWOOD_BOW); register(r, new ItemCrystalBow(defaultBuilder().defaultMaxDamage(500)), LibItemNames.CRYSTAL_BOW); - for(ItemBaubleCosmetic.Variant v : ItemBaubleCosmetic.Variant.values()) { + for (ItemBaubleCosmetic.Variant v : ItemBaubleCosmetic.Variant.values()) { register(r, new ItemBaubleCosmetic(v, unstackable()), LibItemNames.COSMETIC_PREFIX + v.name().toLowerCase(Locale.ROOT)); } - + register(r, new ItemSwapRing(unstackable()), LibItemNames.SWAP_RING); register(r, new ItemFlowerBag(unstackable()), LibItemNames.FLOWER_BAG); register(r, new Item(defaultBuilder()), LibItemNames.PHANTOM_INK); @@ -743,48 +742,80 @@ public final class ModItems { ScreenManager.registerFactory(box, GuiBaubleBox::new); }); } - + public static Item getPetal(DyeColor color) { switch (color) { - default: - case WHITE: return whitePetal; - case ORANGE: return orangePetal; - case MAGENTA: return magentaPetal; - case LIGHT_BLUE: return lightBluePetal; - case YELLOW: return yellowPetal; - case LIME: return limePetal; - case PINK: return pinkPetal; - case GRAY: return grayPetal; - case LIGHT_GRAY: return lightGrayPetal; - case CYAN: return cyanPetal; - case PURPLE: return purplePetal; - case BLUE: return bluePetal; - case BROWN: return brownPetal; - case GREEN: return greenPetal; - case RED: return redPetal; - case BLACK: return blackPetal; + default: + case WHITE: + return whitePetal; + case ORANGE: + return orangePetal; + case MAGENTA: + return magentaPetal; + case LIGHT_BLUE: + return lightBluePetal; + case YELLOW: + return yellowPetal; + case LIME: + return limePetal; + case PINK: + return pinkPetal; + case GRAY: + return grayPetal; + case LIGHT_GRAY: + return lightGrayPetal; + case CYAN: + return cyanPetal; + case PURPLE: + return purplePetal; + case BLUE: + return bluePetal; + case BROWN: + return brownPetal; + case GREEN: + return greenPetal; + case RED: + return redPetal; + case BLACK: + return blackPetal; } } - + public static Item getDye(DyeColor color) { switch (color) { - default: - case WHITE: return whiteDye; - case ORANGE: return orangeDye; - case MAGENTA: return magentaDye; - case LIGHT_BLUE: return lightBlueDye; - case YELLOW: return yellowDye; - case LIME: return limeDye; - case PINK: return pinkDye; - case GRAY: return grayDye; - case LIGHT_GRAY: return lightGrayDye; - case CYAN: return cyanDye; - case PURPLE: return purpleDye; - case BLUE: return blueDye; - case BROWN: return brownDye; - case GREEN: return greenDye; - case RED: return redDye; - case BLACK: return blackDye; + default: + case WHITE: + return whiteDye; + case ORANGE: + return orangeDye; + case MAGENTA: + return magentaDye; + case LIGHT_BLUE: + return lightBlueDye; + case YELLOW: + return yellowDye; + case LIME: + return limeDye; + case PINK: + return pinkDye; + case GRAY: + return grayDye; + case LIGHT_GRAY: + return lightGrayDye; + case CYAN: + return cyanDye; + case PURPLE: + return purpleDye; + case BLUE: + return blueDye; + case BROWN: + return brownDye; + case GREEN: + return greenDye; + case RED: + return redDye; + case BLACK: + return blackDye; } } } diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockDreamwood.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockDreamwood.java index c223aa01e..c15466a70 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockDreamwood.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockDreamwood.java @@ -1,8 +1,17 @@ +/* + * This class is 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 + */ package vazkii.botania.common.item.block; import net.minecraft.block.Block; import net.minecraft.item.BlockItem; import net.minecraft.item.ItemStack; + import vazkii.botania.api.recipe.IElvenItem; public class ItemBlockDreamwood extends BlockItem implements IElvenItem { diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockElven.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockElven.java index 4efb95cbf..a52da32b7 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockElven.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockElven.java @@ -1,18 +1,17 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 9, 2014, 5:02:06 PM (GMT)] */ package vazkii.botania.common.item.block; import net.minecraft.block.Block; import net.minecraft.item.BlockItem; import net.minecraft.item.ItemStack; + import vazkii.botania.api.recipe.IElvenItem; public class ItemBlockElven extends BlockItem implements IElvenItem { diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockPool.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockPool.java index 9239935f2..5692acd98 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockPool.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockPool.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 27, 2014, 8:32:52 PM (GMT)] */ package vazkii.botania.common.item.block; @@ -21,10 +19,12 @@ import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.common.block.mana.BlockPool; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.List; public class ItemBlockPool extends BlockItem { @@ -40,9 +40,11 @@ public class ItemBlockPool extends BlockItem { @OnlyIn(Dist.CLIENT) @Override public void addInformation(@Nonnull ItemStack stack, World world, @Nonnull List stacks, @Nonnull ITooltipFlag flag) { - if(((BlockPool) getBlock()).variant == BlockPool.Variant.CREATIVE) - for(int i = 0; i < 2; i++) + if (((BlockPool) getBlock()).variant == BlockPool.Variant.CREATIVE) { + for (int i = 0; i < 2; i++) { stacks.add(new TranslationTextComponent("botaniamisc.creativePool" + i).applyTextStyle(TextFormatting.GRAY)); + } + } } } diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialFlower.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialFlower.java index 43d66d198..fbbcdbb43 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialFlower.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockSpecialFlower.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 25, 2014, 2:04:15 PM (GMT)] */ package vazkii.botania.common.item.block; @@ -24,6 +22,7 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.subtile.TileEntityGeneratingFlower; import vazkii.botania.common.Botania; @@ -32,6 +31,7 @@ import vazkii.botania.common.lib.LibMisc; import vazkii.botania.common.lib.ModTags; import javax.annotation.Nonnull; + import java.util.List; @Mod.EventBusSubscriber(modid = LibMisc.MOD_ID) @@ -47,20 +47,21 @@ public class ItemBlockSpecialFlower extends BlockItem { @OnlyIn(Dist.CLIENT) @Override public void addInformation(@Nonnull ItemStack stack, World world, @Nonnull List tooltip, @Nonnull ITooltipFlag flag) { - if(GENERATING.contains(this)) { + if (GENERATING.contains(this)) { tooltip.add(new TranslationTextComponent("botania.flowerType.generating").applyTextStyles(TextFormatting.ITALIC, TextFormatting.BLUE)); - } else if(FUNCTIONAL.contains(this)) { + } else if (FUNCTIONAL.contains(this)) { tooltip.add(new TranslationTextComponent("botania.flowerType.functional").applyTextStyles(TextFormatting.ITALIC, TextFormatting.BLUE)); - } else if(MISC.contains(this)) { + } else if (MISC.contains(this)) { tooltip.add(new TranslationTextComponent("botania.flowerType.misc").applyTextStyles(TextFormatting.ITALIC, TextFormatting.BLUE)); } // Prevent crash when tooltips queried before configs load - if(Botania.finishedLoading && ConfigHandler.CLIENT.referencesEnabled.get()) { + if (Botania.finishedLoading && ConfigHandler.CLIENT.referencesEnabled.get()) { String key = getTranslationKey() + ".reference"; ITextComponent lore = new TranslationTextComponent(key); - if(!lore.getString().equals(key)) + if (!lore.getString().equals(key)) { tooltip.add(lore.applyTextStyles(TextFormatting.ITALIC, TextFormatting.GRAY)); + } } } diff --git a/src/main/java/vazkii/botania/common/item/block/ItemBlockTinyPotato.java b/src/main/java/vazkii/botania/common/item/block/ItemBlockTinyPotato.java index e68eb0c79..f87d750cb 100644 --- a/src/main/java/vazkii/botania/common/item/block/ItemBlockTinyPotato.java +++ b/src/main/java/vazkii/botania/common/item/block/ItemBlockTinyPotato.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 27, 2015, 3:44:10 PM (GMT)] */ package vazkii.botania.common.item.block; @@ -18,6 +16,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; + import vazkii.botania.common.core.helper.ItemNBTHelper; import java.util.Arrays; @@ -55,10 +54,10 @@ public class ItemBlockTinyPotato extends BlockItem { @Override public void inventoryTick(ItemStack stack, World world, Entity e, int t, boolean idunno) { - if(!world.isRemote && e instanceof PlayerEntity && e.ticksExisted % 30 == 0 && TYPOS.contains(stack.getDisplayName().getString().toLowerCase())) { + if (!world.isRemote && e instanceof PlayerEntity && e.ticksExisted % 30 == 0 && TYPOS.contains(stack.getDisplayName().getString().toLowerCase())) { PlayerEntity player = (PlayerEntity) e; int ticks = ItemNBTHelper.getInt(stack, TAG_TICKS, 0); - if(ticks < NOT_MY_NAME.length) { + if (ticks < NOT_MY_NAME.length) { player.sendMessage(new StringTextComponent(TextFormatting.RED + NOT_MY_NAME[ticks])); ItemNBTHelper.setInt(stack, TAG_TICKS, ticks + 1); } diff --git a/src/main/java/vazkii/botania/common/item/brew/ItemBrewBase.java b/src/main/java/vazkii/botania/common/item/brew/ItemBrewBase.java index ec9c5e922..6eb43a305 100644 --- a/src/main/java/vazkii/botania/common/item/brew/ItemBrewBase.java +++ b/src/main/java/vazkii/botania/common/item/brew/ItemBrewBase.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 1, 2014, 5:45:58 PM (GMT)] */ package vazkii.botania.common.item.brew; import com.google.common.collect.Lists; + import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.ai.attributes.AttributeModifier; @@ -24,7 +23,6 @@ import net.minecraft.potion.Effect; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.EffectUtils; import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; @@ -38,14 +36,15 @@ import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.brew.Brew; import vazkii.botania.api.brew.IBrewItem; import vazkii.botania.common.core.helper.ItemNBTHelper; -import net.minecraft.item.Item; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.List; import java.util.Map; import java.util.function.Supplier; @@ -88,29 +87,31 @@ public class ItemBrewBase extends Item implements IBrewItem { @Nonnull @Override public ItemStack onItemUseFinish(@Nonnull ItemStack stack, World world, LivingEntity living) { - if(!world.isRemote) { - for(EffectInstance effect : getBrew(stack).getPotionEffects(stack)) { + if (!world.isRemote) { + for (EffectInstance effect : getBrew(stack).getPotionEffects(stack)) { EffectInstance newEffect = new EffectInstance(effect.getPotion(), effect.getDuration(), effect.getAmplifier(), true, true); - if(effect.getPotion().isInstant()) + if (effect.getPotion().isInstant()) { effect.getPotion().affectEntity(living, living, living, newEffect.getAmplifier(), 1F); - else living.addPotionEffect(newEffect); + } else { + living.addPotionEffect(newEffect); + } } - if(world.rand.nextBoolean()) + if (world.rand.nextBoolean()) { world.playSound(null, living.getX(), living.getY(), living.getZ(), SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 1F, 1F); + } int swigs = getSwigsLeft(stack); - if(living instanceof PlayerEntity && !((PlayerEntity) living).abilities.isCreativeMode) { - if(swigs == 1) { + if (living instanceof PlayerEntity && !((PlayerEntity) living).abilities.isCreativeMode) { + if (swigs == 1) { ItemStack result = new ItemStack(baseItem.get()); - if(!((PlayerEntity) living).inventory.addItemStackToInventory(result)) + if (!((PlayerEntity) living).inventory.addItemStackToInventory(result)) { return result; - else { + } else { return ItemStack.EMPTY; } } - setSwigsLeft(stack, swigs - 1); } } @@ -120,8 +121,8 @@ public class ItemBrewBase extends Item implements IBrewItem { @Override public void fillItemGroup(ItemGroup tab, NonNullList list) { - if(isInGroup(tab)) { - for(String s : BotaniaAPI.brewMap.keySet()) { + if (isInGroup(tab)) { + for (String s : BotaniaAPI.brewMap.keySet()) { ItemStack stack = new ItemStack(this); setBrew(stack, s); list.add(stack); @@ -133,7 +134,7 @@ public class ItemBrewBase extends Item implements IBrewItem { @Override public ITextComponent getDisplayName(@Nonnull ItemStack stack) { return new TranslationTextComponent(getTranslationKey(), new TranslationTextComponent(getBrew(stack).getUnlocalizedName(stack)), - new StringTextComponent(Integer.toString(getSwigsLeft(stack))).applyTextStyle(TextFormatting.BOLD)); + new StringTextComponent(Integer.toString(getSwigsLeft(stack))).applyTextStyle(TextFormatting.BOLD)); } // [VanillaCopy] PotionUtils.addPotionTooltip, with custom effect list @@ -143,12 +144,12 @@ public class ItemBrewBase extends Item implements IBrewItem { if (list.isEmpty()) { lores.add((new TranslationTextComponent("effect.none")).applyTextStyle(TextFormatting.GRAY)); } else { - for(EffectInstance effectinstance : list) { + for (EffectInstance effectinstance : list) { ITextComponent itextcomponent = new TranslationTextComponent(effectinstance.getEffectName()); Effect effect = effectinstance.getPotion(); Map map = effect.getAttributeModifierMap(); if (!map.isEmpty()) { - for(Map.Entry entry : map.entrySet()) { + for (Map.Entry entry : map.entrySet()) { AttributeModifier attributemodifier = entry.getValue(); AttributeModifier attributemodifier1 = new AttributeModifier(attributemodifier.getName(), effect.getAttributeModifierAmount(effectinstance.getAmplifier(), attributemodifier), attributemodifier.getOperation()); list1.add(new Tuple<>(entry.getKey().getName(), attributemodifier1)); @@ -171,7 +172,7 @@ public class ItemBrewBase extends Item implements IBrewItem { lores.add(new StringTextComponent("")); lores.add((new TranslationTextComponent("potion.whenDrank")).applyTextStyle(TextFormatting.DARK_PURPLE)); - for(Tuple tuple : list1) { + for (Tuple tuple : list1) { AttributeModifier attributemodifier2 = tuple.getB(); double d0 = attributemodifier2.getAmount(); double d1; @@ -182,10 +183,10 @@ public class ItemBrewBase extends Item implements IBrewItem { } if (d0 > 0.0D) { - lores.add((new TranslationTextComponent("attribute.modifier.plus." + attributemodifier2.getOperation().getId(), ItemStack.DECIMALFORMAT.format(d1), new TranslationTextComponent("attribute.name." + (String)tuple.getA()))).applyTextStyle(TextFormatting.BLUE)); + lores.add((new TranslationTextComponent("attribute.modifier.plus." + attributemodifier2.getOperation().getId(), ItemStack.DECIMALFORMAT.format(d1), new TranslationTextComponent("attribute.name." + (String) tuple.getA()))).applyTextStyle(TextFormatting.BLUE)); } else if (d0 < 0.0D) { d1 = d1 * -1.0D; - lores.add((new TranslationTextComponent("attribute.modifier.take." + attributemodifier2.getOperation().getId(), ItemStack.DECIMALFORMAT.format(d1), new TranslationTextComponent("attribute.name." + (String)tuple.getA()))).applyTextStyle(TextFormatting.RED)); + lores.add((new TranslationTextComponent("attribute.modifier.take." + attributemodifier2.getOperation().getId(), ItemStack.DECIMALFORMAT.format(d1), new TranslationTextComponent("attribute.name." + (String) tuple.getA()))).applyTextStyle(TextFormatting.RED)); } } } @@ -215,7 +216,7 @@ public class ItemBrewBase extends Item implements IBrewItem { public static String getSubtype(ItemStack stack) { return stack.hasTag() ? ItemNBTHelper.getString(stack, TAG_BREW_KEY, "none") : "none"; } - + public int getSwigsLeft(ItemStack stack) { return ItemNBTHelper.getInt(stack, TAG_SWIGS_LEFT, swigs); } diff --git a/src/main/java/vazkii/botania/common/item/brew/ItemIncenseStick.java b/src/main/java/vazkii/botania/common/item/brew/ItemIncenseStick.java index 52c64215c..7a2507d3a 100644 --- a/src/main/java/vazkii/botania/common/item/brew/ItemIncenseStick.java +++ b/src/main/java/vazkii/botania/common/item/brew/ItemIncenseStick.java @@ -1,36 +1,33 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 15, 2015, 3:13:43 PM (GMT)] */ package vazkii.botania.common.item.brew; import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; -import net.minecraft.potion.EffectInstance; -import net.minecraft.potion.EffectUtils; import net.minecraft.util.NonNullList; import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.brew.Brew; import vazkii.botania.api.brew.IBrewContainer; import vazkii.botania.api.brew.IBrewItem; import vazkii.botania.common.core.helper.ItemNBTHelper; -import net.minecraft.item.Item; import javax.annotation.Nonnull; + import java.util.List; public class ItemIncenseStick extends Item implements IBrewItem, IBrewContainer { @@ -45,11 +42,12 @@ public class ItemIncenseStick extends Item implements IBrewItem, IBrewContainer @Override public void fillItemGroup(@Nonnull ItemGroup tab, @Nonnull NonNullList list) { super.fillItemGroup(tab, list); - if(isInGroup(tab)) { - for(String s : BotaniaAPI.brewMap.keySet()) { + if (isInGroup(tab)) { + for (String s : BotaniaAPI.brewMap.keySet()) { ItemStack brewStack = getItemForBrew(BotaniaAPI.brewMap.get(s), new ItemStack(this)); - if(!brewStack.isEmpty()) + if (!brewStack.isEmpty()) { list.add(brewStack); + } } } } @@ -58,7 +56,7 @@ public class ItemIncenseStick extends Item implements IBrewItem, IBrewContainer @Override public void addInformation(ItemStack stack, World world, List list, ITooltipFlag flags) { Brew brew = getBrew(stack); - if(brew == BotaniaAPI.fallbackBrew) { + if (brew == BotaniaAPI.fallbackBrew) { list.add(new TranslationTextComponent("botaniamisc.notInfused").applyTextStyle(TextFormatting.LIGHT_PURPLE)); return; } @@ -83,8 +81,9 @@ public class ItemIncenseStick extends Item implements IBrewItem, IBrewContainer @Override public ItemStack getItemForBrew(Brew brew, ItemStack stack) { - if(!brew.canInfuseIncense() || brew.getPotionEffects(stack).size() != 1 || brew.getPotionEffects(stack).get(0).getPotion().isInstant()) + if (!brew.canInfuseIncense() || brew.getPotionEffects(stack).size() != 1 || brew.getPotionEffects(stack).get(0).getPotion().isInstant()) { return ItemStack.EMPTY; + } ItemStack brewStack = new ItemStack(this); setBrew(brewStack, brew); diff --git a/src/main/java/vazkii/botania/common/item/brew/ItemVial.java b/src/main/java/vazkii/botania/common/item/brew/ItemVial.java index 45521ada4..e3b60b484 100644 --- a/src/main/java/vazkii/botania/common/item/brew/ItemVial.java +++ b/src/main/java/vazkii/botania/common/item/brew/ItemVial.java @@ -1,19 +1,18 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 1, 2014, 5:45:50 PM (GMT)] */ package vazkii.botania.common.item.brew; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; + import vazkii.botania.api.brew.Brew; import vazkii.botania.api.brew.IBrewContainer; -import net.minecraft.item.Item; import vazkii.botania.common.item.ModItems; public class ItemVial extends Item implements IBrewContainer { diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumArmor.java b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumArmor.java index 9b4941e87..c4168f284 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumArmor.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumArmor.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.common.item.equipment.armor.elementium; import net.minecraft.client.renderer.entity.model.BipedModel; @@ -10,6 +18,7 @@ import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TranslationTextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.armor.ModelArmorElementium; @@ -50,18 +59,24 @@ public abstract class ItemElementiumArmor extends ItemManasteelArmor { @Override public boolean hasArmorSetItem(PlayerEntity player, EquipmentSlotType slot) { - if(player == null) - return false; - - ItemStack stack = player.getItemStackFromSlot(slot); - if(stack.isEmpty()) + if (player == null) { return false; + } - switch(slot) { - case HEAD: return stack.getItem() == ModItems.elementiumHelm || stack.getItem() == ModItems.elementiumHelmRevealing; - case CHEST: return stack.getItem() == ModItems.elementiumChest; - case LEGS: return stack.getItem() == ModItems.elementiumLegs; - case FEET: return stack.getItem() == ModItems.elementiumBoots; + ItemStack stack = player.getItemStackFromSlot(slot); + if (stack.isEmpty()) { + return false; + } + + switch (slot) { + case HEAD: + return stack.getItem() == ModItems.elementiumHelm || stack.getItem() == ModItems.elementiumHelmRevealing; + case CHEST: + return stack.getItem() == ModItems.elementiumChest; + case LEGS: + return stack.getItem() == ModItems.elementiumLegs; + case FEET: + return stack.getItem() == ModItems.elementiumBoots; } return false; diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumBoots.java b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumBoots.java index 0d54a0309..1efb6f995 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumBoots.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumBoots.java @@ -1,9 +1,18 @@ +/* + * This class is 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 + */ package vazkii.botania.common.item.equipment.armor.elementium; import com.google.common.collect.Multimap; + import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.ItemStack; + import vazkii.botania.common.core.handler.PixieHandler; import javax.annotation.Nonnull; diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumChest.java b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumChest.java index 5bc3868db..326d84574 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumChest.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumChest.java @@ -1,9 +1,18 @@ +/* + * This class is 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 + */ package vazkii.botania.common.item.equipment.armor.elementium; import com.google.common.collect.Multimap; + import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.ItemStack; + import vazkii.botania.common.core.handler.PixieHandler; import javax.annotation.Nonnull; diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumHelm.java b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumHelm.java index 2560b2536..ddbc2df32 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumHelm.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumHelm.java @@ -1,10 +1,20 @@ +/* + * This class is 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 + */ package vazkii.botania.common.item.equipment.armor.elementium; import com.google.common.collect.Multimap; + import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ItemStack; + import vazkii.botania.api.mana.IManaDiscountArmor; import vazkii.botania.common.core.handler.PixieHandler; diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumLegs.java b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumLegs.java index 3ad354afc..b193832d0 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumLegs.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/elementium/ItemElementiumLegs.java @@ -1,9 +1,18 @@ +/* + * This class is 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 + */ package vazkii.botania.common.item.equipment.armor.elementium; import com.google.common.collect.Multimap; + import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.ItemStack; + import vazkii.botania.common.core.handler.PixieHandler; import javax.annotation.Nonnull; diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelArmor.java b/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelArmor.java index 5f7c675b7..894874353 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelArmor.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelArmor.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 13, 2014, 6:38:21 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.manasteel; @@ -30,6 +28,7 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.DistExecutor; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.item.IPhantomInkable; import vazkii.botania.api.mana.IManaUsingItem; @@ -42,9 +41,8 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.ToolCommons; import javax.annotation.Nonnull; -import java.util.EnumMap; + import java.util.List; -import java.util.Map; import java.util.function.Consumer; public class ItemManasteelArmor extends ArmorItem implements IManaUsingItem, IPhantomInkable { @@ -69,14 +67,16 @@ public class ItemManasteelArmor extends ArmorItem implements IManaUsingItem, IPh @Override public void inventoryTick(ItemStack stack, World world, Entity player, int slot, boolean selected) { - if(player instanceof PlayerEntity) + if (player instanceof PlayerEntity) { onArmorTick(stack, world, (PlayerEntity) player); + } } @Override public void onArmorTick(ItemStack stack, World world, PlayerEntity player) { - if(!world.isRemote && stack.getDamage() > 0 && ManaItemHandler.requestManaExact(stack, player, MANA_PER_DAMAGE * 2, true)) + if (!world.isRemote && stack.getDamage() > 0 && ManaItemHandler.requestManaExact(stack, player, MANA_PER_DAMAGE * 2, true)) { stack.setDamage(stack.getDamage() - 1); + } } @Override @@ -97,7 +97,7 @@ public class ItemManasteelArmor extends ArmorItem implements IManaUsingItem, IPh @Override @OnlyIn(Dist.CLIENT) public BipedModel getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlotType armorSlot, BipedModel original) { - if(ConfigHandler.CLIENT.enableArmorModels.get()) { + if (ConfigHandler.CLIENT.enableArmorModels.get()) { return model.getValue(); } @@ -117,9 +117,11 @@ public class ItemManasteelArmor extends ArmorItem implements IManaUsingItem, IPh @OnlyIn(Dist.CLIENT) @Override public void addInformation(ItemStack stack, World world, List list, ITooltipFlag flags) { - if(Screen.hasShiftDown()) + if (Screen.hasShiftDown()) { addInformationAfterShift(stack, world, list, flags); - else list.add(new TranslationTextComponent("botaniamisc.shiftinfo")); + } else { + list.add(new TranslationTextComponent("botaniamisc.shiftinfo")); + } } @OnlyIn(Dist.CLIENT) @@ -134,8 +136,9 @@ public class ItemManasteelArmor extends ArmorItem implements IManaUsingItem, IPh cmp.applyTextStyle(hasArmorSetItem(player, slot) ? TextFormatting.GREEN : TextFormatting.GRAY); list.add(cmp); } - if(hasPhantomInk(stack)) + if (hasPhantomInk(stack)) { list.add(new TranslationTextComponent("botaniamisc.hasPhantomInk").applyTextStyle(TextFormatting.GRAY)); + } } private static final LazyValue armorSet = new LazyValue<>(() -> new ItemStack[] { @@ -154,18 +157,24 @@ public class ItemManasteelArmor extends ArmorItem implements IManaUsingItem, IPh } public boolean hasArmorSetItem(PlayerEntity player, EquipmentSlotType slot) { - if(player == null || player.inventory == null || player.inventory.armorInventory == null) - return false; - - ItemStack stack = player.getItemStackFromSlot(slot); - if(stack.isEmpty()) + if (player == null || player.inventory == null || player.inventory.armorInventory == null) { return false; + } - switch(slot) { - case HEAD: return stack.getItem() == ModItems.manasteelHelm || stack.getItem() == ModItems.manasteelHelmRevealing; - case CHEST: return stack.getItem() == ModItems.manasteelChest; - case LEGS: return stack.getItem() == ModItems.manasteelLegs; - case FEET: return stack.getItem() == ModItems.manasteelBoots; + ItemStack stack = player.getItemStackFromSlot(slot); + if (stack.isEmpty()) { + return false; + } + + switch (slot) { + case HEAD: + return stack.getItem() == ModItems.manasteelHelm || stack.getItem() == ModItems.manasteelHelmRevealing; + case CHEST: + return stack.getItem() == ModItems.manasteelChest; + case LEGS: + return stack.getItem() == ModItems.manasteelLegs; + case FEET: + return stack.getItem() == ModItems.manasteelBoots; } return false; @@ -173,9 +182,11 @@ public class ItemManasteelArmor extends ArmorItem implements IManaUsingItem, IPh private int getSetPiecesEquipped(PlayerEntity player) { int pieces = 0; - for(EquipmentSlotType slot : EquipmentSlotType.values()) - if (slot.getSlotType() == EquipmentSlotType.Group.ARMOR && hasArmorSetItem(player, slot)) + for (EquipmentSlotType slot : EquipmentSlotType.values()) { + if (slot.getSlotType() == EquipmentSlotType.Group.ARMOR && hasArmorSetItem(player, slot)) { pieces++; + } + } return pieces; } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelHelm.java b/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelHelm.java index a38b95970..3f7c42f4c 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelHelm.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/manasteel/ItemManasteelHelm.java @@ -1,18 +1,17 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 13, 2014, 10:22:24 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.manasteel; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ItemStack; + import vazkii.botania.api.mana.IManaDiscountArmor; import javax.annotation.Nullable; diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveArmor.java b/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveArmor.java index 61f8475a3..b289335b9 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveArmor.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveArmor.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 28, 2015, 8:30:19 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.manaweave; @@ -24,6 +22,7 @@ import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.client.core.proxy.ClientProxy; import vazkii.botania.client.lib.LibResources; @@ -33,6 +32,7 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.armor.manasteel.ItemManasteelArmor; import javax.annotation.Nonnull; + import java.util.List; public class ItemManaweaveArmor extends ItemManasteelArmor { @@ -58,8 +58,9 @@ public class ItemManaweaveArmor extends ItemManasteelArmor { @OnlyIn(Dist.CLIENT) public String getTranslationKey(ItemStack stack) { String name = super.getTranslationKey(stack); - if(ClientProxy.jingleTheBells) + if (ClientProxy.jingleTheBells) { name = name.replaceAll("manaweave", "santaweave"); + } return name; } @@ -77,18 +78,24 @@ public class ItemManaweaveArmor extends ItemManasteelArmor { @Override public boolean hasArmorSetItem(PlayerEntity player, EquipmentSlotType slot) { - if(player == null) - return false; - - ItemStack stack = player.getItemStackFromSlot(slot); - if(stack.isEmpty()) + if (player == null) { return false; + } - switch(slot) { - case HEAD: return stack.getItem() == ModItems.manaweaveHelm; - case CHEST: return stack.getItem() == ModItems.manaweaveChest; - case LEGS: return stack.getItem() == ModItems.manaweaveLegs; - case FEET: return stack.getItem() == ModItems.manaweaveBoots; + ItemStack stack = player.getItemStackFromSlot(slot); + if (stack.isEmpty()) { + return false; + } + + switch (slot) { + case HEAD: + return stack.getItem() == ModItems.manaweaveHelm; + case CHEST: + return stack.getItem() == ModItems.manaweaveChest; + case LEGS: + return stack.getItem() == ModItems.manaweaveLegs; + case FEET: + return stack.getItem() == ModItems.manaweaveBoots; } return false; @@ -102,7 +109,7 @@ public class ItemManaweaveArmor extends ItemManasteelArmor { @OnlyIn(Dist.CLIENT) @Override public void addInformationAfterShift(ItemStack stack, World world, List list, ITooltipFlag flags) { - if(ClientProxy.jingleTheBells) { + if (ClientProxy.jingleTheBells) { list.add(new TranslationTextComponent("botaniamisc.santaweaveInfo")); list.add(new StringTextComponent("")); } diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveHelm.java b/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveHelm.java index 4ef4d216d..e42b08515 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveHelm.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/manaweave/ItemManaweaveHelm.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 28, 2015, 8:47:04 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.manaweave; @@ -15,12 +13,14 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ItemStack; import net.minecraft.world.World; + import vazkii.botania.api.item.IManaProficiencyArmor; import vazkii.botania.api.mana.IManaDiscountArmor; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.common.item.equipment.tool.ToolCommons; import javax.annotation.Nullable; + import java.util.function.Consumer; public class ItemManaweaveHelm extends ItemManaweaveArmor implements IManaDiscountArmor, IManaProficiencyArmor { @@ -43,8 +43,9 @@ public class ItemManaweaveHelm extends ItemManaweaveArmor implements IManaDiscou @Override public void onArmorTick(ItemStack stack, World world, PlayerEntity player) { - if(!world.isRemote && stack.getDamage() > 0 && ManaItemHandler.requestManaExact(stack, player, MANA_PER_DAMAGE * 2, true)) + if (!world.isRemote && stack.getDamage() > 0 && ManaItemHandler.requestManaExact(stack, player, MANA_PER_DAMAGE * 2, true)) { stack.setDamage(stack.getDamage() - 1); + } } @Override diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelArmor.java b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelArmor.java index 1fc244c18..e99da1793 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelArmor.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelArmor.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 14, 2014, 2:58:13 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.terrasteel; import com.google.common.collect.Multimap; + import net.minecraft.client.renderer.entity.model.BipedModel; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; @@ -23,6 +22,7 @@ import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TranslationTextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.armor.ModelArmorTerrasteel; @@ -31,6 +31,7 @@ import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.armor.manasteel.ItemManasteelArmor; import javax.annotation.Nonnull; + import java.util.List; import java.util.UUID; @@ -43,7 +44,7 @@ public class ItemTerrasteelArmor extends ItemManasteelArmor { @Override @OnlyIn(Dist.CLIENT) public BipedModel provideArmorModelForSlot(EquipmentSlotType slot) { - return new ModelArmorTerrasteel(slot); + return new ModelArmorTerrasteel(slot); } @Override @@ -78,18 +79,24 @@ public class ItemTerrasteelArmor extends ItemManasteelArmor { @Override public boolean hasArmorSetItem(PlayerEntity player, EquipmentSlotType slot) { - if(player == null) - return false; - - ItemStack stack = player.getItemStackFromSlot(slot); - if(stack.isEmpty()) + if (player == null) { return false; + } - switch(slot) { - case HEAD: return stack.getItem() == ModItems.terrasteelHelm || stack.getItem() == ModItems.terrasteelHelmRevealing; - case CHEST: return stack.getItem() == ModItems.terrasteelChest; - case LEGS: return stack.getItem() == ModItems.terrasteelLegs; - case FEET: return stack.getItem() == ModItems.terrasteelBoots; + ItemStack stack = player.getItemStackFromSlot(slot); + if (stack.isEmpty()) { + return false; + } + + switch (slot) { + case HEAD: + return stack.getItem() == ModItems.terrasteelHelm || stack.getItem() == ModItems.terrasteelHelmRevealing; + case CHEST: + return stack.getItem() == ModItems.terrasteelChest; + case LEGS: + return stack.getItem() == ModItems.terrasteelLegs; + case FEET: + return stack.getItem() == ModItems.terrasteelBoots; } return false; diff --git a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelHelm.java b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelHelm.java index 6f3a49b5c..43299efdb 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelHelm.java +++ b/src/main/java/vazkii/botania/common/item/equipment/armor/terrasteel/ItemTerrasteelHelm.java @@ -1,25 +1,21 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 14, 2014, 3:13:05 PM (GMT)] */ package vazkii.botania.common.item.equipment.armor.terrasteel; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Atlases; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; @@ -35,16 +31,17 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingHurtEvent; + import vazkii.botania.api.item.AccessoryRenderHelper; import vazkii.botania.api.item.IAncientWillContainer; import vazkii.botania.api.mana.IManaDiscountArmor; import vazkii.botania.api.mana.IManaGivingItem; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.client.core.handler.MiscellaneousIcons; -import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.core.helper.ItemNBTHelper; import javax.annotation.Nullable; + import java.util.List; import java.util.Locale; @@ -60,10 +57,11 @@ public class ItemTerrasteelHelm extends ItemTerrasteelArmor implements IManaDisc @Override public void onArmorTick(ItemStack stack, World world, PlayerEntity player) { super.onArmorTick(stack, world, player); - if(hasArmorSet(player)) { + if (hasArmorSet(player)) { int food = player.getFoodStats().getFoodLevel(); - if(food > 0 && food < 18 && player.shouldHeal() && player.ticksExisted % 80 == 0) + if (food > 0 && food < 18 && player.shouldHeal() && player.ticksExisted % 80 == 0) { player.heal(1F); + } ManaItemHandler.dispatchManaExact(stack, player, 1, true); } } @@ -91,22 +89,26 @@ public class ItemTerrasteelHelm extends ItemTerrasteelArmor implements IManaDisc @OnlyIn(Dist.CLIENT) public void addArmorSetDescription(ItemStack stack, List list) { super.addArmorSetDescription(stack, list); - for(AncientWillType type : AncientWillType.values()) - if(hasAncientWill(stack, type)) + for (AncientWillType type : AncientWillType.values()) { + if (hasAncientWill(stack, type)) { list.add(new TranslationTextComponent("botania.armorset.will_" + type.name().toLowerCase(Locale.ROOT) + ".desc").applyTextStyle(TextFormatting.GRAY)); + } + } } private static boolean hasAnyWill(ItemStack stack) { - for(AncientWillType type : AncientWillType.values()) - if(hasAncientWill_(stack, type)) + for (AncientWillType type : AncientWillType.values()) { + if (hasAncientWill_(stack, type)) { return true; + } + } return false; } @OnlyIn(Dist.CLIENT) public static void renderOnPlayer(MatrixStack ms, IRenderTypeBuffer buffers, int light, ItemStack stack, PlayerEntity player, float partialTicks) { - if(hasAnyWill(stack) && !((ItemTerrasteelArmor) stack.getItem()).hasPhantomInk(stack)) { + if (hasAnyWill(stack) && !((ItemTerrasteelArmor) stack.getItem()).hasPhantomInk(stack)) { ms.push(); AccessoryRenderHelper.translateToHeadLevel(ms, player, partialTicks); ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(90F)); @@ -123,24 +125,30 @@ public class ItemTerrasteelHelm extends ItemTerrasteelArmor implements IManaDisc private void onEntityAttacked(LivingHurtEvent event) { Entity attacker = event.getSource().getImmediateSource(); - if(attacker instanceof PlayerEntity) { + if (attacker instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity) attacker; - if(hasArmorSet(player)) { + if (hasArmorSet(player)) { boolean crit = player.fallDistance > 0.0F && !player.onGround && !player.isOnLadder() && !player.isInWater() && !player.isPotionActive(Effects.BLINDNESS) && !player.isPassenger(); ItemStack stack = player.getItemStackFromSlot(EquipmentSlotType.HEAD); - if(crit && !stack.isEmpty() && stack.getItem() instanceof ItemTerrasteelHelm) { - if(hasAncientWill(stack, AncientWillType.AHRIM)) + if (crit && !stack.isEmpty() && stack.getItem() instanceof ItemTerrasteelHelm) { + if (hasAncientWill(stack, AncientWillType.AHRIM)) { event.getEntityLiving().addPotionEffect(new EffectInstance(Effects.WEAKNESS, 20, 1)); - if(hasAncientWill(stack, AncientWillType.DHAROK)) + } + if (hasAncientWill(stack, AncientWillType.DHAROK)) { event.setAmount(event.getAmount() * (1F + (1F - player.getHealth() / player.getMaxHealth()) * 0.5F)); - if(hasAncientWill(stack, AncientWillType.GUTHAN)) + } + if (hasAncientWill(stack, AncientWillType.GUTHAN)) { player.heal(event.getAmount() * 0.25F); - if(hasAncientWill(stack, AncientWillType.TORAG)) + } + if (hasAncientWill(stack, AncientWillType.TORAG)) { event.getEntityLiving().addPotionEffect(new EffectInstance(Effects.SLOWNESS, 60, 1)); - if(hasAncientWill(stack, AncientWillType.VERAC)) + } + if (hasAncientWill(stack, AncientWillType.VERAC)) { event.getSource().setDamageBypassesArmor(); - if(hasAncientWill(stack, AncientWillType.KARIL)) + } + if (hasAncientWill(stack, AncientWillType.KARIL)) { event.getEntityLiving().addPotionEffect(new EffectInstance(Effects.WITHER, 60, 1)); + } } } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemAuraRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemAuraRing.java index f0c42ea90..d63b20104 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemAuraRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemAuraRing.java @@ -1,18 +1,17 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 24, 2014, 4:43:47 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; + import vazkii.botania.api.mana.IManaGivingItem; import vazkii.botania.api.mana.ManaItemHandler; @@ -24,7 +23,8 @@ public class ItemAuraRing extends ItemBauble implements IManaGivingItem { @Override public void onWornTick(ItemStack stack, LivingEntity player) { - if (player instanceof PlayerEntity && player.ticksExisted % 10 == 0) + if (player instanceof PlayerEntity && player.ticksExisted % 10 == 0) { ManaItemHandler.dispatchManaExact(stack, (PlayerEntity) player, 1, true); + } } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBalanceCloak.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBalanceCloak.java index 99d05ad9e..4c5bd3840 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBalanceCloak.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBalanceCloak.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [14/10/2016, 19:55:51 (GMT)] */ package vazkii.botania.common.item.equipment.bauble; @@ -18,6 +16,7 @@ import net.minecraft.util.SoundCategory; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.event.entity.living.LivingHurtEvent; + import vazkii.botania.client.fx.SparkleParticleData; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.core.handler.ModSounds; @@ -30,28 +29,30 @@ public class ItemBalanceCloak extends ItemHolyCloak { public ItemBalanceCloak(Properties props) { super(props); } - + public boolean effectOnDamage(LivingHurtEvent event, PlayerEntity player, ItemStack stack) { - if(!event.getSource().isMagicDamage()) { + if (!event.getSource().isMagicDamage()) { event.setAmount(event.getAmount() / 2); - - if(event.getSource().getTrueSource() != null) + + if (event.getSource().getTrueSource() != null) { event.getSource().getTrueSource().attackEntityFrom(DamageSource.causeIndirectMagicDamage(player, player), event.getAmount()); - - if(event.getAmount() > player.getHealth()) + } + + if (event.getAmount() > player.getHealth()) { event.setAmount(player.getHealth() - 1); - + } + player.world.playSound(null, player.getX(), player.getY(), player.getZ(), ModSounds.holyCloak, SoundCategory.PLAYERS, 1F, 1F); - for(int i = 0; i < 30; i++) { + for (int i = 0; i < 30; i++) { double x = player.getX() + Math.random() * player.getWidth() * 2 - player.getWidth(); double y = player.getY() + Math.random() * player.getHeight(); double z = player.getZ() + Math.random() * player.getWidth() * 2 - player.getWidth(); boolean green = Math.random() > 0.5; - float g = green ? 1F : 0.3F; - float b = green ? 0.3F : 1F; - SparkleParticleData data = SparkleParticleData.sparkle(0.8F + (float) Math.random() * 0.4F, 0.3F, g, b, 3); - player.world.addParticle(data, x, y, z, 0, 0, 0); - } + float g = green ? 1F : 0.3F; + float b = green ? 0.3F : 1F; + SparkleParticleData data = SparkleParticleData.sparkle(0.8F + (float) Math.random() * 0.4F, 0.3F, g, b, 3); + player.world.addParticle(data, x, y, z, 0, 0, 0); + } return true; } 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 d6ff2327a..04c33f451 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 @@ -1,24 +1,24 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 20, 2014, 3:30:06 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import com.mojang.blaze3d.matrix.MatrixStack; + import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.potion.Effects; @@ -30,17 +30,18 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.api.item.ICosmeticAttachable; import vazkii.botania.api.item.IPhantomInkable; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.core.handler.EquipmentHandler; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.core.helper.PlayerHelper; -import net.minecraft.item.Item; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; import javax.annotation.Nullable; + import java.util.List; import java.util.UUID; @@ -59,39 +60,46 @@ public abstract class ItemBauble extends Item implements ICosmeticAttachable, IP @Override @OnlyIn(Dist.CLIENT) public void addInformation(ItemStack stack, World world, List stacks, ITooltipFlag flags) { - if(Screen.hasShiftDown()) + if (Screen.hasShiftDown()) { addHiddenTooltip(stack, world, stacks, flags); - else stacks.add(new TranslationTextComponent("botaniamisc.shiftinfo")); + } else { + stacks.add(new TranslationTextComponent("botaniamisc.shiftinfo")); + } } @OnlyIn(Dist.CLIENT) public void addHiddenTooltip(ItemStack stack, World world, List stacks, ITooltipFlag flags) { String key = vazkii.botania.client.core.helper.RenderHelper.getKeyDisplayString("key.curios.open.desc"); - if(key != null) + if (key != null) { stacks.add(new TranslationTextComponent("botania.baubletooltip", key)); + } ItemStack cosmetic = getCosmeticItem(stack); - if(!cosmetic.isEmpty()) + if (!cosmetic.isEmpty()) { stacks.add(new TranslationTextComponent("botaniamisc.hasCosmetic", cosmetic.getDisplayName())); + } - if(hasPhantomInk(stack)) + if (hasPhantomInk(stack)) { stacks.add(new TranslationTextComponent("botaniamisc.hasPhantomInk")); + } } @Override public ItemStack getCosmeticItem(ItemStack stack) { CompoundNBT cmp = ItemNBTHelper.getCompound(stack, TAG_COSMETIC_ITEM, true); - if(cmp == null) + if (cmp == null) { return ItemStack.EMPTY; + } return ItemStack.read(cmp); } @Override public void setCosmeticItem(ItemStack stack, ItemStack cosmetic) { CompoundNBT cmp = new CompoundNBT(); - if(!cosmetic.isEmpty()) + if (!cosmetic.isEmpty()) { cmp = cosmetic.write(cmp); + } ItemNBTHelper.setCompound(stack, TAG_COSMETIC_ITEM, cmp); } @@ -108,7 +116,7 @@ public abstract class ItemBauble extends Item implements ICosmeticAttachable, IP public static UUID getBaubleUUID(ItemStack stack) { long most = ItemNBTHelper.getLong(stack, TAG_BAUBLE_UUID_MOST, 0); - if(most == 0) { + if (most == 0) { UUID uuid = UUID.randomUUID(); ItemNBTHelper.setLong(stack, TAG_BAUBLE_UUID_MOST, uuid.getMostSignificantBits()); ItemNBTHelper.setLong(stack, TAG_BAUBLE_UUID_LEAST, uuid.getLeastSignificantBits()); @@ -138,7 +146,7 @@ public abstract class ItemBauble extends Item implements ICosmeticAttachable, IP public void onWornTick(ItemStack stack, LivingEntity entity) {} public void onEquipped(ItemStack stack, LivingEntity entity) { - if(!entity.world.isRemote && entity instanceof ServerPlayerEntity) { + if (!entity.world.isRemote && entity instanceof ServerPlayerEntity) { PlayerHelper.grantCriterion((ServerPlayerEntity) entity, new ResourceLocation(LibMisc.MOD_ID, "main/bauble_wear"), "code_triggered"); } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBaubleCosmetic.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBaubleCosmetic.java index 75204becc..e770546de 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBaubleCosmetic.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBaubleCosmetic.java @@ -1,54 +1,35 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 22, 2015, 2:01:01 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; -import com.mojang.blaze3d.vertex.IVertexBuilder; -import net.minecraft.block.BlockState; + import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.Atlases; -import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.ItemRenderer; -import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.RenderTypeLookup; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Vector3f; -import net.minecraft.client.renderer.model.BakedQuad; -import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.model.ItemCameraTransforms; -import net.minecraft.client.renderer.model.ModelResourceLocation; -import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.LivingEntity; import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.Direction; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import org.lwjgl.opengl.GL11; + import vazkii.botania.api.item.AccessoryRenderHelper; import vazkii.botania.api.item.ICosmeticBauble; import vazkii.botania.client.core.helper.RenderHelper; import java.util.List; -import java.util.Objects; -import java.util.Random; public class ItemBaubleCosmetic extends ItemBauble implements ICosmeticBauble { @@ -85,7 +66,7 @@ public class ItemBaubleCosmetic extends ItemBauble implements ICosmeticBauble { @OnlyIn(Dist.CLIENT) @Override public void addHiddenTooltip(ItemStack stack, World world, List stacks, ITooltipFlag flags) { - if(variant == Variant.THINKING_HAND) { + if (variant == Variant.THINKING_HAND) { stacks.add(new TranslationTextComponent("botaniamisc.cosmeticThinking").applyTextStyle(TextFormatting.GRAY)); } else { stacks.add(new TranslationTextComponent("botaniamisc.cosmeticBauble").applyTextStyle(TextFormatting.GRAY)); @@ -93,12 +74,11 @@ public class ItemBaubleCosmetic extends ItemBauble implements ICosmeticBauble { super.addHiddenTooltip(stack, world, stacks, flags); } - @Override @OnlyIn(Dist.CLIENT) public void doRender(ItemStack stack, LivingEntity player, MatrixStack ms, IRenderTypeBuffer buffers, int light, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) { Variant variant = ((ItemBaubleCosmetic) stack.getItem()).variant; - if(variant.isHead) { + if (variant.isHead) { AccessoryRenderHelper.translateToHeadLevel(ms, player, partialTicks); AccessoryRenderHelper.translateToFace(ms); AccessoryRenderHelper.defaultTransforms(ms); diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBloodPendant.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBloodPendant.java index ad2980547..80421eb4c 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBloodPendant.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBloodPendant.java @@ -1,28 +1,22 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 6, 2014, 5:11:23 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GLX; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Atlases; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.I18n; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.LivingEntity; @@ -39,6 +33,7 @@ import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.brew.Brew; import vazkii.botania.api.brew.IBrewContainer; @@ -47,10 +42,8 @@ import vazkii.botania.api.item.AccessoryRenderHelper; import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.client.core.handler.MiscellaneousIcons; -import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.core.helper.ItemNBTHelper; -import java.awt.*; import java.util.List; public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBrewItem, IManaUsingItem { @@ -64,11 +57,12 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre @Override public void fillItemGroup(ItemGroup tab, NonNullList list) { super.fillItemGroup(tab, list); - if(isInGroup(tab)) { - for(String s : BotaniaAPI.brewMap.keySet()) { + if (isInGroup(tab)) { + for (String s : BotaniaAPI.brewMap.keySet()) { ItemStack brewStack = getItemForBrew(BotaniaAPI.brewMap.get(s), new ItemStack(this)); - if(!brewStack.isEmpty()) + if (!brewStack.isEmpty()) { list.add(brewStack); + } } } } @@ -79,16 +73,16 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre super.addHiddenTooltip(stack, world, list, adv); Brew brew = getBrew(stack); - if(brew == BotaniaAPI.fallbackBrew) { + if (brew == BotaniaAPI.fallbackBrew) { list.add(new TranslationTextComponent("botaniamisc.notInfused").applyTextStyle(TextFormatting.LIGHT_PURPLE)); return; } list.add(new TranslationTextComponent("botaniamisc.brewOf", I18n.format(brew.getUnlocalizedName(stack))).applyTextStyle(TextFormatting.LIGHT_PURPLE)); - for(EffectInstance effect : brew.getPotionEffects(stack)) { + for (EffectInstance effect : brew.getPotionEffects(stack)) { TextFormatting format = effect.getPotion().type.getColor(); ITextComponent cmp = new TranslationTextComponent(effect.getEffectName()); - if(effect.getAmplifier() > 0) { + if (effect.getAmplifier() > 0) { cmp.appendText(" "); cmp.appendSibling(new TranslationTextComponent("botania.roman" + (effect.getAmplifier() + 1))); } @@ -112,8 +106,9 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre player.addPotionEffect(applyEffect); } - if (!doRand || Math.random() < cost) + if (!doRand || Math.random() < cost) { ManaItemHandler.requestManaExact(stack, eplayer, (int) Math.ceil(cost), true); + } } } } @@ -157,8 +152,9 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre @Override public ItemStack getItemForBrew(Brew brew, ItemStack stack) { - if(!brew.canInfuseBloodPendant() || brew.getPotionEffects(stack).size() != 1 || brew.getPotionEffects(stack).get(0).getPotion().isInstant()) + if (!brew.canInfuseBloodPendant() || brew.getPotionEffects(stack).size() != 1 || brew.getPotionEffects(stack).get(0).getPotion().isInstant()) { return ItemStack.EMPTY; + } ItemStack brewStack = new ItemStack(this); setBrew(brewStack, brew); diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemCloudPendant.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemCloudPendant.java index 247cf08e0..5580531fd 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemCloudPendant.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemCloudPendant.java @@ -1,37 +1,32 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [22/10/2016, 16:52:36 (GMT)] */ package vazkii.botania.common.item.equipment.bauble; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.Minecraft; import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.client.renderer.Atlases; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.entity.LivingEntity; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ItemStack; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.DistExecutor; + import vazkii.botania.api.item.AccessoryRenderHelper; import vazkii.botania.client.core.handler.MiscellaneousIcons; -import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.network.PacketHandler; import vazkii.botania.common.network.PacketJump; @@ -40,7 +35,7 @@ public class ItemCloudPendant extends ItemBauble { private static int timesJumped; private static boolean jumpDown; - + public ItemCloudPendant(Properties props) { super(props); } @@ -48,20 +43,22 @@ public class ItemCloudPendant extends ItemBauble { @Override public void onWornTick(ItemStack stack, LivingEntity player) { DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> { - if(player == Minecraft.getInstance().player) { + if (player == Minecraft.getInstance().player) { ClientPlayerEntity playerSp = (ClientPlayerEntity) player; - if (playerSp.onGround) + if (playerSp.onGround) { timesJumped = 0; - else { - if(playerSp.movementInput.jump) { + } else { + if (playerSp.movementInput.jump) { if (!jumpDown && timesJumped < ((ItemCloudPendant) stack.getItem()).getMaxAllowedJumps()) { playerSp.jump(); PacketHandler.sendToServer(new PacketJump()); timesJumped++; } jumpDown = true; - } else jumpDown = false; + } else { + jumpDown = false; + } } } }); diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDivaCharm.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDivaCharm.java index aa9163abe..d665a96ab 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDivaCharm.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDivaCharm.java @@ -1,23 +1,20 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 25, 2014, 10:30:39 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; import com.google.common.base.Predicates; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.model.ItemCameraTransforms; -import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; @@ -35,6 +32,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.fml.server.ServerLifecycleHooks; + import vazkii.botania.api.item.AccessoryRenderHelper; import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; @@ -55,7 +53,7 @@ public class ItemDivaCharm extends ItemBauble implements IManaUsingItem { } private void onEntityDamaged(LivingHurtEvent event) { - if(event.getSource().getImmediateSource() instanceof PlayerEntity + if (event.getSource().getImmediateSource() instanceof PlayerEntity && event.getEntityLiving() instanceof MobEntity && !event.getEntityLiving().world.isRemote && event.getEntityLiving().isNonBoss() @@ -65,18 +63,19 @@ public class ItemDivaCharm extends ItemBauble implements IManaUsingItem { PlayerEntity player = (PlayerEntity) event.getSource().getImmediateSource(); ItemStack amulet = EquipmentHandler.findOrEmpty(ModItems.divaCharm, player); - if(!amulet.isEmpty()) { + if (!amulet.isEmpty()) { final int cost = 250; - if(ManaItemHandler.requestManaExact(amulet, player, cost, false)) { + if (ManaItemHandler.requestManaExact(amulet, player, cost, false)) { final int range = 20; List mobs = player.world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(target.getX() - range, target.getY() - range, target.getZ() - range, target.getX() + range, target.getY() + range, target.getZ() + range), Predicates.instanceOf(IMob.class)); - if(mobs.size() > 1) { - if(SubTileHeiseiDream.brainwashEntity(target, (List) mobs)) { + if (mobs.size() > 1) { + if (SubTileHeiseiDream.brainwashEntity(target, (List) mobs)) { target.heal(target.getMaxHealth()); target.revive(); - if(target instanceof CreeperEntity) + if (target instanceof CreeperEntity) { ((CreeperEntity) event.getEntityLiving()).timeSinceIgnited = 2; + } ManaItemHandler.requestManaExact(amulet, player, cost, true); player.world.playSound(null, player.getX(), player.getY(), player.getZ(), ModSounds.divaCharm, SoundCategory.PLAYERS, 1F, 1F); diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDodgeRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDodgeRing.java index 08527d51b..0c0d6b0ab 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDodgeRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDodgeRing.java @@ -1,17 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [22/09/2016, 12:56:22 (GMT)] */ package vazkii.botania.common.item.equipment.bauble; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.AbstractGui; import net.minecraft.entity.LivingEntity; @@ -24,6 +22,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.event.InputEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.common.core.handler.EquipmentHandler; import vazkii.botania.common.core.helper.ItemNBTHelper; @@ -50,38 +49,44 @@ public class ItemDodgeRing extends ItemBauble { @OnlyIn(Dist.CLIENT) public static void onKeyDown(InputEvent.KeyInputEvent event) { Minecraft mc = Minecraft.getInstance(); - if(mc.player == null) + if (mc.player == null) { return; + } ItemStack ringStack = EquipmentHandler.findOrEmpty(ModItems.dodgeRing, mc.player); - if(ringStack.isEmpty() || ItemNBTHelper.getInt(ringStack, TAG_DODGE_COOLDOWN, 0) > 0) + if (ringStack.isEmpty() || ItemNBTHelper.getInt(ringStack, TAG_DODGE_COOLDOWN, 0) > 0) { return; + } int threshold = 5; - if(mc.gameSettings.keyBindLeft.isKeyDown() && !oldLeftDown) { + if (mc.gameSettings.keyBindLeft.isKeyDown() && !oldLeftDown) { int oldLeft = leftDown; leftDown = ClientTickHandler.ticksInGame; - if(leftDown - oldLeft < threshold) + if (leftDown - oldLeft < threshold) { dodge(mc.player, Direction.WEST); - } else if(mc.gameSettings.keyBindRight.isKeyDown() && !oldRightDown) { + } + } else if (mc.gameSettings.keyBindRight.isKeyDown() && !oldRightDown) { int oldRight = rightDown; rightDown = ClientTickHandler.ticksInGame; - if(rightDown - oldRight < threshold) + if (rightDown - oldRight < threshold) { dodge(mc.player, Direction.EAST); - } else if(mc.gameSettings.keyBindForward.isKeyDown() && !oldForwardDown) { + } + } else if (mc.gameSettings.keyBindForward.isKeyDown() && !oldForwardDown) { int oldForward = forwardDown; forwardDown = ClientTickHandler.ticksInGame; - if(forwardDown - oldForward < threshold) + if (forwardDown - oldForward < threshold) { dodge(mc.player, Direction.NORTH); - } else if(mc.gameSettings.keyBindBack.isKeyDown() && !oldBackDown) { + } + } else if (mc.gameSettings.keyBindBack.isKeyDown() && !oldBackDown) { int oldBack = backDown; backDown = ClientTickHandler.ticksInGame; - if(backDown - oldBack < threshold) + if (backDown - oldBack < threshold) { dodge(mc.player, Direction.SOUTH); + } } oldLeftDown = mc.gameSettings.keyBindLeft.isKeyDown(); @@ -90,28 +95,28 @@ public class ItemDodgeRing extends ItemBauble { oldBackDown = mc.gameSettings.keyBindBack.isKeyDown(); } - @Override public void onWornTick(ItemStack stack, LivingEntity player) { int cd = ItemNBTHelper.getInt(stack, TAG_DODGE_COOLDOWN, 0); - if(cd > 0) + if (cd > 0) { ItemNBTHelper.setInt(stack, TAG_DODGE_COOLDOWN, cd - 1); + } } private static void dodge(PlayerEntity player, Direction dir) { - if(player.abilities.isFlying || !player.onGround || dir == Direction.UP || dir == Direction.DOWN) + if (player.abilities.isFlying || !player.onGround || dir == Direction.UP || dir == Direction.DOWN) { return; + } float yaw = player.rotationYaw; float x = MathHelper.sin(-yaw * 0.017453292F - (float) Math.PI); float z = MathHelper.cos(-yaw * 0.017453292F - (float) Math.PI); - if(dir == Direction.NORTH || dir == Direction.SOUTH) { + if (dir == Direction.NORTH || dir == Direction.SOUTH) { x = MathHelper.cos(-yaw * 0.017453292F); z = MathHelper.sin(yaw * 0.017453292F); } Vector3 lookVec = new Vector3(x, 0, z); - Vector3 sideVec = lookVec.crossProduct(new Vector3(0, dir == Direction.WEST || dir == Direction.NORTH? 1 : - (dir == Direction.EAST || dir == Direction.SOUTH? -1 : 0), 0)).multiply(1.25); + Vector3 sideVec = lookVec.crossProduct(new Vector3(0, dir == Direction.WEST || dir == Direction.NORTH ? 1 : (dir == Direction.EAST || dir == Direction.SOUTH ? -1 : 0), 0)).multiply(1.25); player.setMotion(sideVec.toVec3D()); @@ -123,11 +128,11 @@ public class ItemDodgeRing extends ItemBauble { int xo = Minecraft.getInstance().getWindow().getScaledWidth() / 2 - 20; int y = Minecraft.getInstance().getWindow().getScaledHeight() / 2 + 20; - if(!player.abilities.isFlying) { + if (!player.abilities.isFlying) { int cd = ItemNBTHelper.getInt(stack, TAG_DODGE_COOLDOWN, 0); int width = Math.min((int) ((cd - pticks) * 2), 40); RenderSystem.color4f(1F, 1F, 1F, 1F); - if(width > 0) { + if (width > 0) { AbstractGui.fill(xo, y - 2, xo + 40, y - 1, 0x88000000); AbstractGui.fill(xo, y - 2, xo + width, y - 1, 0xFFFFFFFF); } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java index 722bcfe90..d11285df8 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java @@ -1,18 +1,17 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 26, 2014, 4:05:50 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.AbstractGui; import net.minecraft.client.renderer.IRenderTypeBuffer; @@ -38,7 +37,9 @@ import net.minecraftforge.client.gui.ForgeIngameGui; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import net.minecraftforge.event.entity.player.PlayerEvent; + import org.lwjgl.opengl.GL11; + import vazkii.botania.api.item.AccessoryRenderHelper; import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; @@ -56,6 +57,7 @@ import vazkii.botania.common.item.ModItems; import javax.annotation.Nonnull; import javax.annotation.Nullable; + import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -92,8 +94,8 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem { @Override public void fillItemGroup(@Nonnull ItemGroup tab, @Nonnull NonNullList list) { - if(isInGroup(tab)) { - for(int i = 0; i < SUBTYPES + 1; i++) { + if (isInGroup(tab)) { + for (int i = 0; i < SUBTYPES + 1; i++) { ItemStack stack = new ItemStack(this); ItemNBTHelper.setInt(stack, TAG_VARIANT, i); list.add(stack); @@ -109,18 +111,18 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem { } private void updatePlayerFlyStatus(LivingUpdateEvent event) { - if(event.getEntityLiving() instanceof PlayerEntity) { + if (event.getEntityLiving() instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity) event.getEntityLiving(); ItemStack tiara = EquipmentHandler.findOrEmpty(ModItems.flightTiara, player); int left = ItemNBTHelper.getInt(tiara, TAG_TIME_LEFT, MAX_FLY_TIME); - if(playersWithFlight.contains(playerStr(player))) { - if(shouldPlayerHaveFlight(player)) { + if (playersWithFlight.contains(playerStr(player))) { + if (shouldPlayerHaveFlight(player)) { player.abilities.allowFlying = true; - if(player.abilities.isFlying) { - if(!player.world.isRemote) + if (player.abilities.isFlying) { + if (!player.world.isRemote) { ManaItemHandler.requestManaExact(tiara, player, getCost(tiara, left), true); - else if(Math.abs(player.getMotion().getX()) > 0.1 || Math.abs(player.getMotion().getZ()) > 0.1) { + } else if (Math.abs(player.getMotion().getX()) > 0.1 || Math.abs(player.getMotion().getZ()) > 0.1) { double x = event.getEntityLiving().getX() - 0.5; double y = event.getEntityLiving().getY() - 0.5; double z = event.getEntityLiving().getZ() - 0.5; @@ -131,69 +133,69 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem { float b = 1F; int variant = getVariant(tiara); - switch(variant) { - case 2 : { + switch (variant) { + case 2: { r = 0.1F; g = 0.1F; b = 0.1F; break; } - case 3 : { + case 3: { r = 0F; g = 0.6F; break; } - case 4 : { + case 4: { g = 0.3F; b = 0.3F; break; } - case 5 : { + case 5: { r = 0.6F; g = 0F; b = 0.6F; break; } - case 6 : { + case 6: { r = 0.4F; g = 0F; b = 0F; break; } - case 7 : { + case 7: { r = 0.2F; g = 0.6F; b = 0.2F; break; } - case 8 : { + case 8: { r = 0.85F; g = 0.85F; b = 0F; break; } - case 9 : { + case 9: { r = 0F; b = 0F; break; } } - for(int i = 0; i < 2; i++) { - SparkleParticleData data = SparkleParticleData.sparkle(2F * (float) Math.random(), r, g, b, 20); - player.world.addParticle(data, x + Math.random() * event.getEntityLiving().getWidth(), y + Math.random() * 0.4, z + Math.random() * event.getEntityLiving().getWidth(), 0, 0, 0); - } + for (int i = 0; i < 2; i++) { + SparkleParticleData data = SparkleParticleData.sparkle(2F * (float) Math.random(), r, g, b, 20); + player.world.addParticle(data, x + Math.random() * event.getEntityLiving().getWidth(), y + Math.random() * 0.4, z + Math.random() * event.getEntityLiving().getWidth(), 0, 0, 0); + } } } } else { - if(!player.isSpectator() && !player.abilities.isCreativeMode) { + if (!player.isSpectator() && !player.abilities.isCreativeMode) { player.abilities.allowFlying = false; player.abilities.isFlying = false; player.abilities.disableDamage = false; } playersWithFlight.remove(playerStr(player)); } - } else if(shouldPlayerHaveFlight(player)) { + } else if (shouldPlayerHaveFlight(player)) { playersWithFlight.add(playerStr(player)); player.abilities.allowFlying = true; } @@ -211,8 +213,8 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem { } private boolean shouldPlayerHaveFlight(PlayerEntity player) { - ItemStack armor = EquipmentHandler.findOrEmpty(ModItems.flightTiara, player); - if(!armor.isEmpty()) { + ItemStack armor = EquipmentHandler.findOrEmpty(ModItems.flightTiara, player); + if (!armor.isEmpty()) { int left = ItemNBTHelper.getInt(armor, TAG_TIME_LEFT, MAX_FLY_TIME); boolean flying = ItemNBTHelper.getBoolean(armor, TAG_FLYING, false); return (left > (flying ? 0 : MAX_FLY_TIME / 10) || player.inventory.hasItemStack(new ItemStack(ModItems.flugelEye))) && ManaItemHandler.requestManaExact(armor, player, getCost(armor, left), false); @@ -234,7 +236,7 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem { public void onEquipped(ItemStack stack, LivingEntity living) { super.onEquipped(stack, living); int variant = getVariant(stack); - if(variant != WING_TYPES && StringObfuscator.matchesHash(stack.getDisplayName().getString(), SUPER_AWESOME_HASH)) { + if (variant != WING_TYPES && StringObfuscator.matchesHash(stack.getDisplayName().getString(), SUPER_AWESOME_HASH)) { ItemNBTHelper.setInt(stack, TAG_VARIANT, WING_TYPES); stack.clearCustomName(); } @@ -242,32 +244,34 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem { @Override public void onWornTick(ItemStack stack, LivingEntity player) { - if(player instanceof PlayerEntity) { + if (player instanceof PlayerEntity) { PlayerEntity p = (PlayerEntity) player; boolean flying = p.abilities.isFlying; boolean wasSprting = ItemNBTHelper.getBoolean(stack, TAG_IS_SPRINTING, false); boolean isSprinting = p.isSprinting(); - if(isSprinting != wasSprting) + if (isSprinting != wasSprting) { ItemNBTHelper.setBoolean(stack, TAG_IS_SPRINTING, isSprinting); + } int time = ItemNBTHelper.getInt(stack, TAG_TIME_LEFT, MAX_FLY_TIME); int newTime = time; Vector3 look = new Vector3(p.getLookVec()).multiply(1, 0, 1).normalize(); - if(flying) { - if(time > 0 && !p.isSpectator() && !p.isCreative() - && !ItemNBTHelper.getBoolean(stack, TAG_INFINITE_FLIGHT, false)) + if (flying) { + if (time > 0 && !p.isSpectator() && !p.isCreative() + && !ItemNBTHelper.getBoolean(stack, TAG_INFINITE_FLIGHT, false)) { newTime--; + } final int maxCd = 80; int cooldown = ItemNBTHelper.getInt(stack, TAG_DASH_COOLDOWN, 0); - if(!wasSprting && isSprinting && cooldown == 0) { + if (!wasSprting && isSprinting && cooldown == 0) { p.setMotion(p.getMotion().add(look.x, 0, look.z)); p.world.playSound(null, p.getX(), p.getY(), p.getZ(), ModSounds.dash, SoundCategory.PLAYERS, 1F, 1F); ItemNBTHelper.setInt(stack, TAG_DASH_COOLDOWN, maxCd); ItemNBTHelper.setBoolean(stack, TAG_BOOST_PENDING, true); - } else if(cooldown > 0) { - if(ItemNBTHelper.getBoolean(stack, TAG_BOOST_PENDING, false)) { + } else if (cooldown > 0) { + if (ItemNBTHelper.getBoolean(stack, TAG_BOOST_PENDING, false)) { player.moveRelative(5F, new Vec3d(0F, 0F, 1F)); ItemNBTHelper.removeEntry(stack, TAG_BOOST_PENDING); } @@ -276,10 +280,11 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem { } else { boolean wasGliding = ItemNBTHelper.getBoolean(stack, TAG_GLIDING, false); boolean doGlide = player.isSneaking() && !player.onGround && (player.getMotion().getY() < -.7F || wasGliding); - if(time < MAX_FLY_TIME && player.ticksExisted % (doGlide ? 6 : 2) == 0) + if (time < MAX_FLY_TIME && player.ticksExisted % (doGlide ? 6 : 2) == 0) { newTime++; + } - if(doGlide) { + if (doGlide) { float mul = 0.6F; player.setMotion(look.x * mul, Math.max(-0.15F, player.getMotion().getY()), look.z * mul); player.fallDistance = 2F; @@ -288,8 +293,9 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem { } ItemNBTHelper.setBoolean(stack, TAG_FLYING, flying); - if(newTime != time) + if (newTime != time) { ItemNBTHelper.setInt(stack, TAG_TIME_LEFT, newTime); + } } } @@ -302,7 +308,7 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem { @OnlyIn(Dist.CLIENT) public void doRender(ItemStack stack, LivingEntity player, MatrixStack ms, IRenderTypeBuffer buffers, int light, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) { int meta = getVariant(stack); - if(meta > 0 && meta <= MiscellaneousIcons.INSTANCE.tiaraWingIcons.length) { + if (meta > 0 && meta <= MiscellaneousIcons.INSTANCE.tiaraWingIcons.length) { IBakedModel model = MiscellaneousIcons.INSTANCE.tiaraWingIcons[meta - 1]; boolean flying = ((PlayerEntity) player).abilities.isFlying; @@ -396,7 +402,7 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem { RenderHelper.renderItemCustomColor(player, stack, color, ms, buffers, light, OverlayTexture.DEFAULT_UV, model); ms.pop(); - if(meta != 2) { // Sephiroth + if (meta != 2) { // Sephiroth ms.scale(-1F, 1F, 1F); ms.push(); ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(rz)); @@ -409,22 +415,26 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem { ms.pop(); - if(meta == 1) + if (meta == 1) { renderHalo(player, ms, buffers, partialTicks); + } } } @OnlyIn(Dist.CLIENT) public static void renderHalo(@Nullable LivingEntity player, MatrixStack ms, IRenderTypeBuffer buffers, float partialTicks) { - if(player != null) + if (player != null) { AccessoryRenderHelper.translateToHeadLevel(ms, player, partialTicks); + } ms.translate(0, 1.5F, 0); ms.multiply(new Vector3f(1, 0, -1).getDegreesQuaternion(30)); ms.translate(-0.1F, -0.5F, -0.1F); - if(player != null) + if (player != null) { ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(player.ticksExisted + partialTicks)); - else ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(Botania.proxy.getWorldElapsedTicks())); - + } else { + ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(Botania.proxy.getWorldElapsedTicks())); + } + IVertexBuilder buffer = buffers.getBuffer(RenderHelper.HALO); Matrix4f mat = ms.peek().getModel(); buffer.vertex(mat, -0.75F, 0, -0.75F).texture(0, 0).endVertex(); @@ -451,9 +461,9 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem { int segs = left / segTime + 1; int last = left % segTime; - for(int i = 0; i < segs; i++) { + for (int i = 0; i < segs; i++) { float trans = 1F; - if(i == segs - 1) { + if (i == segs - 1) { trans = (float) last / (float) segTime; RenderSystem.enableBlend(); RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); @@ -465,11 +475,12 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem { x += 8; } - if(player.abilities.isFlying) { + if (player.abilities.isFlying) { int width = ItemNBTHelper.getInt(stack, TAG_DASH_COOLDOWN, 0); RenderSystem.color4f(1F, 1F, 1F, 1F); - if(width > 0) + if (width > 0) { AbstractGui.fill(xo, y - 2, xo + 80, y - 1, 0x88000000); + } AbstractGui.fill(xo, y - 2, xo + width, y - 1, 0xFFFFFFFF); } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGoddessCharm.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGoddessCharm.java index c76ea260d..aee73cacd 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGoddessCharm.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGoddessCharm.java @@ -1,17 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Oct 30, 2016, 6:22:03 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.Vector3f; @@ -28,6 +26,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.event.world.ExplosionEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.api.item.AccessoryRenderHelper; import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; @@ -41,7 +40,7 @@ import java.util.List; public class ItemGoddessCharm extends ItemBauble implements IManaUsingItem { public static final int COST = 1000; - + public ItemGoddessCharm(Properties props) { super(props); } @@ -51,16 +50,16 @@ public class ItemGoddessCharm extends ItemBauble implements IManaUsingItem { Explosion e = event.getExplosion(); Vec3d vec = e.getPosition(); List players = event.getWorld().getEntitiesWithinAABB(PlayerEntity.class, new AxisAlignedBB(vec.x, vec.y, vec.z, vec.x, vec.y, vec.z).grow(8)); - - for(PlayerEntity player : players) { + + for (PlayerEntity player : players) { ItemStack charm = EquipmentHandler.findOrEmpty(ModItems.goddessCharm, player); - if(!charm.isEmpty() && ManaItemHandler.requestManaExact(charm, player, COST, true)) { + if (!charm.isEmpty() && ManaItemHandler.requestManaExact(charm, player, COST, true)) { event.getAffectedBlocks().clear(); return; } } } - + @Override @OnlyIn(Dist.CLIENT) public void doRender(ItemStack stack, LivingEntity player, MatrixStack ms, IRenderTypeBuffer buffers, int light, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) { diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterAuraRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterAuraRing.java index 344c51107..a8e0044a9 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterAuraRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterAuraRing.java @@ -1,18 +1,17 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 24, 2014, 5:12:53 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; + import vazkii.botania.api.mana.IManaGivingItem; import vazkii.botania.api.mana.ManaItemHandler; @@ -24,7 +23,8 @@ public class ItemGreaterAuraRing extends ItemBauble implements IManaGivingItem { @Override public void onWornTick(ItemStack stack, LivingEntity player) { - if (player instanceof PlayerEntity && player.ticksExisted % 2 == 0) + if (player instanceof PlayerEntity && player.ticksExisted % 2 == 0) { ManaItemHandler.dispatchManaExact(stack, (PlayerEntity) player, 1, true); + } } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterManaRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterManaRing.java index a1fcbd087..2cdd0eb40 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterManaRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterManaRing.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 24, 2014, 5:20:54 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemHolyCloak.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemHolyCloak.java index 708338522..088f81b11 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemHolyCloak.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemHolyCloak.java @@ -1,19 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Dec 4, 2014, 11:03:13 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GLX; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.texture.OverlayTexture; @@ -27,6 +24,7 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingHurtEvent; + import vazkii.botania.api.item.AccessoryRenderHelper; import vazkii.botania.client.fx.SparkleParticleData; import vazkii.botania.client.lib.LibResources; @@ -40,8 +38,7 @@ public class ItemHolyCloak extends ItemBauble { private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_HOLY_CLOAK); private static final ResourceLocation textureGlow = new ResourceLocation(LibResources.MODEL_HOLY_CLOAK_GLOW); - @OnlyIn(Dist.CLIENT) - private static ModelCloak model; + @OnlyIn(Dist.CLIENT) private static ModelCloak model; private static final String TAG_COOLDOWN = "cooldown"; private static final String TAG_IN_EFFECT = "inEffect"; @@ -52,18 +49,19 @@ public class ItemHolyCloak extends ItemBauble { } private void onPlayerDamage(LivingHurtEvent event) { - if(event.getEntityLiving() instanceof PlayerEntity && !event.getSource().canHarmInCreative()) { + if (event.getEntityLiving() instanceof PlayerEntity && !event.getSource().canHarmInCreative()) { PlayerEntity player = (PlayerEntity) event.getEntityLiving(); ItemStack stack = EquipmentHandler.findOrEmpty(this, player); - if(!stack.isEmpty() && !isInEffect(stack)) { + if (!stack.isEmpty() && !isInEffect(stack)) { ItemHolyCloak cloak = (ItemHolyCloak) stack.getItem(); int cooldown = getCooldown(stack); // Used to prevent StackOverflows with mobs that deal damage when damaged setInEffect(stack, true); - if(cooldown == 0 && cloak.effectOnDamage(event, player, stack)) + if (cooldown == 0 && cloak.effectOnDamage(event, player, stack)) { setCooldown(stack, cloak.getCooldownTime(stack)); + } setInEffect(stack, false); } } @@ -72,8 +70,9 @@ public class ItemHolyCloak extends ItemBauble { @Override public void onWornTick(ItemStack stack, LivingEntity living) { int cooldown = getCooldown(stack); - if(cooldown > 0) + if (cooldown > 0) { setCooldown(stack, cooldown - 1); + } } @Override @@ -86,8 +85,9 @@ public class ItemHolyCloak extends ItemBauble { float s = 1F / 16F; ms.scale(s, s, s); - if(model == null) + if (model == null) { model = new ModelCloak(); + } Minecraft.getInstance().textureManager.bindTexture(item.getCloakTexture()); IVertexBuilder buffer = buffers.getBuffer(model.getLayer(item.getCloakTexture())); @@ -98,20 +98,20 @@ public class ItemHolyCloak extends ItemBauble { } public boolean effectOnDamage(LivingHurtEvent event, PlayerEntity player, ItemStack stack) { - if(!event.getSource().isMagicDamage()) { + if (!event.getSource().isMagicDamage()) { event.setCanceled(true); player.world.playSound(null, player.getX(), player.getY(), player.getZ(), ModSounds.holyCloak, SoundCategory.PLAYERS, 1F, 1F); - for(int i = 0; i < 30; i++) { + for (int i = 0; i < 30; i++) { double x = player.getX() + Math.random() * player.getWidth() * 2 - player.getWidth(); double y = player.getY() + Math.random() * player.getHeight(); double z = player.getZ() + Math.random() * player.getWidth() * 2 - player.getWidth(); boolean yellow = Math.random() > 0.5; - float r = yellow ? 1F : 0.3F; - float g = yellow ? 1F : 0.3F; - float b = yellow ? 0.3F : 1F; - SparkleParticleData data = SparkleParticleData.sparkle(0.8F + (float) Math.random() * 0.4F, r, g, b, 3); - player.world.addParticle(data, x, y, z, 0, 0, 0); - } + float r = yellow ? 1F : 0.3F; + float g = yellow ? 1F : 0.3F; + float b = yellow ? 0.3F : 1F; + SparkleParticleData data = SparkleParticleData.sparkle(0.8F + (float) Math.random() * 0.4F, r, g, b, 3); + player.world.addParticle(data, x, y, z, 0, 0, 0); + } return true; } @@ -148,4 +148,3 @@ public class ItemHolyCloak extends ItemBauble { return textureGlow; } } - diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemIcePendant.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemIcePendant.java index 47d7648a5..411043e3c 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemIcePendant.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemIcePendant.java @@ -1,30 +1,24 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 26, 2014, 2:06:17 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; - import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Atlases; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.enchantment.FrostWalkerEnchantment; import net.minecraft.entity.LivingEntity; import net.minecraft.inventory.EquipmentSlotType; @@ -35,8 +29,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.client.core.handler.MiscellaneousIcons; -import vazkii.botania.client.core.helper.IconHelper; public class ItemIcePendant extends ItemBauble { @@ -57,18 +51,17 @@ public class ItemIcePendant extends ItemBauble { int z = MathHelper.floor(entity.getZ()); BlockState blockstate = Blocks.SNOW.getDefaultState(); - for(int l = 0; l < 4; ++l) { - x = MathHelper.floor(entity.getX() + (double)((float)(l % 2 * 2 - 1) * 0.25F)); - z = MathHelper.floor(entity.getZ() + (double)((float)(l / 2 % 2 * 2 - 1) * 0.25F)); + for (int l = 0; l < 4; ++l) { + x = MathHelper.floor(entity.getX() + (double) ((float) (l % 2 * 2 - 1) * 0.25F)); + z = MathHelper.floor(entity.getZ() + (double) ((float) (l / 2 % 2 * 2 - 1) * 0.25F)); BlockPos blockpos = new BlockPos(x, y, z); if (entity.world.isAirBlock(blockpos) && entity.world.getBiome(blockpos).getTemperatureCached(blockpos) < 0.9F && blockstate.isValidPosition(entity.world, blockpos)) { entity.world.setBlockState(blockpos, blockstate); } } - } - else if (entity.world.isRemote && !entity.isSneaking()) { - if(entity.world.rand.nextFloat() >= 0.25F) { - entity.world.addParticle(new BlockParticleData(ParticleTypes.FALLING_DUST, Blocks.SNOW_BLOCK.getDefaultState()), entity.getX() + entity.world.rand.nextFloat() * 0.6 - 0.3, entity.getY() + 1.1, entity.getZ() + entity.world.rand.nextFloat() * 0.6 - 0.3, 0, -0.15, 0); + } else if (entity.world.isRemote && !entity.isSneaking()) { + if (entity.world.rand.nextFloat() >= 0.25F) { + entity.world.addParticle(new BlockParticleData(ParticleTypes.FALLING_DUST, Blocks.SNOW_BLOCK.getDefaultState()), entity.getX() + entity.world.rand.nextFloat() * 0.6 - 0.3, entity.getY() + 1.1, entity.getZ() + entity.world.rand.nextFloat() * 0.6 - 0.3, 0, -0.15, 0); } } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemInvisibilityCloak.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemInvisibilityCloak.java index b030e57b6..dc2e19a96 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemInvisibilityCloak.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemInvisibilityCloak.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [22/10/2016, 11:51:06 (GMT)] */ package vazkii.botania.common.item.equipment.bauble; @@ -15,6 +13,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Effects; + import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; @@ -27,20 +26,22 @@ public class ItemInvisibilityCloak extends ItemBauble implements IManaUsingItem @Override public void onUnequipped(ItemStack stack, LivingEntity player) { EffectInstance effect = player.getActivePotionEffect(Effects.INVISIBILITY); - if(effect != null && player instanceof PlayerEntity && effect.getAmplifier() == -42) + if (effect != null && player instanceof PlayerEntity && effect.getAmplifier() == -42) { player.removePotionEffect(Effects.INVISIBILITY); + } } @Override public void onWornTick(ItemStack stack, LivingEntity player) { - if(player instanceof PlayerEntity && !player.world.isRemote) { + if (player instanceof PlayerEntity && !player.world.isRemote) { int manaCost = 2; boolean hasMana = ManaItemHandler.requestManaExact(stack, (PlayerEntity) player, manaCost, false); - if(!hasMana) + if (!hasMana) { onUnequipped(stack, player); - else { - if(player.getActivePotionEffect(Effects.INVISIBILITY) != null) + } else { + if (player.getActivePotionEffect(Effects.INVISIBILITY) != null) { player.removePotionEffect(Effects.INVISIBILITY); + } player.addPotionEffect(new EffectInstance(Effects.INVISIBILITY, Integer.MAX_VALUE, -42, true, true)); } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java index ce66872d1..3c15c5104 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java @@ -1,28 +1,24 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 31, 2014, 12:59:16 AM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; + import it.unimi.dsi.fastutil.ints.IntArrayList; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Atlases; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.item.ItemEntity; @@ -46,9 +42,9 @@ import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.wrapper.InvWrapper; + import vazkii.botania.api.item.AccessoryRenderHelper; import vazkii.botania.client.core.handler.MiscellaneousIcons; -import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.client.fx.WispParticleData; import vazkii.botania.common.Botania; import vazkii.botania.common.core.handler.EquipmentHandler; @@ -67,12 +63,15 @@ public class ItemItemFinder extends ItemBauble { @Override public void onWornTick(ItemStack stack, LivingEntity player) { - if(!(player instanceof PlayerEntity)) + if (!(player instanceof PlayerEntity)) { return; + } - if(player.world.isRemote) + if (player.world.isRemote) { this.tickClient(stack, (PlayerEntity) player); - else this.tickServer(stack, (PlayerEntity) player); + } else { + this.tickServer(stack, (PlayerEntity) player); + } } @Override @@ -92,22 +91,23 @@ public class ItemItemFinder extends ItemBauble { } protected void tickClient(ItemStack stack, PlayerEntity player) { - if(!Botania.proxy.isTheClientPlayer(player)) + if (!Botania.proxy.isTheClientPlayer(player)) { return; + } ListNBT blocks = ItemNBTHelper.getList(stack, TAG_BLOCK_POSITIONS, Constants.NBT.TAG_LONG, false); - for(int i = 0; i < blocks.size(); i++) { + for (int i = 0; i < blocks.size(); i++) { BlockPos pos = BlockPos.fromLong(((LongNBT) blocks.get(i)).getLong()); float m = 0.02F; WispParticleData data = WispParticleData.wisp(0.15F + 0.05F * (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), false); - player.world.addParticle(data, pos.getX() + (float) Math.random(), pos.getY() + (float) Math.random(), pos.getZ() + (float) Math.random() , m * (float) (Math.random() - 0.5), m * (float) (Math.random() - 0.5), m * (float) (Math.random() - 0.5)); + player.world.addParticle(data, pos.getX() + (float) Math.random(), pos.getY() + (float) Math.random(), pos.getZ() + (float) Math.random(), m * (float) (Math.random() - 0.5), m * (float) (Math.random() - 0.5), m * (float) (Math.random() - 0.5)); } int[] entities = ItemNBTHelper.getIntArray(stack, TAG_ENTITY_POSITIONS); - for(int i : entities) { + for (int i : entities) { Entity e = player.world.getEntityByID(i); - if(e != null && Math.random() < 0.6) { + if (e != null && Math.random() < 0.6) { WispParticleData data = WispParticleData.wisp(0.15F + 0.05F * (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), Math.random() < 0.6); player.world.addParticle(data, e.getX() + (float) (Math.random() * 0.5 - 0.25) * 0.45F, e.getY() + e.getHeight(), e.getZ() + (float) (Math.random() * 0.5 - 0.25) * 0.45F, 0, 0.05F + 0.03F * (float) Math.random(), 0); } @@ -128,65 +128,71 @@ public class ItemItemFinder extends ItemBauble { } private void scanForStack(ItemStack pstack, PlayerEntity player, IntArrayList entIdBuilder, ListNBT blockPosBuilder) { - if(!pstack.isEmpty() || player.isSneaking()) { + if (!pstack.isEmpty() || player.isSneaking()) { int range = 24; List entities = player.world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(player.getX() - range, player.getY() - range, player.getZ() - range, player.getX() + range, player.getY() + range, player.getZ() + range)); - for(Entity e : entities) { - if(e == player) + for (Entity e : entities) { + if (e == player) { continue; - if(e.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).isPresent() && !(e instanceof PlayerEntity)) { - if(scanInventory(e.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY), pstack)) + } + if (e.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).isPresent() && !(e instanceof PlayerEntity)) { + if (scanInventory(e.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY), pstack)) { entIdBuilder.add(e.getEntityId()); + } - } else if(e instanceof ItemEntity) { + } else if (e instanceof ItemEntity) { ItemEntity item = (ItemEntity) e; ItemStack istack = item.getItem(); - if(player.isSneaking() || istack.isItemEqual(pstack) && ItemStack.areItemStackTagsEqual(istack, pstack)) + if (player.isSneaking() || istack.isItemEqual(pstack) && ItemStack.areItemStackTagsEqual(istack, pstack)) { entIdBuilder.add(item.getEntityId()); + } - } else if(e instanceof IInventory) { + } else if (e instanceof IInventory) { IInventory inv = (IInventory) e; - if(scanInventory(LazyOptional.of(() -> new InvWrapper(inv)), pstack)) + if (scanInventory(LazyOptional.of(() -> new InvWrapper(inv)), pstack)) { entIdBuilder.add(e.getEntityId()); + } - } else if(e instanceof PlayerEntity) { + } else if (e instanceof PlayerEntity) { PlayerEntity player_ = (PlayerEntity) e; LazyOptional playerInv = player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY); LazyOptional binv = EquipmentHandler.getAllWorn(player); - if(scanInventory(playerInv, pstack) || scanInventory(binv, pstack)) + if (scanInventory(playerInv, pstack) || scanInventory(binv, pstack)) { entIdBuilder.add(player_.getEntityId()); + } - } else if(e instanceof VillagerEntity) { + } else if (e instanceof VillagerEntity) { VillagerEntity villager = (VillagerEntity) e; - for(MerchantOffer offer : villager.getOffers()) { + for (MerchantOffer offer : villager.getOffers()) { if (equalStacks(pstack, offer.getBuyingStackFirst()) - || equalStacks(pstack, offer.getBuyingStackSecond()) - || equalStacks(pstack, offer.getSellingStack())) { + || equalStacks(pstack, offer.getBuyingStackSecond()) + || equalStacks(pstack, offer.getSellingStack())) { entIdBuilder.add(villager.getEntityId()); } } } } - if(!pstack.isEmpty()) { + if (!pstack.isEmpty()) { range = 12; BlockPos pos = new BlockPos(player); - for(BlockPos pos_ : BlockPos.getAllInBoxMutable(pos.add(-range, -range, -range), pos.add(range + 1, range + 1, range + 1))) { + for (BlockPos pos_ : BlockPos.getAllInBoxMutable(pos.add(-range, -range, -range), pos.add(range + 1, range + 1, range + 1))) { TileEntity tile = player.world.getTileEntity(pos_); - if(tile != null) { + if (tile != null) { boolean foundCap = false; - for(Direction e : Direction.values()) { - if(scanInventory(tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, e), pstack)) { + for (Direction e : Direction.values()) { + if (scanInventory(tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, e), pstack)) { blockPosBuilder.add(LongNBT.of(pos_.toLong())); foundCap = true; break; } } - if(!foundCap && tile instanceof IInventory) { + if (!foundCap && tile instanceof IInventory) { IInventory inv = (IInventory) tile; - if(scanInventory(LazyOptional.of(() -> new InvWrapper(inv)), pstack)) + if (scanInventory(LazyOptional.of(() -> new InvWrapper(inv)), pstack)) { blockPosBuilder.add(LongNBT.of(pos_.toLong())); + } } } } @@ -203,13 +209,15 @@ public class ItemItemFinder extends ItemBauble { } private boolean scanInventory(IItemHandler inv, ItemStack pstack) { - if(pstack.isEmpty()) + if (pstack.isEmpty()) { return false; + } - for(int l = 0; l < inv.getSlots(); l++) { + for (int l = 0; l < inv.getSlots(); l++) { ItemStack istack = inv.getStackInSlot(l); - if(!istack.isEmpty() && equalStacks(istack, pstack)) + if (!istack.isEmpty() && equalStacks(istack, pstack)) { return true; + } } return false; } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemKnockbackBelt.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemKnockbackBelt.java index d3688f54f..fb4e400a9 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemKnockbackBelt.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemKnockbackBelt.java @@ -1,21 +1,18 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 26, 2014, 7:08:53 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; -import net.minecraft.client.Minecraft; + import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.entity.model.BipedModel; import net.minecraft.client.renderer.texture.OverlayTexture; @@ -26,6 +23,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.client.lib.LibResources; public class ItemKnockbackBelt extends ItemBauble { @@ -52,8 +50,9 @@ public class ItemKnockbackBelt extends ItemBauble { float s = 1.05F / 16F; ms.scale(s, s, s); - if(model == null) + if (model == null) { model = new BipedModel(1.0F); + } IVertexBuilder buffer = buffers.getBuffer(model.getLayer(texture)); model.bipedBody.render(ms, buffer, light, OverlayTexture.DEFAULT_UV); diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemLavaPendant.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemLavaPendant.java index d144b1d14..4e162dc26 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemLavaPendant.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemLavaPendant.java @@ -1,35 +1,30 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 26, 2014, 11:23:27 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Atlases; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.entity.LivingEntity; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ItemStack; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.item.AccessoryRenderHelper; import vazkii.botania.client.core.handler.MiscellaneousIcons; -import vazkii.botania.client.core.helper.IconHelper; public class ItemLavaPendant extends ItemBauble { @@ -39,8 +34,9 @@ public class ItemLavaPendant extends ItemBauble { @Override public void onWornTick(ItemStack stack, LivingEntity player) { - if(player.isBurning()) + if (player.isBurning()) { player.extinguish(); + } } @Override diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMagnetRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMagnetRing.java index 9f1f5e216..268f88d44 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMagnetRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMagnetRing.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 17, 2014, 3:16:36 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; @@ -18,6 +16,7 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.item.ItemTossEvent; + import vazkii.botania.api.item.IRelic; import vazkii.botania.api.mana.IManaItem; import vazkii.botania.client.fx.SparkleParticleData; @@ -50,7 +49,7 @@ public class ItemMagnetRing extends ItemBauble { private void onTossItem(ItemTossEvent event) { ItemStack ring = EquipmentHandler.findOrEmpty(s -> s.getItem() instanceof ItemMagnetRing, event.getPlayer()); - if(!ring.isEmpty()) { + if (!ring.isEmpty()) { setCooldown(ring, 100); } } @@ -59,19 +58,21 @@ public class ItemMagnetRing extends ItemBauble { public void onWornTick(ItemStack stack, LivingEntity living) { super.onWornTick(stack, living); - if(living.isSpectator()) - return; - - int cooldown = getCooldown(stack); - - if(SubTileSolegnolia.hasSolegnoliaAround(living)) { - if(cooldown < 0) - setCooldown(stack, 2); + if (living.isSpectator()) { return; } - if(cooldown <= 0) { - if(living.isSneaking() == ConfigHandler.COMMON.invertMagnetRing.get()) { + int cooldown = getCooldown(stack); + + if (SubTileSolegnolia.hasSolegnoliaAround(living)) { + if (cooldown < 0) { + setCooldown(stack, 2); + } + return; + } + + if (cooldown <= 0) { + if (living.isSneaking() == ConfigHandler.COMMON.invertMagnetRing.get()) { double x = living.getX(); double y = living.getY() + 0.75; double z = living.getZ(); @@ -79,40 +80,48 @@ public class ItemMagnetRing extends ItemBauble { int range = ((ItemMagnetRing) stack.getItem()).range; List items = living.world.getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range)); int pulled = 0; - for(ItemEntity item : items) - if(((ItemMagnetRing) stack.getItem()).canPullItem(item)) { - if(pulled > 200) + for (ItemEntity item : items) { + if (((ItemMagnetRing) stack.getItem()).canPullItem(item)) { + if (pulled > 200) { break; + } MathHelper.setEntityMotionFromVector(item, new Vector3(x, y, z), 0.45F); - if(living.world.isRemote) { + if (living.world.isRemote) { boolean red = living.world.rand.nextBoolean(); - float r = red ? 1F : 0F; - float b = red ? 0F : 1F; - SparkleParticleData data = SparkleParticleData.sparkle(1F, r, 0F, b, 3); - living.world.addParticle(data, item.getX(), item.getY(), item.getZ(), 0, 0, 0); - } + float r = red ? 1F : 0F; + float b = red ? 0F : 1F; + SparkleParticleData data = SparkleParticleData.sparkle(1F, r, 0F, b, 3); + living.world.addParticle(data, item.getX(), item.getY(), item.getZ(), 0, 0, 0); + } pulled++; } + } } - } else setCooldown(stack, cooldown - 1); + } else { + setCooldown(stack, cooldown - 1); + } } private boolean canPullItem(ItemEntity item) { - if(!item.isAlive() || item.pickupDelay >= 40 || SubTileSolegnolia.hasSolegnoliaAround(item) || item.getPersistentData().getBoolean("PreventRemoteMovement")) + if (!item.isAlive() || item.pickupDelay >= 40 || SubTileSolegnolia.hasSolegnoliaAround(item) || item.getPersistentData().getBoolean("PreventRemoteMovement")) { return false; + } ItemStack stack = item.getItem(); - if(stack.isEmpty() || stack.getItem() instanceof IManaItem || stack.getItem() instanceof IRelic || ModTags.Items.MAGNET_RING_BLACKLIST.contains(stack.getItem())) + if (stack.isEmpty() || stack.getItem() instanceof IManaItem || stack.getItem() instanceof IRelic || ModTags.Items.MAGNET_RING_BLACKLIST.contains(stack.getItem())) { return false; + } BlockPos pos = new BlockPos(item); - if(ModTags.Blocks.MAGNET_RING_BLACKLIST.contains(item.world.getBlockState(pos).getBlock())) + if (ModTags.Blocks.MAGNET_RING_BLACKLIST.contains(item.world.getBlockState(pos).getBlock())) { return false; + } - if(ModTags.Blocks.MAGNET_RING_BLACKLIST.contains(item.world.getBlockState(pos.down()).getBlock())) + if (ModTags.Blocks.MAGNET_RING_BLACKLIST.contains(item.world.getBlockState(pos.down()).getBlock())) { return false; + } return true; } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemManaRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemManaRing.java index 0082d4884..52c40406b 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemManaRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemManaRing.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 24, 2014, 2:55:28 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; @@ -16,6 +14,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.NonNullList; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; + import vazkii.botania.api.mana.IManaItem; import vazkii.botania.api.mana.IManaTooltipDisplay; import vazkii.botania.common.core.helper.ItemNBTHelper; @@ -34,7 +33,7 @@ public class ItemManaRing extends ItemBauble implements IManaItem, IManaTooltipD @Override public void fillItemGroup(@Nonnull ItemGroup tab, @Nonnull NonNullList stacks) { - if(isInGroup(tab)) { + if (isInGroup(tab)) { stacks.add(new ItemStack(this)); ItemStack full = new ItemStack(this); diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMiningRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMiningRing.java index b213f5bdc..609a82e7e 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMiningRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMiningRing.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 17, 2014, 4:12:46 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; @@ -15,6 +13,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Effects; + import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; @@ -26,28 +25,31 @@ public class ItemMiningRing extends ItemBauble implements IManaUsingItem { @Override public void onWornTick(ItemStack stack, LivingEntity player) { - if(player instanceof PlayerEntity && !player.world.isRemote) { + if (player instanceof PlayerEntity && !player.world.isRemote) { int manaCost = 5; boolean hasMana = ManaItemHandler.requestManaExact(stack, (PlayerEntity) player, manaCost, false); - if(!hasMana) + if (!hasMana) { onUnequipped(stack, player); - else { - if(player.getActivePotionEffect(Effects.HASTE) != null) + } else { + if (player.getActivePotionEffect(Effects.HASTE) != null) { player.removePotionEffect(Effects.HASTE); + } player.addPotionEffect(new EffectInstance(Effects.HASTE, Integer.MAX_VALUE, 1, true, true)); } - if(player.swingProgress == 0.25F) + if (player.swingProgress == 0.25F) { ManaItemHandler.requestManaExact(stack, (PlayerEntity) player, manaCost, true); + } } } @Override public void onUnequipped(ItemStack stack, LivingEntity player) { EffectInstance effect = player.getActivePotionEffect(Effects.HASTE); - if(effect != null && effect.getAmplifier() == 1) + if (effect != null && effect.getAmplifier() == 1) { player.removePotionEffect(Effects.HASTE); + } } @Override diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMonocle.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMonocle.java index 2ac8dd2b1..49fee24da 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMonocle.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMonocle.java @@ -1,17 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 24, 2015, 3:03:18 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -22,7 +20,6 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.model.ItemCameraTransforms; -import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; @@ -37,6 +34,7 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.item.AccessoryRenderHelper; import vazkii.botania.api.item.IBurstViewerBauble; import vazkii.botania.api.item.ICosmeticAttachable; @@ -67,8 +65,9 @@ public class ItemMonocle extends ItemBauble implements IBurstViewerBauble, ICosm public static void renderHUD(PlayerEntity player) { Minecraft mc = Minecraft.getInstance(); RayTraceResult ray = mc.objectMouseOver; - if(ray == null || ray.getType() != RayTraceResult.Type.BLOCK) + if (ray == null || ray.getType() != RayTraceResult.Type.BLOCK) { return; + } BlockPos pos = ((BlockRayTraceResult) ray).getPos(); BlockState state = player.world.getBlockState(pos); Block block = state.getBlock(); @@ -77,19 +76,20 @@ public class ItemMonocle extends ItemBauble implements IBurstViewerBauble, ICosm ItemStack dispStack = ItemStack.EMPTY; String text = ""; - if(block == Blocks.REDSTONE_WIRE) { + if (block == Blocks.REDSTONE_WIRE) { dispStack = new ItemStack(Items.REDSTONE); text = TextFormatting.RED + "" + state.get(RedstoneWireBlock.POWER); - } else if(block == Blocks.REPEATER) { + } else if (block == Blocks.REPEATER) { dispStack = new ItemStack(Blocks.REPEATER); text = "" + state.get(RepeaterBlock.DELAY); - } else if(block == Blocks.COMPARATOR) { + } else if (block == Blocks.COMPARATOR) { dispStack = new ItemStack(Blocks.COMPARATOR); text = state.get(ComparatorBlock.MODE) == ComparatorMode.SUBTRACT ? "-" : "+"; } - if(dispStack.isEmpty()) + if (dispStack.isEmpty()) { return; + } int x = mc.getWindow().getScaledWidth() / 2 + 15; int y = mc.getWindow().getScaledHeight() / 2 - 8; @@ -103,16 +103,18 @@ public class ItemMonocle extends ItemBauble implements IBurstViewerBauble, ICosm return EquipmentHandler.getAllWorn(player).map(inv -> { for (int i = 0; i < inv.getSlots(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(!stack.isEmpty()) { + if (!stack.isEmpty()) { Item item = stack.getItem(); - if(item instanceof IBurstViewerBauble) + if (item instanceof IBurstViewerBauble) { return true; + } - if(item instanceof ICosmeticAttachable) { + if (item instanceof ICosmeticAttachable) { ICosmeticAttachable attach = (ICosmeticAttachable) item; ItemStack cosmetic = attach.getCosmeticItem(stack); - if(!cosmetic.isEmpty() && cosmetic.getItem() instanceof IBurstViewerBauble) + if (!cosmetic.isEmpty() && cosmetic.getItem() instanceof IBurstViewerBauble) { return true; + } } } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemPixieRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemPixieRing.java index 24d4d2a9b..cfb434e81 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemPixieRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemPixieRing.java @@ -1,18 +1,18 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 20, 2014, 6:13:45 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; import com.google.common.collect.Multimap; + import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.item.ItemStack; + import vazkii.botania.common.core.handler.PixieHandler; public class ItemPixieRing extends ItemBauble { diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemReachRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemReachRing.java index 4c1f164cc..fcebefd41 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemReachRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemReachRing.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 22, 2014, 3:00:09 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; + import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; @@ -21,7 +20,7 @@ public class ItemReachRing extends ItemBauble { public ItemReachRing(Properties props) { super(props); } - + @Override public Multimap getEquippedAttributeModifiers(ItemStack stack) { Multimap attributes = HashMultimap.create(); diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSpeedUpBelt.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSpeedUpBelt.java index 32da907d2..3aba50f53 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSpeedUpBelt.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSpeedUpBelt.java @@ -1,18 +1,17 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [24/11/2015, 22:50:29 (GMT)] */ package vazkii.botania.common.item.equipment.bauble; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; + import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.core.helper.ItemNBTHelper; @@ -49,8 +48,9 @@ public class ItemSpeedUpBelt extends ItemTravelBelt { @Override public void onNotMovingTick(ItemStack stack, PlayerEntity player) { - if(!commitPositionAndCompare(stack, player)) + if (!commitPositionAndCompare(stack, player)) { ItemNBTHelper.setFloat(stack, TAG_SPEED, 0F); + } } public boolean commitPositionAndCompare(ItemStack stack, PlayerEntity player) { @@ -66,4 +66,3 @@ public class ItemSpeedUpBelt extends ItemTravelBelt { } } - diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperCloudPendant.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperCloudPendant.java index 92f82f974..3b7c138f9 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperCloudPendant.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperCloudPendant.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [22/10/2016, 17:28:51 (GMT)] */ package vazkii.botania.common.item.equipment.bauble; @@ -15,7 +13,7 @@ public class ItemSuperCloudPendant extends ItemCloudPendant { public ItemSuperCloudPendant(Properties props) { super(props); } - + @Override public int getMaxAllowedJumps() { return 3; diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperLavaPendant.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperLavaPendant.java index 0503700d3..ce734a8c7 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperLavaPendant.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperLavaPendant.java @@ -1,27 +1,22 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 31, 2014, 6:09:17 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Atlases; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.entity.LivingEntity; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ItemStack; @@ -29,9 +24,9 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingHurtEvent; + import vazkii.botania.api.item.AccessoryRenderHelper; import vazkii.botania.client.core.handler.MiscellaneousIcons; -import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.core.handler.EquipmentHandler; public class ItemSuperLavaPendant extends ItemBauble { @@ -42,7 +37,7 @@ public class ItemSuperLavaPendant extends ItemBauble { } private void onDamage(LivingHurtEvent evt) { - if(evt.getSource().isFireDamage() + if (evt.getSource().isFireDamage() && !EquipmentHandler.findOrEmpty(this, evt.getEntityLiving()).isEmpty()) { evt.setCanceled(true); } @@ -50,8 +45,9 @@ public class ItemSuperLavaPendant extends ItemBauble { @Override public void onWornTick(ItemStack stack, LivingEntity living) { - if (living.isBurning()) + if (living.isBurning()) { living.extinguish(); + } } @Override diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperTravelBelt.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperTravelBelt.java index a68145101..9a8519732 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperTravelBelt.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperTravelBelt.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 20, 2014, 6:26:40 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; import net.minecraft.util.ResourceLocation; + import vazkii.botania.client.lib.LibResources; public class ItemSuperTravelBelt extends ItemTravelBelt { diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSwapRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSwapRing.java index 6b7a05df6..1e1aa4950 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSwapRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSwapRing.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 23, 2015, 7:21:52 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; @@ -17,9 +15,9 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceContext; import net.minecraft.util.math.RayTraceResult; import net.minecraftforge.common.ToolType; + import vazkii.botania.api.item.ISortableTool; import vazkii.botania.common.item.equipment.tool.ToolCommons; @@ -31,45 +29,49 @@ public class ItemSwapRing extends ItemBauble { @Override public void onWornTick(ItemStack stack, LivingEntity entity) { - if(entity.world.isRemote && !(entity instanceof PlayerEntity)) + if (entity.world.isRemote && !(entity instanceof PlayerEntity)) { return; + } PlayerEntity player = (PlayerEntity) entity; ItemStack currentStack = player.getHeldItemMainhand(); - if(currentStack.isEmpty() || !(currentStack.getItem() instanceof ISortableTool)) + if (currentStack.isEmpty() || !(currentStack.getItem() instanceof ISortableTool)) { return; + } ISortableTool tool = (ISortableTool) currentStack.getItem(); BlockRayTraceResult pos = ToolCommons.raytraceFromEntity(player, 4.5F, false); ToolType typeToFind = null; - if(player.isSwingInProgress && pos.getType() == RayTraceResult.Type.BLOCK) { + if (player.isSwingInProgress && pos.getType() == RayTraceResult.Type.BLOCK) { BlockState state = entity.world.getBlockState(pos.getPos()); Material mat = state.getMaterial(); - if(ToolCommons.materialsPick.contains(mat)) + if (ToolCommons.materialsPick.contains(mat)) { typeToFind = ToolType.PICKAXE; - else if(ToolCommons.materialsShovel.contains(mat)) + } else if (ToolCommons.materialsShovel.contains(mat)) { typeToFind = ToolType.SHOVEL; - else if(ToolCommons.materialsAxe.contains(mat)) + } else if (ToolCommons.materialsAxe.contains(mat)) { typeToFind = ToolType.AXE; + } } - if(typeToFind == null) + if (typeToFind == null) { return; + } ItemStack bestTool = currentStack; int bestToolPriority = currentStack.getToolTypes().contains(typeToFind) ? tool.getSortingPriority(currentStack) : -1; int bestSlot = -1; - for(int i = 0; i < player.inventory.getSizeInventory(); i++) { + for (int i = 0; i < player.inventory.getSizeInventory(); i++) { ItemStack stackInSlot = player.inventory.getStackInSlot(i); - if(!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof ISortableTool && stackInSlot != currentStack) { + if (!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof ISortableTool && stackInSlot != currentStack) { ISortableTool toolInSlot = (ISortableTool) stackInSlot.getItem(); - if(stackInSlot.getToolTypes().contains(typeToFind)) { + if (stackInSlot.getToolTypes().contains(typeToFind)) { int priority = toolInSlot.getSortingPriority(stackInSlot); - if(priority > bestToolPriority) { + if (priority > bestToolPriority) { bestTool = stackInSlot; bestToolPriority = priority; bestSlot = i; @@ -78,7 +80,7 @@ public class ItemSwapRing extends ItemBauble { } } - if(bestSlot != -1) { + if (bestSlot != -1) { player.setHeldItem(Hand.MAIN_HAND, bestTool); player.inventory.setInventorySlotContents(bestSlot, currentStack); } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemThirdEye.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemThirdEye.java index abdbf0bbc..c9108a03b 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemThirdEye.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemThirdEye.java @@ -1,27 +1,22 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [22/10/2016, 20:18:44 (GMT)] */ package vazkii.botania.common.item.equipment.bauble; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Atlases; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.monster.IMob; @@ -33,11 +28,11 @@ import net.minecraft.potion.Effects; import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.handler.MiscellaneousIcons; -import vazkii.botania.client.core.helper.IconHelper; import java.util.List; @@ -51,18 +46,20 @@ public class ItemThirdEye extends ItemBauble implements IManaUsingItem { @Override public void onWornTick(ItemStack stack, LivingEntity living) { - if(!(living instanceof PlayerEntity)) + if (!(living instanceof PlayerEntity)) { return; + } PlayerEntity eplayer = (PlayerEntity) living; double range = 24; AxisAlignedBB aabb = new AxisAlignedBB(living.getX(), living.getY(), living.getZ(), living.getX(), living.getY(), living.getZ()).grow(range); List mobs = living.world.getEntitiesWithinAABB(LivingEntity.class, aabb, (Entity e) -> e instanceof IMob); - for(LivingEntity e : mobs) { + for (LivingEntity e : mobs) { EffectInstance potion = e.getActivePotionEffect(Effects.GLOWING); - if((potion == null || potion.getDuration() <= 2) && ManaItemHandler.requestManaExact(stack, eplayer, COST, true)) + if ((potion == null || potion.getDuration() <= 2) && ManaItemHandler.requestManaExact(stack, eplayer, COST, true)) { e.addPotionEffect(new EffectInstance(Effects.GLOWING, 12, 0)); + } } } @@ -74,10 +71,11 @@ public class ItemThirdEye extends ItemBauble implements IManaUsingItem { ms.translate(-0.3, -0.6, armor ? -0.18 : -0.12); ms.scale(0.6F, 0.6F, 0.6F); - for(int i = 0; i < 3; i++) { - ms.push(); + for (int i = 0; i < 3; i++) { + ms.push(); switch (i) { - case 0: break; + case 0: + break; case 1: float scale1 = 0.75F; diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTinyPlanet.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTinyPlanet.java index e752f7c07..c03d8c486 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTinyPlanet.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTinyPlanet.java @@ -1,21 +1,18 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 20, 2014, 10:58:00 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; import com.google.common.base.Predicates; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; @@ -26,6 +23,7 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.api.mana.ITinyPlanetExcempt; import vazkii.botania.common.block.ModBlocks; @@ -40,7 +38,7 @@ public class ItemTinyPlanet extends ItemBauble { public ItemTinyPlanet(Properties props) { super(props); } - + @Override public void onWornTick(ItemStack stack, LivingEntity player) { double x = player.getX(); @@ -61,15 +59,17 @@ public class ItemTinyPlanet extends ItemBauble { public static void applyEffect(World world, double x, double y, double z) { int range = 8; List entities = world.getEntitiesWithinAABB(ThrowableEntity.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range), Predicates.instanceOf(IManaBurst.class)); - for(ThrowableEntity entity : entities) { + for (ThrowableEntity entity : entities) { IManaBurst burst = (IManaBurst) entity; ItemStack lens = burst.getSourceLens(); - if(lens != null && lens.getItem() instanceof ITinyPlanetExcempt && !((ITinyPlanetExcempt) lens.getItem()).shouldPull(lens)) + if (lens != null && lens.getItem() instanceof ITinyPlanetExcempt && !((ITinyPlanetExcempt) lens.getItem()).shouldPull(lens)) { continue; + } int orbitTime = getEntityOrbitTime(entity); - if(orbitTime == 0) + if (orbitTime == 0) { burst.setMinManaLoss(burst.getMinManaLoss() * 3); + } float radius = Math.min(7.5F, (Math.max(40, orbitTime) - 40) / 40F + 1.5F); int angle = orbitTime % 360; @@ -90,9 +90,11 @@ public class ItemTinyPlanet extends ItemBauble { public static int getEntityOrbitTime(Entity entity) { CompoundNBT cmp = entity.getPersistentData(); - if(cmp.contains(TAG_ORBIT)) + if (cmp.contains(TAG_ORBIT)) { return cmp.getInt(TAG_ORBIT); - else return 0; + } else { + return 0; + } } public static void incrementOrbitTime(Entity entity) { diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTravelBelt.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTravelBelt.java index 81a0bef0e..c83d3a100 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTravelBelt.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTravelBelt.java @@ -1,19 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 24, 2014, 11:14:57 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.vertex.IVertexBuilder; -import net.minecraft.client.Minecraft; + import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.entity.model.BipedModel; import net.minecraft.client.renderer.texture.OverlayTexture; @@ -28,6 +25,7 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import net.minecraftforge.event.entity.player.PlayerEvent; + import vazkii.botania.api.item.AccessoryRenderHelper; import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; @@ -40,8 +38,7 @@ import java.util.List; public class ItemTravelBelt extends ItemBauble implements IManaUsingItem { private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_TRAVEL_BELT); - @OnlyIn(Dist.CLIENT) - private static BipedModel model; + @OnlyIn(Dist.CLIENT) private static BipedModel model; private static final int COST = 1; private static final int COST_INTERVAL = 10; @@ -67,35 +64,40 @@ public class ItemTravelBelt extends ItemBauble implements IManaUsingItem { } private void updatePlayerStepStatus(LivingUpdateEvent event) { - if(event.getEntityLiving() instanceof PlayerEntity) { + if (event.getEntityLiving() instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity) event.getEntityLiving(); ItemStack belt = EquipmentHandler.findOrEmpty(s -> s.getItem() instanceof ItemTravelBelt, player); String s = playerStr(player); - if(playersWithStepup.contains(s)) { - if(shouldPlayerHaveStepup(player)) { + if (playersWithStepup.contains(s)) { + if (shouldPlayerHaveStepup(player)) { ItemTravelBelt beltItem = (ItemTravelBelt) belt.getItem(); - if(player.world.isRemote) { - if((player.onGround || player.abilities.isFlying) && player.moveForward > 0F && !player.isInWaterOrBubbleColumn()) { + if (player.world.isRemote) { + if ((player.onGround || player.abilities.isFlying) && player.moveForward > 0F && !player.isInWaterOrBubbleColumn()) { float speed = beltItem.getSpeed(belt); player.moveRelative(player.abilities.isFlying ? speed : speed, new Vec3d(0, 0, 1)); beltItem.onMovedTick(belt, player); - if(player.ticksExisted % COST_INTERVAL == 0) + if (player.ticksExisted % COST_INTERVAL == 0) { ManaItemHandler.requestManaExact(belt, player, COST, true); - } else beltItem.onNotMovingTick(belt, player); + } + } else { + beltItem.onNotMovingTick(belt, player); + } } - if(player.isSneaking()) + if (player.isSneaking()) { player.stepHeight = 0.60001F; // Not 0.6F because that is the default - else player.stepHeight = 1.25F; + } else { + player.stepHeight = 1.25F; + } } else { player.stepHeight = 0.6F; playersWithStepup.remove(s); } - } else if(shouldPlayerHaveStepup(player)) { + } else if (shouldPlayerHaveStepup(player)) { playersWithStepup.add(s); player.stepHeight = 1.25F; } @@ -111,11 +113,11 @@ public class ItemTravelBelt extends ItemBauble implements IManaUsingItem { public void onNotMovingTick(ItemStack stack, PlayerEntity player) {} private void onPlayerJump(LivingJumpEvent event) { - if(event.getEntityLiving() instanceof PlayerEntity) { + if (event.getEntityLiving() instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity) event.getEntityLiving(); ItemStack belt = EquipmentHandler.findOrEmpty(s -> s.getItem() instanceof ItemTravelBelt, player); - if(!belt.isEmpty() && ManaItemHandler.requestManaExact(belt, player, COST, false)) { + if (!belt.isEmpty() && ManaItemHandler.requestManaExact(belt, player, COST, false)) { player.setMotion(player.getMotion().add(0, ((ItemTravelBelt) belt.getItem()).jump, 0)); player.fallDistance = -((ItemTravelBelt) belt.getItem()).fallBuffer; } @@ -142,7 +144,6 @@ public class ItemTravelBelt extends ItemBauble implements IManaUsingItem { return texture; } - @Override @OnlyIn(Dist.CLIENT) public void doRender(ItemStack stack, LivingEntity player, MatrixStack ms, IRenderTypeBuffer buffers, int light, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) { @@ -152,8 +153,9 @@ public class ItemTravelBelt extends ItemBauble implements IManaUsingItem { float s = 1.05F / 16F; ms.scale(s, s, s); - if(model == null) + if (model == null) { model = new BipedModel(1F); + } ResourceLocation texture = ((ItemTravelBelt) stack.getItem()).getRenderTexture(); IVertexBuilder buffer = buffers.getBuffer(model.getLayer(texture)); diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemUnholyCloak.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemUnholyCloak.java index 5b32932dd..82505ca12 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemUnholyCloak.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemUnholyCloak.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Dec 4, 2014, 11:12:51 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; import com.google.common.base.Predicates; + import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.monster.IMob; @@ -23,6 +22,7 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.event.entity.living.LivingHurtEvent; + import vazkii.botania.client.fx.WispParticleData; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.core.handler.ModSounds; @@ -40,23 +40,24 @@ public class ItemUnholyCloak extends ItemHolyCloak { @Override public boolean effectOnDamage(LivingHurtEvent event, PlayerEntity player, ItemStack stack) { - if(!event.getSource().isUnblockable()) { + if (!event.getSource().isUnblockable()) { int range = 6; List mobs = player.world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(player.getX() - range, player.getY() - range, player.getZ() - range, player.getX() + range, player.getY() + range, player.getZ() + range), Predicates.instanceOf(IMob.class)); - for(IMob mob : (List) mobs) - if(mob instanceof LivingEntity) { + for (IMob mob : (List) mobs) { + if (mob instanceof LivingEntity) { LivingEntity entity = (LivingEntity) mob; entity.attackEntityFrom(DamageSource.causePlayerDamage(player), event.getAmount()); } + } player.world.playSound(null, player.getX(), player.getY(), player.getZ(), ModSounds.unholyCloak, SoundCategory.PLAYERS, 1F, 1F); - for(int i = 0; i < 90; i++) { + for (int i = 0; i < 90; i++) { float rad = i * 4F * (float) Math.PI / 180F; float xMotion = (float) Math.cos(rad) * 0.2F; float zMotion = (float) Math.sin(rad) * 0.2F; - WispParticleData data = WispParticleData.wisp(0.6F + (float) Math.random() * 0.2F, 0.4F + (float) Math.random() + 0.25F, 0F, 0F); - player.world.addParticle(data, player.getX(), player.getY() + 0.5, player.getZ(), xMotion, 0F, zMotion); - } + WispParticleData data = WispParticleData.wisp(0.6F + (float) Math.random() * 0.2F, 0.4F + (float) Math.random() + 0.25F, 0F, 0F); + player.world.addParticle(data, player.getX(), player.getY() + 0.5, player.getZ(), xMotion, 0F, zMotion); + } return true; } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemWaterRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemWaterRing.java index 34a26fcb6..226278812 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemWaterRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemWaterRing.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 17, 2014, 3:44:24 PM (GMT)] */ package vazkii.botania.common.item.equipment.bauble; @@ -16,6 +14,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.potion.Effect; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Effects; + import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.common.core.handler.EquipmentHandler; @@ -31,11 +30,12 @@ public class ItemWaterRing extends ItemBauble implements IManaUsingItem { @Override public void onWornTick(ItemStack stack, LivingEntity living) { - if(living.isInWaterOrBubbleColumn()) { + if (living.isInWaterOrBubbleColumn()) { // only activate for one ring at a time ItemStack result = EquipmentHandler.findOrEmpty(ModItems.waterRing, living); - if(result != stack) + if (result != stack) { return; + } if (!living.world.isRemote) { if (living instanceof PlayerEntity && !ManaItemHandler.requestManaExact(stack, (PlayerEntity) living, COST, true)) { @@ -45,7 +45,9 @@ public class ItemWaterRing extends ItemBauble implements IManaUsingItem { addEffect(living, Effects.DOLPHINS_GRACE); } } - } else onUnequipped(stack, living); + } else { + onUnequipped(stack, living); + } } private static void addEffect(LivingEntity living, Effect effect) { diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/ItemEnderDagger.java b/src/main/java/vazkii/botania/common/item/equipment/tool/ItemEnderDagger.java index 8799efbfb..1a2ee1fe5 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/ItemEnderDagger.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/ItemEnderDagger.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 10, 2014, 11:48:12 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool; import com.google.common.collect.Multimap; + import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.SharedMonsterAttributes; @@ -22,10 +21,12 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.util.Hand; import net.minecraft.world.World; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelSword; import javax.annotation.Nonnull; + import java.util.function.Consumer; public class ItemEnderDagger extends ItemManasteelSword { @@ -36,7 +37,7 @@ public class ItemEnderDagger extends ItemManasteelSword { @Override public boolean hitEntity(ItemStack stack, LivingEntity target, @Nonnull LivingEntity attacker) { - if(!target.world.isRemote + if (!target.world.isRemote && target instanceof EndermanEntity && attacker instanceof PlayerEntity) { target.attackEntityFrom(DamageSource.causePlayerDamage((PlayerEntity) attacker), 20); diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/ItemGlassPick.java b/src/main/java/vazkii/botania/common/item/equipment/tool/ItemGlassPick.java index d0dee41dc..f6f35a6ef 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/ItemGlassPick.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/ItemGlassPick.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 6, 2014, 9:55:23 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool; @@ -24,6 +22,7 @@ import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.Tags; + import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelPick; import java.util.Map; @@ -68,18 +67,19 @@ public class ItemGlassPick extends ItemManasteelPick { } /* - * No way to modify the loot context so we're gonna go braindead hack workaround here: - * - When block starting to break, if the tool doesn't have silktouch already, add it and add a "temp silk touch" flag - * - Every tick, if the "temp silk touch" flag is present, remove it and remove any silk touch enchants from the stack - */ + * No way to modify the loot context so we're gonna go braindead hack workaround here: + * - When block starting to break, if the tool doesn't have silktouch already, add it and add a "temp silk touch" flag + * - Every tick, if the "temp silk touch" flag is present, remove it and remove any silk touch enchants from the stack + */ @Override public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, PlayerEntity player) { BlockState state = player.world.getBlockState(pos); boolean isGlass = state.getMaterial() == Material.GLASS || Tags.Blocks.GLASS.contains(state.getBlock()); boolean hasSilk = EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) > 0; - if (hasSilk || !isGlass) + if (hasSilk || !isGlass) { return super.onBlockStartBreak(itemstack, pos, player); + } itemstack.addEnchantment(Enchantments.SILK_TOUCH, 1); itemstack.getTag().putBoolean(TAG_SILK_HACK, true); diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/ItemStarSword.java b/src/main/java/vazkii/botania/common/item/equipment/tool/ItemStarSword.java index fcc3935dc..198325e6b 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/ItemStarSword.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/ItemStarSword.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 17, 2015, 3:55:52 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool; @@ -17,9 +15,9 @@ import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Effects; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceContext; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.common.core.handler.ModSounds; import vazkii.botania.common.core.helper.Vector3; @@ -37,14 +35,14 @@ public class ItemStarSword extends ItemManasteelSword { @Override public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) { super.inventoryTick(stack, world, entity, slot, selected); - if(entity instanceof PlayerEntity) { + if (entity instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity) entity; EffectInstance haste = player.getActivePotionEffect(Effects.HASTE); float check = haste == null ? 0.16666667F : haste.getAmplifier() == 1 ? 0.5F : 0.4F; - if(player.getHeldItemMainhand() == stack && player.swingProgress == check && !world.isRemote) { + if (player.getHeldItemMainhand() == stack && player.swingProgress == check && !world.isRemote) { BlockRayTraceResult pos = ToolCommons.raytraceFromEntity(player, 48, false); - if(pos.getType() == RayTraceResult.Type.BLOCK) { + if (pos.getType() == RayTraceResult.Type.BLOCK) { Vector3 posVec = Vector3.fromBlockPos(pos.getPos()); Vector3 motVec = new Vector3((0.5 * Math.random() - 0.25) * 18, 24, (0.5 * Math.random() - 0.25) * 18); posVec = posVec.add(motVec); diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/ItemThunderSword.java b/src/main/java/vazkii/botania/common/item/equipment/tool/ItemThunderSword.java index 512a410e3..bbf752f95 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/ItemThunderSword.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/ItemThunderSword.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 27, 2015, 10:38:50 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool; import com.google.common.collect.Multimap; + import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.SharedMonsterAttributes; @@ -21,6 +20,7 @@ import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.util.math.AxisAlignedBB; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.common.Botania; import vazkii.botania.common.core.helper.ItemNBTHelper; @@ -28,6 +28,7 @@ import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelSword; import javax.annotation.Nonnull; + import java.util.ArrayList; import java.util.List; import java.util.Random; @@ -43,7 +44,7 @@ public class ItemThunderSword extends ItemManasteelSword { @Override public boolean hitEntity(ItemStack stack, LivingEntity entity, @Nonnull LivingEntity attacker) { - if(!(entity instanceof PlayerEntity) && entity != null) { + if (!(entity instanceof PlayerEntity) && entity != null) { double range = 8; List alreadyTargetedEntities = new ArrayList<>(); int dmg = 5; @@ -54,15 +55,18 @@ public class ItemThunderSword extends ItemManasteelSword { Random rand = new Random(lightningSeed); LivingEntity lightningSource = entity; int hops = entity.world.isThundering() ? 10 : 4; - for(int i = 0; i < hops; i++) { + for (int i = 0; i < hops; i++) { List entities = entity.world.getEntitiesInAABBexcluding(lightningSource, new AxisAlignedBB(lightningSource.getX() - range, lightningSource.getY() - range, lightningSource.getZ() - range, lightningSource.getX() + range, lightningSource.getY() + range, lightningSource.getZ() + range), selector::test); - if(entities.isEmpty()) + if (entities.isEmpty()) { break; + } LivingEntity target = (LivingEntity) entities.get(rand.nextInt(entities.size())); - if(attacker instanceof PlayerEntity) + if (attacker instanceof PlayerEntity) { target.attackEntityFrom(DamageSource.causePlayerDamage((PlayerEntity) attacker), dmg); - else target.attackEntityFrom(DamageSource.causeMobDamage(attacker), dmg); + } else { + target.attackEntityFrom(DamageSource.causeMobDamage(attacker), dmg); + } Botania.proxy.lightningFX(Vector3.fromEntityCenter(lightningSource), Vector3.fromEntityCenter(target), 1, 0x0179C4, 0xAADFFF); @@ -71,11 +75,11 @@ public class ItemThunderSword extends ItemManasteelSword { dmg--; } - if(!entity.world.isRemote) + if (!entity.world.isRemote) { ItemNBTHelper.setLong(stack, TAG_LIGHTNING_SEED, entity.world.rand.nextLong()); + } } - return super.hitEntity(stack, entity, attacker); } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/ToolCommons.java b/src/main/java/vazkii/botania/common/item/equipment/tool/ToolCommons.java index 6ebac1ebf..1b2e2597e 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/ToolCommons.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/ToolCommons.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 13, 2014, 7:13:04 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool; @@ -26,13 +24,12 @@ import net.minecraft.item.ToolItem; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceContext; -import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3i; import net.minecraft.world.World; import net.minecraftforge.common.ForgeHooks; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.common.core.handler.ConfigHandler; @@ -54,8 +51,9 @@ public final class ToolCommons { * Consumes as much mana as possible, returning the amount of damage that couldn't be paid with mana */ public static int damageItemIfPossible(ItemStack stack, int amount, LivingEntity entity, int manaPerDamage) { - if(!(entity instanceof PlayerEntity)) + if (!(entity instanceof PlayerEntity)) { return amount; + } PlayerEntity player = (PlayerEntity) entity; while (amount > 0) { @@ -73,85 +71,98 @@ public final class ToolCommons { int manaToRequest = dmg * manaPerDamage; boolean manaRequested = entity instanceof PlayerEntity && ManaItemHandler.requestManaExactForTool(stack, (PlayerEntity) entity, manaToRequest, true); - if(!manaRequested) + if (!manaRequested) { stack.damageItem(dmg, entity, e -> {}); + } } public static void removeBlocksInIteration(PlayerEntity player, ItemStack stack, World world, BlockPos centerPos, - Vec3i startDelta, Vec3i endDelta, Predicate filter, - boolean dispose) { + Vec3i startDelta, Vec3i endDelta, Predicate filter, + boolean dispose) { for (BlockPos iterPos : BlockPos.getAllInBoxMutable(centerPos.add(startDelta), centerPos.add(endDelta))) { // skip original block space to avoid crash, vanilla code in the tool class will handle it - if (iterPos.equals(centerPos)) + if (iterPos.equals(centerPos)) { continue; + } removeBlockWithDrops(player, stack, world, iterPos, filter, dispose); } } public static void removeBlockWithDrops(PlayerEntity player, ItemStack stack, World world, BlockPos pos, - Predicate filter, - boolean dispose) { + Predicate filter, + boolean dispose) { removeBlockWithDrops(player, stack, world, pos, filter, dispose, true); } public static void removeBlockWithDrops(PlayerEntity player, ItemStack stack, World world, BlockPos pos, - Predicate filter, - boolean dispose, boolean particles) { - if(!world.isBlockLoaded(pos)) + Predicate filter, + boolean dispose, boolean particles) { + if (!world.isBlockLoaded(pos)) { return; + } BlockState state = world.getBlockState(pos); Block block = state.getBlock(); - if(!world.isRemote && filter.test(state) + if (!world.isRemote && filter.test(state) && !block.isAir(state, world, pos) && state.getPlayerRelativeBlockHardness(player, world, pos) > 0 && state.canHarvestBlock(player.world, pos, player)) { int exp = ForgeHooks.onBlockBreakEvent(world, ((ServerPlayerEntity) player).interactionManager.getGameType(), (ServerPlayerEntity) player, pos); - if(exp == -1) + if (exp == -1) { return; + } - if(!player.abilities.isCreativeMode) { + if (!player.abilities.isCreativeMode) { TileEntity tile = world.getTileEntity(pos); - if(block.removedByPlayer(state, world, pos, player, true, world.getFluidState(pos))) { + if (block.removedByPlayer(state, world, pos, player, true, world.getFluidState(pos))) { block.onPlayerDestroy(world, pos, state); - if(!dispose || !ItemElementiumPick.isDisposable(block)) { + if (!dispose || !ItemElementiumPick.isDisposable(block)) { block.harvestBlock(world, player, pos, state, tile, stack); block.dropXpOnBlockBreak(world, pos, exp); } } damageItem(stack, 1, player, 80); - } else world.removeBlock(pos, false); + } else { + world.removeBlock(pos, false); + } - if(particles && ConfigHandler.COMMON.blockBreakParticles.get() && ConfigHandler.COMMON.blockBreakParticlesTool.get()) + if (particles && ConfigHandler.COMMON.blockBreakParticles.get() && ConfigHandler.COMMON.blockBreakParticlesTool.get()) { world.playEvent(2001, pos, Block.getStateId(state)); + } } } public static int getToolPriority(ItemStack stack) { - if(stack.isEmpty()) + if (stack.isEmpty()) { return 0; + } Item item = stack.getItem(); - if(!(item instanceof ToolItem)) + if (!(item instanceof ToolItem)) { return 0; + } ToolItem tool = (ToolItem) item; IItemTier material = tool.getTier(); int materialLevel = 0; - if(material == BotaniaAPI.MANASTEEL_ITEM_TIER) + if (material == BotaniaAPI.MANASTEEL_ITEM_TIER) { materialLevel = 10; - if(material == BotaniaAPI.ELEMENTIUM_ITEM_TIER) + } + if (material == BotaniaAPI.ELEMENTIUM_ITEM_TIER) { materialLevel = 11; - if(material == BotaniaAPI.TERRASTEEL_ITEM_TIER) + } + if (material == BotaniaAPI.TERRASTEEL_ITEM_TIER) { materialLevel = 20; + } int modifier = 0; - if(item == ModItems.terraPick) + if (item == ModItems.terraPick) { modifier = ItemTerraPick.getLevel(stack); + } int efficiency = EnchantmentHelper.getEnchantmentLevel(Enchantments.EFFICIENCY, stack); return materialLevel * 100 + modifier * 10 + efficiency; 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 9947966e7..932ed5a1a 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 @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 21, 2015, 6:33:40 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.bow; @@ -16,6 +14,7 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.projectile.AbstractArrowEntity; import net.minecraft.item.ItemStack; + import vazkii.botania.api.mana.ManaItemHandler; public class ItemCrystalBow extends ItemLivingwoodBow { @@ -40,7 +39,8 @@ public class ItemCrystalBow extends ItemLivingwoodBow { @Override void onFire(ItemStack stack, LivingEntity living, boolean infinity, AbstractArrowEntity arrow) { arrow.pickupStatus = AbstractArrowEntity.PickupStatus.CREATIVE_ONLY; - if(living instanceof PlayerEntity) + if (living instanceof PlayerEntity) { ManaItemHandler.requestManaExactForTool(stack, (PlayerEntity) living, ARROW_COST / (infinity ? 2 : 1), true); + } } } 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 a0f52182a..c24c3f6fe 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 @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 21, 2015, 4:58:45 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.bow; @@ -28,12 +26,14 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; import net.minecraft.world.World; + import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.ToolCommons; import javax.annotation.Nonnull; + import java.util.function.Consumer; public class ItemLivingwoodBow extends BowItem implements IManaUsingItem { @@ -42,12 +42,9 @@ public class ItemLivingwoodBow extends BowItem implements IManaUsingItem { public ItemLivingwoodBow(Properties builder) { super(builder); addPropertyOverride(new ResourceLocation("minecraft:pull"), (stack, worldIn, entityIn) -> { - if (entityIn == null) - { + if (entityIn == null) { return 0.0F; - } - else - { + } else { ItemStack itemstack = entityIn.getActiveItemStack(); return !itemstack.isEmpty() && itemstack.getItem() instanceof ItemLivingwoodBow ? (stack.getUseDuration() - entityIn.getItemInUseCount()) * chargeVelocityMultiplier() / 20.0F : 0.0F; } @@ -62,7 +59,9 @@ public class ItemLivingwoodBow extends BowItem implements IManaUsingItem { 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 (ret != null) { + return ret; + } if (!playerIn.abilities.isCreativeMode && !flag) { return flag ? new ActionResult<>(ActionResultType.PASS, itemstack) : new ActionResult<>(ActionResultType.FAIL, itemstack); @@ -76,13 +75,15 @@ public class ItemLivingwoodBow extends BowItem implements IManaUsingItem { @Override public void onPlayerStoppedUsing(@Nonnull ItemStack stack, @Nonnull World worldIn, LivingEntity entityLiving, int timeLeft) { if (entityLiving instanceof PlayerEntity) { - PlayerEntity playerentity = (PlayerEntity)entityLiving; + PlayerEntity playerentity = (PlayerEntity) entityLiving; boolean flag = canFire(stack, playerentity); // Botania - custom check ItemStack itemstack = playerentity.findAmmo(stack); 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; + if (i < 0) { + return; + } if (!itemstack.isEmpty() || flag) { if (itemstack.isEmpty()) { @@ -90,10 +91,10 @@ public class ItemLivingwoodBow extends BowItem implements IManaUsingItem { } 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 (!((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); + 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); @@ -103,7 +104,7 @@ public class ItemLivingwoodBow extends BowItem implements IManaUsingItem { int j = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER, stack); if (j > 0) { - abstractarrowentity.setDamage(abstractarrowentity.getDamage() + (double)j * 0.5D + 0.5D); + abstractarrowentity.setDamage(abstractarrowentity.getDamage() + (double) j * 0.5D + 0.5D); } int k = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack); @@ -124,7 +125,7 @@ public class ItemLivingwoodBow extends BowItem implements IManaUsingItem { worldIn.addEntity(abstractarrowentity); } - worldIn.playSound((PlayerEntity)null, playerentity.getX(), playerentity.getY(), playerentity.getZ(), SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F / (random.nextFloat() * 0.4F + 1.2F) + f * 0.5F); + worldIn.playSound((PlayerEntity) null, playerentity.getX(), playerentity.getY(), playerentity.getZ(), 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()) { @@ -154,8 +155,9 @@ public class ItemLivingwoodBow extends BowItem implements IManaUsingItem { @Override public void inventoryTick(ItemStack stack, World world, Entity player, int slot, boolean selected) { - if(!world.isRemote && player instanceof PlayerEntity && stack.getDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (PlayerEntity) player, MANA_PER_DAMAGE * 2, true)) + if (!world.isRemote && player instanceof PlayerEntity && stack.getDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (PlayerEntity) player, MANA_PER_DAMAGE * 2, true)) { stack.setDamage(stack.getDamage() - 1); + } } @Override diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumAxe.java b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumAxe.java index 89320b67f..6a2cc747a 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumAxe.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumAxe.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.common.item.equipment.tool.elementium; import net.minecraft.enchantment.EnchantmentHelper; @@ -13,6 +21,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingDropsEvent; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.core.helper.ItemNBTHelper; @@ -31,25 +40,26 @@ public class ItemElementiumAxe extends ItemManasteelAxe { // Thanks to SpitefulFox for the drop rates // https://github.com/SpitefulFox/ForbiddenMagic/blob/master/src/com/spiteful/forbidden/FMEventHandler.java - private void onEntityDrops(LivingDropsEvent event) { - if(event.isRecentlyHit() && event.getSource().getTrueSource() != null && event.getSource().getTrueSource() instanceof PlayerEntity) { + private void onEntityDrops(LivingDropsEvent event) { + if (event.isRecentlyHit() && event.getSource().getTrueSource() != null && event.getSource().getTrueSource() instanceof PlayerEntity) { ItemStack weapon = ((PlayerEntity) event.getSource().getTrueSource()).getHeldItemMainhand(); - if(!weapon.isEmpty() && weapon.getItem() == this) { + if (!weapon.isEmpty() && weapon.getItem() == this) { Random rand = event.getEntityLiving().world.rand; int looting = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, weapon); - if(event.getEntityLiving() instanceof AbstractSkeletonEntity && rand.nextInt(26) <= 3 + looting) + if (event.getEntityLiving() instanceof AbstractSkeletonEntity && rand.nextInt(26) <= 3 + looting) { addDrop(event, new ItemStack(event.getEntity() instanceof WitherSkeletonEntity ? Items.WITHER_SKELETON_SKULL : Items.SKELETON_SKULL)); - else if(event.getEntityLiving() instanceof ZombieEntity && !(event.getEntityLiving() instanceof ZombiePigmanEntity) && rand.nextInt(26) <= 2 + 2 * looting) + } else if (event.getEntityLiving() instanceof ZombieEntity && !(event.getEntityLiving() instanceof ZombiePigmanEntity) && rand.nextInt(26) <= 2 + 2 * looting) { addDrop(event, new ItemStack(Items.ZOMBIE_HEAD)); - else if(event.getEntityLiving() instanceof CreeperEntity && rand.nextInt(26) <= 2 + 2 * looting) + } else if (event.getEntityLiving() instanceof CreeperEntity && rand.nextInt(26) <= 2 + 2 * looting) { addDrop(event, new ItemStack(Items.CREEPER_HEAD)); - else if(event.getEntityLiving() instanceof PlayerEntity && rand.nextInt(11) <= 1 + looting) { + } else if (event.getEntityLiving() instanceof PlayerEntity && rand.nextInt(11) <= 1 + looting) { ItemStack stack = new ItemStack(Items.PLAYER_HEAD); ItemNBTHelper.setString(stack, "SkullOwner", ((PlayerEntity) event.getEntityLiving()).getGameProfile().getName()); addDrop(event, stack); - } else if(event.getEntityLiving() instanceof EntityDoppleganger && rand.nextInt(13) < 1 + looting) + } else if (event.getEntityLiving() instanceof EntityDoppleganger && rand.nextInt(13) < 1 + looting) { addDrop(event, new ItemStack(ModBlocks.gaiaHead)); + } } } } 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 fb69aaab5..bc46f44c6 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 @@ -1,9 +1,18 @@ +/* + * This class is 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 + */ package vazkii.botania.common.item.equipment.tool.elementium; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelPick; @@ -18,9 +27,9 @@ public class ItemElementiumPick extends ItemManasteelPick { } private void onHarvestDrops(HarvestDropsEvent event) { - if(event.getHarvester() != null) { + if (event.getHarvester() != null) { ItemStack stack = event.getHarvester().getHeldItemMainhand(); - if(!stack.isEmpty() && (stack.getItem() == this || stack.getItem() == ModItems.terraPick && ItemTerraPick.isTipped(stack))) { + if (!stack.isEmpty() && (stack.getItem() == this || stack.getItem() == ModItems.terraPick && ItemTerraPick.isTipped(stack))) { event.getDrops().removeIf(s -> !s.isEmpty() && (isDisposable(s) || isSemiDisposable(s) && !event.getHarvester().isSneaking())); } @@ -32,8 +41,9 @@ public class ItemElementiumPick extends ItemManasteelPick { } private static boolean isDisposable(ItemStack stack) { - if(stack.isEmpty()) + if (stack.isEmpty()) { return false; + } return ModTags.Items.DISPOSABLE.contains(stack.getItem()); } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumShears.java b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumShears.java index 14f2ac772..3a2887bec 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumShears.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumShears.java @@ -1,6 +1,15 @@ +/* + * This class is 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 + */ package vazkii.botania.common.item.equipment.tool.elementium; import com.google.common.base.Predicates; + import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.Enchantments; import net.minecraft.entity.Entity; @@ -9,19 +18,20 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.UseAction; import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.IShearable; + import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelShears; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.List; public class ItemElementiumShears extends ItemManasteelShears { @@ -29,7 +39,7 @@ public class ItemElementiumShears extends ItemManasteelShears { public ItemElementiumShears(Properties props) { super(props); addPropertyOverride(new ResourceLocation(LibMisc.MOD_ID, "reddit"), - (stack, worldIn, entityIn) -> stack.getDisplayName().getString().equalsIgnoreCase("dammit reddit") ? 1F: 0F); + (stack, worldIn, entityIn) -> stack.getDisplayName().getString().equalsIgnoreCase("dammit reddit") ? 1F : 0F); } @Nonnull @@ -52,19 +62,20 @@ public class ItemElementiumShears extends ItemManasteelShears { @Override public void onUsingTick(ItemStack stack, LivingEntity living, int count) { - if(living.world.isRemote) + if (living.world.isRemote) { return; + } - if(count != getUseDuration(stack) && count % 5 == 0) { + if (count != getUseDuration(stack) && count % 5 == 0) { int range = 12; List sheep = living.world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(living.getX() - range, living.getY() - range, living.getZ() - range, living.getX() + range, living.getY() + range, living.getZ() + range), Predicates.instanceOf(IShearable.class)); - if(sheep.size() > 0) { - for(IShearable target : (List) sheep) { + if (sheep.size() > 0) { + for (IShearable target : (List) sheep) { Entity entity = (Entity) target; - if(target.isShearable(stack, entity.world, new BlockPos(entity))) { + if (target.isShearable(stack, entity.world, new BlockPos(entity))) { List drops = target.onSheared(stack, entity.world, new BlockPos(entity), EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack)); - for(ItemStack drop : drops) { + for (ItemStack drop : drops) { entity.entityDropItem(drop, 1.0F); } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumShovel.java b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumShovel.java index 3f55a060a..71bdbdd61 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumShovel.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumShovel.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.common.item.equipment.tool.elementium; import net.minecraft.block.Block; @@ -8,6 +16,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3i; import net.minecraft.world.World; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelShovel; @@ -22,15 +31,17 @@ public class ItemElementiumShovel extends ItemManasteelShovel { public boolean onBlockStartBreak(ItemStack stack, BlockPos pos, PlayerEntity player) { World world = player.world; Material mat = world.getBlockState(pos).getMaterial(); - if (!ToolCommons.materialsShovel.contains(mat)) + if (!ToolCommons.materialsShovel.contains(mat)) { return false; + } Block blk = world.getBlockState(pos).getBlock(); - if(blk instanceof FallingBlock) + if (blk instanceof FallingBlock) { ToolCommons.removeBlocksInIteration(player, stack, world, pos, new Vec3i(0, -12, 0), new Vec3i(1, 12, 1), state -> state.getBlock() == blk, false); + } return false; } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumSword.java b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumSword.java index 8d9fe8c17..665d62cd7 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumSword.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/elementium/ItemElementiumSword.java @@ -1,8 +1,18 @@ +/* + * This class is 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 + */ package vazkii.botania.common.item.equipment.tool.elementium; import com.google.common.collect.Multimap; + import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.inventory.EquipmentSlotType; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.common.core.handler.PixieHandler; import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelSword; diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelAxe.java b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelAxe.java index 81a2b4747..d2774795b 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelAxe.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelAxe.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 13, 2014, 7:15:39 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.manasteel; @@ -19,6 +17,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; import net.minecraft.util.ActionResultType; import net.minecraft.world.World; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.item.ISortableTool; import vazkii.botania.api.mana.IManaUsingItem; @@ -28,6 +27,7 @@ import vazkii.botania.common.core.helper.PlayerHelper; import vazkii.botania.common.item.equipment.tool.ToolCommons; import javax.annotation.Nonnull; + import java.util.function.Consumer; import java.util.regex.Pattern; @@ -58,10 +58,10 @@ public class ItemManasteelAxe extends AxeItem implements IManaUsingItem, ISortab @Override public ActionResultType onItemUse(ItemUseContext ctx) { PlayerEntity player = ctx.getPlayer(); - if(player != null) { - for(int i = 0; i < player.inventory.getSizeInventory(); i++) { + if (player != null) { + for (int i = 0; i < player.inventory.getSizeInventory(); i++) { ItemStack stackAt = player.inventory.getStackInSlot(i); - if(!stackAt.isEmpty() && SAPLING_PATTERN.matcher(stackAt.getItem().getTranslationKey()).find()) { + if (!stackAt.isEmpty() && SAPLING_PATTERN.matcher(stackAt.getItem().getTranslationKey()).find()) { ItemStack displayStack = stackAt.copy(); if (PlayerHelper.substituteUse(ctx, stackAt) == ActionResultType.SUCCESS) { ItemsRemainingRenderHandler.set(player, displayStack, SAPLING_PATTERN); @@ -74,11 +74,11 @@ public class ItemManasteelAxe extends AxeItem implements IManaUsingItem, ISortab return super.onItemUse(ctx); } - @Override public void inventoryTick(ItemStack stack, World world, Entity player, int slot, boolean selected) { - if(!world.isRemote && player instanceof PlayerEntity && stack.getDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (PlayerEntity) player, getManaPerDamage() * 2, true)) + if (!world.isRemote && player instanceof PlayerEntity && stack.getDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (PlayerEntity) player, getManaPerDamage() * 2, true)) { stack.setDamage(stack.getDamage() - 1); + } } @Override @@ -90,4 +90,4 @@ public class ItemManasteelAxe extends AxeItem implements IManaUsingItem, ISortab public int getSortingPriority(ItemStack stack) { return ToolCommons.getToolPriority(stack); } -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelPick.java b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelPick.java index 863da0be9..d944b6687 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelPick.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelPick.java @@ -1,16 +1,13 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 13, 2014, 7:05:58 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.manasteel; -import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; @@ -19,8 +16,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; import net.minecraft.item.PickaxeItem; import net.minecraft.util.ActionResultType; -import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.item.ISortableTool; import vazkii.botania.api.mana.IManaUsingItem; @@ -30,6 +27,7 @@ import vazkii.botania.common.core.helper.PlayerHelper; import vazkii.botania.common.item.equipment.tool.ToolCommons; import javax.annotation.Nonnull; + import java.util.function.Consumer; import java.util.regex.Pattern; @@ -57,10 +55,10 @@ public class ItemManasteelPick extends PickaxeItem implements IManaUsingItem, IS public ActionResultType onItemUse(ItemUseContext ctx) { PlayerEntity player = ctx.getPlayer(); - if(player != null) { - for(int i = 0; i < player.inventory.getSizeInventory(); i++) { + if (player != null) { + for (int i = 0; i < player.inventory.getSizeInventory(); i++) { ItemStack stackAt = player.inventory.getStackInSlot(i); - if(!stackAt.isEmpty() && TORCH_PATTERN.matcher(stackAt.getItem().getTranslationKey()).find()) { + if (!stackAt.isEmpty() && TORCH_PATTERN.matcher(stackAt.getItem().getTranslationKey()).find()) { ItemStack displayStack = stackAt.copy(); ActionResultType did = PlayerHelper.substituteUse(ctx, stackAt); ItemsRemainingRenderHandler.set(player, displayStack, TORCH_PATTERN); @@ -78,8 +76,9 @@ public class ItemManasteelPick extends PickaxeItem implements IManaUsingItem, IS @Override public void inventoryTick(ItemStack stack, World world, Entity player, int slot, boolean selected) { - if(!world.isRemote && player instanceof PlayerEntity && stack.getDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (PlayerEntity) player, MANA_PER_DAMAGE * 2, true)) + if (!world.isRemote && player instanceof PlayerEntity && stack.getDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (PlayerEntity) player, MANA_PER_DAMAGE * 2, true)) { stack.setDamage(stack.getDamage() - 1); + } } @Override diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShears.java b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShears.java index d2d0d98cc..e1c69e654 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShears.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShears.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 13, 2014, 7:28:35 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.manasteel; @@ -25,12 +23,14 @@ import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.IShearable; + import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.ToolCommons; import javax.annotation.Nonnull; + import java.util.List; import java.util.Random; import java.util.function.Consumer; @@ -45,15 +45,16 @@ public class ItemManasteelShears extends ShearsItem implements IManaUsingItem { @Override public boolean itemInteractionForEntity(@Nonnull ItemStack itemstack, PlayerEntity player, LivingEntity entity, Hand hand) { - if(entity.world.isRemote) + if (entity.world.isRemote) { return false; + } - if(entity instanceof IShearable) { - IShearable target = (IShearable)entity; - if(target.isShearable(itemstack, entity.world, new BlockPos(entity))) { + if (entity instanceof IShearable) { + IShearable target = (IShearable) entity; + if (target.isShearable(itemstack, entity.world, new BlockPos(entity))) { List drops = target.onSheared(itemstack, entity.world, new BlockPos(entity), EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, itemstack)); - for(ItemStack stack : drops) { + for (ItemStack stack : drops) { entity.entityDropItem(stack, 1.0F); } @@ -68,19 +69,20 @@ public class ItemManasteelShears extends ShearsItem implements IManaUsingItem { @Override public boolean onBlockStartBreak(@Nonnull ItemStack itemstack, @Nonnull BlockPos pos, PlayerEntity player) { - if (player.world.isRemote) + if (player.world.isRemote) { return false; + } Block block = player.world.getBlockState(pos).getBlock(); - if(block instanceof IShearable) { - IShearable target = (IShearable)block; - if(target.isShearable(itemstack, player.world, pos)) { + if (block instanceof IShearable) { + IShearable target = (IShearable) block; + if (target.isShearable(itemstack, player.world, pos)) { List drops = target.onSheared(itemstack, player.world, pos, EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, itemstack)); Random rand = new Random(); - for(ItemStack stack : drops) { + for (ItemStack stack : drops) { float f = 0.7F; - double d = rand.nextFloat() * f + (1D - f) * 0.5; + double d = rand.nextFloat() * f + (1D - f) * 0.5; double d1 = rand.nextFloat() * f + (1D - f) * 0.5; double d2 = rand.nextFloat() * f + (1D - f) * 0.5; @@ -106,8 +108,9 @@ public class ItemManasteelShears extends ShearsItem implements IManaUsingItem { @Override public void inventoryTick(ItemStack stack, World world, Entity player, int slot, boolean selected) { - if(!world.isRemote && player instanceof PlayerEntity && stack.getDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (PlayerEntity) player, MANA_PER_DAMAGE * 2, true)) + if (!world.isRemote && player instanceof PlayerEntity && stack.getDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (PlayerEntity) player, MANA_PER_DAMAGE * 2, true)) { stack.setDamage(stack.getDamage() - 1); + } } @Override diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShovel.java b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShovel.java index ac800b650..eda527c6f 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShovel.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelShovel.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 13, 2014, 7:14:54 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.manasteel; @@ -29,6 +27,7 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.UseHoeEvent; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.item.ISortableTool; import vazkii.botania.api.mana.IManaUsingItem; @@ -37,6 +36,7 @@ import vazkii.botania.common.item.equipment.tool.ToolCommons; import vazkii.botania.common.lib.LibObfuscation; import javax.annotation.Nonnull; + import java.util.Map; import java.util.function.Consumer; @@ -71,20 +71,23 @@ public class ItemManasteelShovel extends ShovelItem implements IManaUsingItem, I @Nonnull @Override public ActionResultType onItemUse(ItemUseContext ctx) { - if (super.onItemUse(ctx) == ActionResultType.SUCCESS) + if (super.onItemUse(ctx) == ActionResultType.SUCCESS) { return ActionResultType.SUCCESS; + } ItemStack stack = ctx.getItem(); PlayerEntity player = ctx.getPlayer(); World world = ctx.getWorld(); BlockPos pos = ctx.getPos(); - if (player == null || !player.canPlayerEdit(pos, ctx.getFace(), stack)) + if (player == null || !player.canPlayerEdit(pos, ctx.getFace(), stack)) { return ActionResultType.PASS; + } UseHoeEvent event = new UseHoeEvent(ctx); - if (MinecraftForge.EVENT_BUS.post(event)) + if (MinecraftForge.EVENT_BUS.post(event)) { return ActionResultType.FAIL; + } if (event.getResult() == Event.Result.ALLOW) { ToolCommons.damageItem(stack, 1, player, getManaPerDamage()); @@ -93,8 +96,9 @@ public class ItemManasteelShovel extends ShovelItem implements IManaUsingItem, I Block block = world.getBlockState(pos).getBlock(); BlockState converted = HOE_LOOKUP.get(block); - if (converted == null) + if (converted == null) { return ActionResultType.PASS; + } if (ctx.getFace() != Direction.DOWN && world.getBlockState(pos.up()).getBlock().isAir(world.getBlockState(pos.up()), world, pos.up())) { world.playSound(null, pos, converted.getSoundType().getStepSound(), @@ -102,9 +106,9 @@ public class ItemManasteelShovel extends ShovelItem implements IManaUsingItem, I (converted.getSoundType().getVolume() + 1.0F) / 2.0F, converted.getSoundType().getPitch() * 0.8F); - if (world.isRemote) + if (world.isRemote) { return ActionResultType.SUCCESS; - else { + } else { world.setBlockState(pos, converted); ToolCommons.damageItem(stack, 1, player, getManaPerDamage()); return ActionResultType.SUCCESS; @@ -116,8 +120,9 @@ public class ItemManasteelShovel extends ShovelItem implements IManaUsingItem, I @Override public void inventoryTick(ItemStack stack, World world, Entity player, int slot, boolean selected) { - if (!world.isRemote && player instanceof PlayerEntity && stack.getDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (PlayerEntity) player, getManaPerDamage() * 2, true)) + if (!world.isRemote && player instanceof PlayerEntity && stack.getDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (PlayerEntity) player, getManaPerDamage() * 2, true)) { stack.setDamage(stack.getDamage() - 1); + } } @Override diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelSword.java b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelSword.java index 3d2fc2cfb..934085dbb 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelSword.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/manasteel/ItemManasteelSword.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 13, 2014, 7:21:32 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.manasteel; @@ -18,6 +16,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.SwordItem; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; @@ -46,8 +45,9 @@ public class ItemManasteelSword extends SwordItem implements IManaUsingItem { @Override public void inventoryTick(ItemStack stack, World world, Entity player, int slot, boolean selected) { - if(!world.isRemote && player instanceof PlayerEntity && stack.getDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (PlayerEntity) player, getManaPerDamage() * 2, true)) + if (!world.isRemote && player instanceof PlayerEntity && stack.getDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (PlayerEntity) player, getManaPerDamage() * 2, true)) { stack.setDamage(stack.getDamage() - 1); + } } public int getManaPerDamage() { 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 0ec7b16d5..ca4348e17 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 @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 15, 2015, 6:55:34 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.terrasteel; @@ -18,12 +16,12 @@ import net.minecraft.util.Direction; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceContext; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; import net.minecraft.world.dimension.DimensionType; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.TickEvent; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.item.ISequentialBreaker; import vazkii.botania.common.item.ItemTemperanceStone; @@ -33,6 +31,7 @@ import vazkii.botania.common.item.relic.ItemLokiRing; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -44,7 +43,6 @@ import java.util.Set; public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker { - /** * The number of blocks per tick which the Terra Truncator will * collect. @@ -78,8 +76,9 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker super(BotaniaAPI.TERRASTEEL_ITEM_TIER, props); MinecraftForge.EVENT_BUS.addListener(this::onTickEnd); addPropertyOverride(new ResourceLocation(LibMisc.MOD_ID, "terraaxe_on"), (stack, world, entity) -> { - if(entity instanceof PlayerEntity && !shouldBreak((PlayerEntity) entity)) + if (entity instanceof PlayerEntity && !shouldBreak((PlayerEntity) entity)) { return 0; + } return 1; }); } @@ -91,7 +90,7 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker @Override public boolean onBlockStartBreak(ItemStack stack, BlockPos pos, PlayerEntity player) { BlockRayTraceResult raycast = ToolCommons.raytraceFromEntity(player, 10, false); - if(raycast.getType() == RayTraceResult.Type.BLOCK) { + if (raycast.getType() == RayTraceResult.Type.BLOCK) { Direction face = raycast.getFace(); breakOtherBlock(player, stack, pos, pos, face); ItemLokiRing.breakOnAllCursors(player, this, stack, pos, face); @@ -107,7 +106,7 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker @Override public void breakOtherBlock(PlayerEntity player, ItemStack stack, BlockPos pos, BlockPos originPos, Direction side) { - if(shouldBreak(player)) { + if (shouldBreak(player)) { addBlockSwapper(player.world, player, stack, pos, 32, true); } } @@ -119,12 +118,13 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker private void onTickEnd(TickEvent.WorldTickEvent event) { // Block Swapping ticking should only occur on the server - if(event.world.isRemote) + if (event.world.isRemote) { return; + } - if(event.phase == TickEvent.Phase.END) { + if (event.phase == TickEvent.Phase.END) { DimensionType dim = event.world.getDimension().getType(); - if(blockSwappers.containsKey(dim)) { + if (blockSwappers.containsKey(dim)) { Set swappers = blockSwappers.get(dim); // Iterate through all of our swappers, removing any @@ -140,20 +140,21 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker * 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. + * @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). + * @param steps The range of the block swapper, in blocks. + * @param leaves If true, will treat leaves specially (see the BlockSwapper + * documentation). */ private static void addBlockSwapper(World world, PlayerEntity player, ItemStack stack, BlockPos 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) + if (world.isRemote) { return; + } DimensionType dim = world.getDimension().getType(); blockSwappers.computeIfAbsent(dim, d -> new HashSet<>()).add(swapper); @@ -162,13 +163,11 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker /** * A block swapper for the Terra Truncator, which uses a standard * Breadth First Search to try and murder/cut down trees. - * * The Terra Truncator will look up to BLOCK_RANGE blocks to find wood * to cut down (only cutting down adjacent pieces of wood, so it doesn't * jump through the air). However, the truncator will only go through * LEAF_BLOCK_RANGE leave blocks in order to prevent adjacent trees which * are connected only by leaves from being devoured as well. - * * The leaf restriction is implemented by reducing the number of remaining * steps to the min of LEAF_BLOCK_RANGE and the current range. The restriction * can be removed entirely by setting the "leaves" variable to true, in which @@ -225,13 +224,14 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker /** * Creates a new block swapper with the provided parameters. - * @param world The world the swapper is in. - * @param player The player responsible for creating this swapper. - * @param truncator The Terra Truncator responsible for creating this swapper. + * + * @param world The world the swapper is in. + * @param player The player responsible for creating this swapper. + * @param truncator The Terra Truncator responsible for creating this swapper. * @param origCoords The original coordinates this swapper should start at. - * @param range The range this swapper should swap in. - * @param leaves If true, leaves will be treated specially and - * severely reduce the radius of further spreading when encountered. + * @param range The range this swapper should swap in. + * @param leaves If true, leaves will be treated specially and + * severely reduce the radius of further spreading when encountered. */ public BlockSwapper(World world, PlayerEntity player, ItemStack truncator, BlockPos origCoords, int range, boolean leaves) { this.world = world; @@ -253,26 +253,30 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker * further blocks and expands the breadth first search. The return * value signifies whether or not the block swapper has more blocks * to swap, or if it has finished swapping. + * * @return True if the block swapper has more blocks to swap, false - * otherwise (implying it can be safely removed). + * otherwise (implying it can be safely removed). */ public boolean tick() { // If empty, this swapper is done. - if(candidateQueue.isEmpty()) + if (candidateQueue.isEmpty()) { return false; + } int remainingSwaps = BLOCK_SWAP_RATE; - while(remainingSwaps > 0 && !candidateQueue.isEmpty()) { + while (remainingSwaps > 0 && !candidateQueue.isEmpty()) { SwapCandidate cand = candidateQueue.poll(); // If we've already completed this location, move along, as this // is just a suboptimal one. - if(completedCoords.contains(cand.coordinates)) + if (completedCoords.contains(cand.coordinates)) { continue; + } // If this candidate is out of range, discard it. - if(cand.range <= 0) + if (cand.range <= 0) { continue; + } // Otherwise, perform the break and then look at the adjacent tiles. // This is a ridiculous function call here. @@ -287,24 +291,23 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker // Then, go through all of the adjacent blocks and look if // any of them are any good. - for(BlockPos adj : adjacent(cand.coordinates)) { + for (BlockPos adj : adjacent(cand.coordinates)) { Block block = world.getBlockState(adj).getBlock(); boolean isWood = BlockTags.LOGS.contains(block); boolean isLeaf = BlockTags.LEAVES.contains(block); // If it's not wood or a leaf, we aren't interested. - if(!isWood && !isLeaf) + if (!isWood && !isLeaf) { continue; + } // If we treat leaves specially and this is a leaf, it gets // the minimum of the leaf range and the current range - 1. // Otherwise, it gets the standard range - 1. - int newRange = treatLeavesSpecial && isLeaf ? - Math.min(LEAF_BLOCK_RANGE, cand.range - 1) : - cand.range - 1; + int newRange = treatLeavesSpecial && isLeaf ? Math.min(LEAF_BLOCK_RANGE, cand.range - 1) : cand.range - 1; - candidateQueue.offer(new SwapCandidate(adj, newRange)); + candidateQueue.offer(new SwapCandidate(adj, newRange)); } } @@ -316,15 +319,18 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker List coords = new ArrayList<>(); // Visit all the surrounding blocks in the provided radius. // Gotta love these nested loops, right? - for(int dx = -SINGLE_BLOCK_RADIUS; dx <= SINGLE_BLOCK_RADIUS; dx++) - for(int dy = -SINGLE_BLOCK_RADIUS; dy <= SINGLE_BLOCK_RADIUS; dy++) - for(int dz = -SINGLE_BLOCK_RADIUS; dz <= SINGLE_BLOCK_RADIUS; dz++) { + for (int dx = -SINGLE_BLOCK_RADIUS; dx <= SINGLE_BLOCK_RADIUS; dx++) { + for (int dy = -SINGLE_BLOCK_RADIUS; dy <= SINGLE_BLOCK_RADIUS; dy++) { + for (int dz = -SINGLE_BLOCK_RADIUS; dz <= SINGLE_BLOCK_RADIUS; dz++) { // Skip the central tile. - if(dx == 0 && dy == 0 && dz == 0) + if (dx == 0 && dy == 0 && dz == 0) { continue; + } coords.add(original.add(dx, dy, dz)); } + } + } return coords; } @@ -350,8 +356,9 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker /** * Constructs a new Swap Candidate with the provided * coordinates and range. + * * @param coordinates The coordinates of this candidate. - * @param range The remaining range of this candidate. + * @param range The remaining range of this candidate. */ public SwapCandidate(BlockPos coordinates, int range) { this.coordinates = coordinates; @@ -367,7 +374,9 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker @Override public boolean equals(Object other) { - if(!(other instanceof SwapCandidate)) return false; + if (!(other instanceof SwapCandidate)) { + return false; + } SwapCandidate cand = (SwapCandidate) other; return coordinates.equals(cand.coordinates) && range == cand.range; diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraPick.java b/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraPick.java index 3cabdcaf2..934305bfd 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraPick.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraPick.java @@ -1,19 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [May 20, 2014, 10:56:14 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.terrasteel; import net.minecraft.block.material.Material; import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.Enchantments; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity; @@ -30,7 +26,6 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceContext; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3i; import net.minecraft.util.text.ITextComponent; @@ -39,6 +34,7 @@ import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.item.ISequentialBreaker; import vazkii.botania.api.mana.IManaGivingItem; @@ -54,6 +50,7 @@ import vazkii.botania.common.item.relic.ItemThorRing; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.Arrays; import java.util.List; @@ -86,8 +83,8 @@ public class ItemTerraPick extends ItemManasteelPick implements IManaItem, ISequ @Override public void fillItemGroup(@Nonnull ItemGroup tab, @Nonnull NonNullList list) { - if(isInGroup(tab)) { - for(int mana : CREATIVE_MANA) { + if (isInGroup(tab)) { + for (int mana : CREATIVE_MANA) { ItemStack stack = new ItemStack(this); setMana(stack, mana); list.add(stack); @@ -105,8 +102,9 @@ public class ItemTerraPick extends ItemManasteelPick implements IManaItem, ISequ ITextComponent rank = new TranslationTextComponent("botania.rank" + getLevel(stack)); ITextComponent rankFormat = new TranslationTextComponent("botaniamisc.toolRank", rank); stacks.add(rankFormat); - if(getMana(stack) == Integer.MAX_VALUE) + if (getMana(stack) == Integer.MAX_VALUE) { stacks.add(new TranslationTextComponent("botaniamisc.getALife").applyTextStyle(TextFormatting.RED)); + } } @Nonnull @@ -117,10 +115,11 @@ public class ItemTerraPick extends ItemManasteelPick implements IManaItem, ISequ getMana(stack); int level = getLevel(stack); - if(level != 0) { + if (level != 0) { setEnabled(stack, !isEnabled(stack)); - if(!world.isRemote) + if (!world.isRemote) { world.playSound(null, player.getX(), player.getY(), player.getZ(), ModSounds.terraPickMode, SoundCategory.PLAYERS, 0.5F, 0.4F); + } } return ActionResult.success(stack); @@ -136,20 +135,21 @@ public class ItemTerraPick extends ItemManasteelPick implements IManaItem, ISequ @Override public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) { super.inventoryTick(stack, world, entity, slot, selected); - if(isEnabled(stack)) { + if (isEnabled(stack)) { int level = getLevel(stack); - if(level == 0) + if (level == 0) { setEnabled(stack, false); - else if(entity instanceof PlayerEntity && !((PlayerEntity) entity).isSwingInProgress) + } else if (entity instanceof PlayerEntity && !((PlayerEntity) entity).isSwingInProgress) { addMana(stack, -level); + } } } @Override public boolean onBlockStartBreak(ItemStack stack, BlockPos pos, PlayerEntity player) { BlockRayTraceResult raycast = ToolCommons.raytraceFromEntity(player, 10, false); - if(!player.world.isRemote && raycast.getType() == RayTraceResult.Type.BLOCK) { + if (!player.world.isRemote && raycast.getType() == RayTraceResult.Type.BLOCK) { Direction face = raycast.getFace(); breakOtherBlock(player, stack, pos, pos, face); ItemLokiRing.breakOnAllCursors(player, this, stack, pos, face); @@ -166,16 +166,19 @@ public class ItemTerraPick extends ItemManasteelPick implements IManaItem, ISequ @Override public void breakOtherBlock(PlayerEntity player, ItemStack stack, BlockPos pos, BlockPos originPos, Direction side) { - if(!isEnabled(stack)) + if (!isEnabled(stack)) { return; + } World world = player.world; Material mat = world.getBlockState(pos).getMaterial(); - if(!MATERIALS.contains(mat)) + if (!MATERIALS.contains(mat)) { return; + } - if(world.isAirBlock(pos)) + if (world.isAirBlock(pos)) { return; + } boolean thor = !ItemThorRing.getThorRing(player).isEmpty(); boolean doX = thor || side.getXOffset() == 0; @@ -184,21 +187,23 @@ public class ItemTerraPick extends ItemManasteelPick implements IManaItem, ISequ int origLevel = getLevel(stack); int level = origLevel + (thor ? 1 : 0); - if(ItemTemperanceStone.hasTemperanceActive(player) && level > 2) + if (ItemTemperanceStone.hasTemperanceActive(player) && level > 2) { level = 2; + } int range = level - 1; int rangeY = Math.max(1, range); - if(range == 0 && level != 1) + if (range == 0 && level != 1) { return; + } Vec3i beginDiff = new Vec3i(doX ? -range : 0, doY ? -1 : 0, doZ ? -range : 0); Vec3i endDiff = new Vec3i(doX ? range : 0, doY ? rangeY * 2 - 1 : 0, doZ ? range : 0); ToolCommons.removeBlocksInIteration(player, stack, world, pos, beginDiff, endDiff, state -> MATERIALS.contains(state.getMaterial()), isTipped(stack)); - if(origLevel == 5) { + if (origLevel == 5) { PlayerHelper.grantCriterion((ServerPlayerEntity) player, new ResourceLocation(LibMisc.MOD_ID, "challenge/rank_ss_pick"), "code_triggered"); } } @@ -239,9 +244,11 @@ public class ItemTerraPick extends ItemManasteelPick implements IManaItem, ISequ public static int getLevel(ItemStack stack) { int mana = getMana_(stack); - for(int i = LEVELS.length - 1; i > 0; i--) - if(mana >= LEVELS[i]) + for (int i = LEVELS.length - 1; i > 0; i--) { + if (mana >= LEVELS[i]) { return i; + } + } return 0; } diff --git a/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraSword.java b/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraSword.java index fa63b703d..82a6673c2 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraSword.java +++ b/src/main/java/vazkii/botania/common/item/equipment/tool/terrasteel/ItemTerraSword.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 14, 2014, 7:34:56 PM (GMT)] */ package vazkii.botania.common.item.equipment.tool.terrasteel; @@ -21,6 +19,7 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.AttackEntityEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.api.mana.BurstProperties; @@ -41,7 +40,7 @@ public class ItemTerraSword extends ItemManasteelSword implements ILensEffect { public ItemTerraSword(Properties props) { super(BotaniaAPI.TERRASTEEL_ITEM_TIER, props); MinecraftForge.EVENT_BUS.addListener(this::leftClick); - MinecraftForge.EVENT_BUS.addListener(this::attackEntity); + MinecraftForge.EVENT_BUS.addListener(this::attackEntity); } private void leftClick(PlayerInteractEvent.LeftClickEmpty evt) { @@ -106,22 +105,23 @@ public class ItemTerraSword extends ItemManasteelSword implements ILensEffect { List entities = entity.world.getEntitiesWithinAABB(LivingEntity.class, axis); LivingEntity thrower = entity.getThrower(); - for(LivingEntity living : entities) { - if(living == thrower || living instanceof PlayerEntity && thrower instanceof PlayerEntity - && !((PlayerEntity) thrower).canAttackPlayer(((PlayerEntity) living))) + for (LivingEntity living : entities) { + if (living == thrower || living instanceof PlayerEntity && thrower instanceof PlayerEntity + && !((PlayerEntity) thrower).canAttackPlayer(((PlayerEntity) living))) { continue; + } - if(living.hurtTime == 0) { + if (living.hurtTime == 0) { int cost = MANA_PER_DAMAGE / 3; int mana = burst.getMana(); - if(mana >= cost) { + if (mana >= cost) { burst.setMana(mana - cost); float damage = 4F + BotaniaAPI.TERRASTEEL_ITEM_TIER.getAttackDamage(); - if(!burst.isFake() && !entity.world.isRemote) { + if (!burst.isFake() && !entity.world.isRemote) { DamageSource source = DamageSource.MAGIC; - if(thrower instanceof PlayerEntity) { + if (thrower instanceof PlayerEntity) { source = DamageSource.causePlayerDamage((PlayerEntity) thrower); - } else if(thrower != null) { + } else if (thrower != null) { source = DamageSource.causeMobDamage(thrower); } living.attackEntityFrom(source, damage); diff --git a/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemElementiumHelmRevealing.java b/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemElementiumHelmRevealing.java index 3318d9741..474a987e6 100644 --- a/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemElementiumHelmRevealing.java +++ b/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemElementiumHelmRevealing.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 28, 2014, 6:16:24 PM (GMT)] */ package vazkii.botania.common.item.interaction.thaumcraft; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ItemStack; + import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.item.equipment.armor.elementium.ItemElementiumHelm; diff --git a/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemManaInkwell.java b/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemManaInkwell.java index 5461d6c9a..b6de98377 100644 --- a/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemManaInkwell.java +++ b/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemManaInkwell.java @@ -1,23 +1,22 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 26, 2014, 5:39:07 PM (GMT)] */ package vazkii.botania.common.item.interaction.thaumcraft; +import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.NonNullList; import net.minecraft.world.World; + import vazkii.botania.api.mana.IManaItem; import vazkii.botania.common.core.helper.ItemNBTHelper; -import net.minecraft.item.Item; import javax.annotation.Nonnull; @@ -35,7 +34,7 @@ public class ItemManaInkwell extends Item implements IManaItem { @Override public void fillItemGroup(@Nonnull ItemGroup tab, @Nonnull NonNullList list) { - if(isInGroup(tab)) { + if (isInGroup(tab)) { list.add(new ItemStack(this)); ItemStack full = new ItemStack(this); setMana(full, MAX_MANA); @@ -52,10 +51,10 @@ public class ItemManaInkwell extends Item implements IManaItem { @Override public void setDamage(ItemStack stack, int damage) { int currentDamage = stack.getDamage(); - if(damage > currentDamage) { + if (damage > currentDamage) { int cost = (damage - currentDamage) * COST_PER_USE; int mana = getMana(stack); - if(mana >= cost) { + if (mana >= cost) { addMana(stack, -cost); return; } diff --git a/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemManasteelHelmRevealing.java b/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemManasteelHelmRevealing.java index 6513d209d..0199b2dfc 100644 --- a/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemManasteelHelmRevealing.java +++ b/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemManasteelHelmRevealing.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 28, 2014, 6:18:05 PM (GMT)] */ package vazkii.botania.common.item.interaction.thaumcraft; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ItemStack; + import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.item.equipment.armor.manasteel.ItemManasteelHelm; @@ -27,4 +26,4 @@ public class ItemManasteelHelmRevealing extends ItemManasteelHelm { return ConfigHandler.CLIENT.enableArmorModels.get() ? LibResources.MODEL_MANASTEEL_NEW : LibResources.MODEL_MANASTEEL_2; } -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemTerrasteelHelmRevealing.java b/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemTerrasteelHelmRevealing.java index 17c7a58a7..56a6e3dbf 100644 --- a/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemTerrasteelHelmRevealing.java +++ b/src/main/java/vazkii/botania/common/item/interaction/thaumcraft/ItemTerrasteelHelmRevealing.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 28, 2014, 6:22:51 PM (GMT)] */ package vazkii.botania.common.item.interaction.thaumcraft; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ItemStack; + import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.item.equipment.armor.terrasteel.ItemTerrasteelHelm; @@ -24,7 +23,7 @@ public class ItemTerrasteelHelmRevealing extends ItemTerrasteelHelm { @Override public String getArmorTextureAfterInk(ItemStack stack, EquipmentSlotType slot) { - return ConfigHandler.CLIENT.enableArmorModels.get() ? LibResources.MODEL_TERRASTEEL_NEW : LibResources.MODEL_TERRASTEEL_2; + return ConfigHandler.CLIENT.enableArmorModels.get() ? LibResources.MODEL_TERRASTEEL_NEW : LibResources.MODEL_TERRASTEEL_2; } -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/common/item/lens/ItemLens.java b/src/main/java/vazkii/botania/common/item/lens/ItemLens.java index eab65bf60..c5d66a091 100644 --- a/src/main/java/vazkii/botania/common/item/lens/ItemLens.java +++ b/src/main/java/vazkii/botania/common/item/lens/ItemLens.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 31, 2014, 3:02:58 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -24,6 +22,7 @@ import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.api.mana.BurstProperties; import vazkii.botania.api.mana.ICompositableLens; @@ -34,10 +33,10 @@ import vazkii.botania.api.mana.IManaSpreader; import vazkii.botania.api.mana.ITinyPlanetExcempt; import vazkii.botania.common.Botania; import vazkii.botania.common.core.helper.ItemNBTHelper; -import net.minecraft.item.Item; import vazkii.botania.common.item.ModItems; import javax.annotation.Nonnull; + import java.util.List; public class ItemLens extends Item implements ILensControl, ICompositableLens, ITinyPlanetExcempt { @@ -65,7 +64,7 @@ public class ItemLens extends Item implements ILensControl, ICompositableLens, I @Override public void addInformation(ItemStack stack, World world, List stacks, ITooltipFlag flags) { int storedColor = getStoredColor(stack); - if(storedColor != -1) { + if (storedColor != -1) { TranslationTextComponent colorName = new TranslationTextComponent(storedColor == 16 ? "botania.color.rainbow" : "color.minecraft." + DyeColor.byId(storedColor)); stacks.add(new TranslationTextComponent("botaniamisc.color", colorName).applyTextStyle(TextFormatting.GRAY)); } @@ -75,8 +74,9 @@ public class ItemLens extends Item implements ILensControl, ICompositableLens, I @Override public ITextComponent getDisplayName(@Nonnull ItemStack stack) { ItemStack compositeLens = getCompositeLens(stack); - if(compositeLens.isEmpty()) + if (compositeLens.isEmpty()) { return super.getDisplayName(stack); + } String shortKeyA = stack.getTranslationKey() + ".short"; String shortKeyB = compositeLens.getTranslationKey() + ".short"; return new TranslationTextComponent("item.botania.composite_lens", new TranslationTextComponent(shortKeyA), new TranslationTextComponent(shortKeyB)); @@ -85,14 +85,16 @@ public class ItemLens extends Item implements ILensControl, ICompositableLens, I @Override public void apply(ItemStack stack, BurstProperties props) { int storedColor = getStoredColor(stack); - if(storedColor != -1) + if (storedColor != -1) { props.color = getLensColor(stack); + } getLens(stack).apply(stack, props); ItemStack compositeLens = getCompositeLens(stack); - if(!compositeLens.isEmpty() && compositeLens.getItem() instanceof ILens) + if (!compositeLens.isEmpty() && compositeLens.getItem() instanceof ILens) { ((ILens) compositeLens.getItem()).apply(compositeLens, props); + } } @Override @@ -102,8 +104,9 @@ public class ItemLens extends Item implements ILensControl, ICompositableLens, I dead = getLens(stack).collideBurst(burst, entity, pos, isManaBlock, dead, stack); ItemStack compositeLens = getCompositeLens(stack); - if(!compositeLens.isEmpty() && compositeLens.getItem() instanceof ILens) + if (!compositeLens.isEmpty() && compositeLens.getItem() instanceof ILens) { dead = ((ILens) compositeLens.getItem()).collideBurst(burst, pos, isManaBlock, dead, compositeLens); + } return dead; } @@ -113,25 +116,29 @@ public class ItemLens extends Item implements ILensControl, ICompositableLens, I ThrowableEntity entity = (ThrowableEntity) burst; int storedColor = getStoredColor(stack); - if(storedColor == 16 && entity.world.isRemote) + if (storedColor == 16 && entity.world.isRemote) { burst.setColor(getLensColor(stack)); + } getLens(stack).updateBurst(burst, entity, stack); ItemStack compositeLens = getCompositeLens(stack); - if(!compositeLens.isEmpty() && compositeLens.getItem() instanceof ILens) + if (!compositeLens.isEmpty() && compositeLens.getItem() instanceof ILens) { ((ILens) compositeLens.getItem()).updateBurst(burst, compositeLens); + } } @Override public int getLensColor(ItemStack stack) { int storedColor = getStoredColor(stack); - if(storedColor == -1) + if (storedColor == -1) { return 0xFFFFFF; + } - if(storedColor == 16) + if (storedColor == 16) { return MathHelper.hsvToRGB(Botania.proxy.getWorldElapsedTicks() * 2 % 360 / 360F, 1F, 1F); + } return DyeColor.byId(storedColor).colorValue; } @@ -156,23 +163,28 @@ public class ItemLens extends Item implements ILensControl, ICompositableLens, I } public static Lens getLens(ItemStack stack) { - if(stack.getItem() instanceof ItemLens) + if (stack.getItem() instanceof ItemLens) { return ((ItemLens) stack.getItem()).lens; - else return new Lens(); + } else { + return new Lens(); + } } @Override public boolean canCombineLenses(ItemStack sourceLens, ItemStack compositeLens) { ICompositableLens sourceItem = (ICompositableLens) sourceLens.getItem(); ICompositableLens compositeItem = (ICompositableLens) compositeLens.getItem(); - if(sourceItem == compositeItem) + if (sourceItem == compositeItem) { return false; + } - if(!sourceItem.isCombinable(sourceLens) || !compositeItem.isCombinable(compositeLens)) + if (!sourceItem.isCombinable(sourceLens) || !compositeItem.isCombinable(compositeLens)) { return false; + } - if(isBlacklisted(sourceLens, compositeLens)) + if (isBlacklisted(sourceLens, compositeLens)) { return false; + } return true; } @@ -180,14 +192,16 @@ public class ItemLens extends Item implements ILensControl, ICompositableLens, I @Override public ItemStack getCompositeLens(ItemStack stack) { CompoundNBT cmp = ItemNBTHelper.getCompound(stack, TAG_COMPOSITE_LENS, true); - if(cmp == null) + if (cmp == null) { return ItemStack.EMPTY; - else return ItemStack.read(cmp); + } else { + return ItemStack.read(cmp); + } } @Override public ItemStack setCompositeLens(ItemStack sourceLens, ItemStack compositeLens) { - if(!compositeLens.isEmpty()) { + if (!compositeLens.isEmpty()) { CompoundNBT cmp = compositeLens.write(new CompoundNBT()); ItemNBTHelper.setCompound(sourceLens, TAG_COMPOSITE_LENS, cmp); } @@ -198,7 +212,7 @@ public class ItemLens extends Item implements ILensControl, ICompositableLens, I public int getManaToTransfer(IManaBurst burst, ThrowableEntity entity, ItemStack stack, IManaReceiver receiver) { return getLens(stack).getManaToTransfer(burst, entity, stack, receiver); } - + @Override public boolean shouldPull(ItemStack stack) { return stack.getItem() != ModItems.lensStorm; diff --git a/src/main/java/vazkii/botania/common/item/lens/Lens.java b/src/main/java/vazkii/botania/common/item/lens/Lens.java index cb35550eb..b563cfe29 100644 --- a/src/main/java/vazkii/botania/common/item/lens/Lens.java +++ b/src/main/java/vazkii/botania/common/item/lens/Lens.java @@ -1,24 +1,23 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 24, 2015, 4:31:16 PM (GMT)] */ package vazkii.botania.common.item.lens; import net.minecraft.entity.projectile.ThrowableEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.math.RayTraceResult; + import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.api.mana.BurstProperties; import vazkii.botania.api.mana.IManaReceiver; import vazkii.botania.api.mana.IManaSpreader; -public class Lens { +public class Lens { public void apply(ItemStack stack, BurstProperties props) {} @@ -35,7 +34,7 @@ public class Lens { public void onControlledSpreaderTick(ItemStack stack, IManaSpreader spreader, boolean redstone) {} public void onControlledSpreaderPulse(ItemStack stack, IManaSpreader spreader, boolean redstone) {} - + public int getManaToTransfer(IManaBurst burst, ThrowableEntity entity, ItemStack stack, IManaReceiver receiver) { return burst.getMana(); } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensBounce.java b/src/main/java/vazkii/botania/common/item/lens/LensBounce.java index 6f3c14314..3b90fa82d 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensBounce.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensBounce.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 24, 2015, 4:34:29 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -16,6 +14,7 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.RayTraceResult; + import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.common.core.helper.Vector3; @@ -23,7 +22,7 @@ public class LensBounce extends Lens { @Override public boolean collideBurst(IManaBurst burst, ThrowableEntity entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) { - if(!isManaBlock && pos.getType() == RayTraceResult.Type.BLOCK) { + if (!isManaBlock && pos.getType() == RayTraceResult.Type.BLOCK) { BlockPos coords = burst.getBurstSourceBlockPos(); BlockRayTraceResult rtr = (BlockRayTraceResult) pos; if (!coords.equals(rtr.getPos())) { diff --git a/src/main/java/vazkii/botania/common/item/lens/LensDamage.java b/src/main/java/vazkii/botania/common/item/lens/LensDamage.java index f4530b7f2..42fa3d911 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensDamage.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensDamage.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 24, 2015, 4:37:33 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -16,6 +14,7 @@ import net.minecraft.entity.projectile.ThrowableEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.util.math.AxisAlignedBB; + import vazkii.botania.api.internal.IManaBurst; import java.util.List; @@ -24,19 +23,21 @@ public class LensDamage extends Lens { @Override public void updateBurst(IManaBurst burst, ThrowableEntity entity, ItemStack stack) { - if (entity.world.isRemote) + if (entity.world.isRemote) { return; + } AxisAlignedBB axis = new AxisAlignedBB(entity.getX(), entity.getY(), entity.getZ(), entity.lastTickPosX, entity.lastTickPosY, entity.lastTickPosZ).grow(1); List entities = entity.world.getEntitiesWithinAABB(LivingEntity.class, axis); - for(LivingEntity living : entities) { - if(living instanceof PlayerEntity) + for (LivingEntity living : entities) { + if (living instanceof PlayerEntity) { continue; + } - if(living.hurtTime == 0) { + if (living.hurtTime == 0) { int mana = burst.getMana(); - if(mana >= 16) { + if (mana >= 16) { burst.setMana(mana - 16); - if(!burst.isFake()) { + if (!burst.isFake()) { DamageSource src = entity.getThrower() != null ? DamageSource.causeIndirectMagicDamage(entity, entity.getThrower()) : DamageSource.MAGIC; diff --git a/src/main/java/vazkii/botania/common/item/lens/LensEfficiency.java b/src/main/java/vazkii/botania/common/item/lens/LensEfficiency.java index eaea75604..b7bb8bc5c 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensEfficiency.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensEfficiency.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 24, 2015, 4:34:06 PM (GMT)] */ package vazkii.botania.common.item.lens; import net.minecraft.item.ItemStack; + import vazkii.botania.api.mana.BurstProperties; public class LensEfficiency extends Lens { diff --git a/src/main/java/vazkii/botania/common/item/lens/LensExplosive.java b/src/main/java/vazkii/botania/common/item/lens/LensExplosive.java index 11d64cd4f..2ac00e7ba 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensExplosive.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensExplosive.java @@ -1,13 +1,10 @@ -/** - * This class was created by - . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 24, 2015, 4:41:44 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -18,20 +15,23 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.Explosion; + import vazkii.botania.api.internal.IManaBurst; public class LensExplosive extends Lens { @Override public boolean collideBurst(IManaBurst burst, ThrowableEntity entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) { - if(!entity.world.isRemote && !burst.isFake() && pos.getType() == RayTraceResult.Type.BLOCK) { + if (!entity.world.isRemote && !burst.isFake() && pos.getType() == RayTraceResult.Type.BLOCK) { BlockPos coords = burst.getBurstSourceBlockPos(); - if(!isManaBlock && !coords.equals(((BlockRayTraceResult) pos).getPos())) { + if (!isManaBlock && !coords.equals(((BlockRayTraceResult) pos).getPos())) { Entity cause = entity.getThrower() != null ? entity.getThrower() : entity; entity.world.createExplosion(cause, entity.getX(), entity.getY(), entity.getZ(), burst.getMana() / 50F, Explosion.Mode.BREAK); } - } else dead = false; + } else { + dead = false; + } return dead; } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensFire.java b/src/main/java/vazkii/botania/common/item/lens/LensFire.java index f29ac960a..d598aa92d 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensFire.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensFire.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 24, 2015, 4:46:03 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -18,6 +16,7 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.RayTraceResult; + import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.common.block.ModBlocks; @@ -29,11 +28,11 @@ public class LensFire extends Lens { public boolean collideBurst(IManaBurst burst, ThrowableEntity entity, RayTraceResult rtr, boolean isManaBlock, boolean dead, ItemStack stack) { BlockPos coords = burst.getBurstSourceBlockPos(); - if(!entity.world.isRemote && rtr.getType() == RayTraceResult.Type.BLOCK + if (!entity.world.isRemote && rtr.getType() == RayTraceResult.Type.BLOCK && !burst.isFake() && !isManaBlock) { BlockRayTraceResult brtr = (BlockRayTraceResult) rtr; BlockPos pos = brtr.getPos(); - if(!coords.equals(pos)) { + if (!coords.equals(pos)) { Direction dir = brtr.getFace(); BlockPos offPos = pos.offset(dir); @@ -41,16 +40,18 @@ public class LensFire extends Lens { Block blockAt = entity.world.getBlockState(pos).getBlock(); Block blockAtOffset = entity.world.getBlockState(offPos).getBlock(); - if(blockAt == Blocks.NETHER_PORTAL) + if (blockAt == Blocks.NETHER_PORTAL) { entity.world.setBlockState(pos, Blocks.AIR.getDefaultState()); - if(blockAtOffset == Blocks.NETHER_PORTAL) + } + if (blockAtOffset == Blocks.NETHER_PORTAL) { entity.world.setBlockState(offPos, Blocks.AIR.getDefaultState()); - else if(blockAt == ModBlocks.incensePlate) { + } else if (blockAt == ModBlocks.incensePlate) { TileIncensePlate plate = (TileIncensePlate) entity.world.getTileEntity(pos); plate.ignite(); VanillaPacketDispatcher.dispatchTEToNearbyPlayers(plate); - } else if(blockAtOffset.isAir(entity.world.getBlockState(offPos), entity.world, offPos)) + } else if (blockAtOffset.isAir(entity.world.getBlockState(offPos), entity.world, offPos)) { entity.world.setBlockState(offPos, Blocks.FIRE.getDefaultState()); + } } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensFirework.java b/src/main/java/vazkii/botania/common/item/lens/LensFirework.java index dabcafcfd..2082d6378 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensFirework.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensFirework.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [15/11/2015, 19:12:41 (GMT)] */ package vazkii.botania.common.item.lens; @@ -19,6 +17,7 @@ import net.minecraft.nbt.ListNBT; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.RayTraceResult; + import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.common.core.helper.ItemNBTHelper; @@ -26,9 +25,9 @@ public class LensFirework extends Lens { @Override public boolean collideBurst(IManaBurst burst, ThrowableEntity entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) { - if(!entity.world.isRemote && !burst.isFake()) { + if (!entity.world.isRemote && !burst.isFake()) { BlockPos coords = burst.getBurstSourceBlockPos(); - if(pos.getType() == RayTraceResult.Type.BLOCK + if (pos.getType() == RayTraceResult.Type.BLOCK && !isManaBlock && !((BlockRayTraceResult) pos).getPos().equals(coords)) { ItemStack fireworkStack = generateFirework(burst.getColor()); @@ -36,7 +35,9 @@ public class LensFirework extends Lens { FireworkRocketEntity rocket = new FireworkRocketEntity(entity.world, entity.getX(), entity.getY(), entity.getZ(), fireworkStack); entity.world.addEntity(rocket); } - } else dead = false; + } else { + dead = false; + } return dead; } @@ -48,18 +49,23 @@ public class LensFirework extends Lens { int type = 1; double rand = Math.random(); - if(rand > 0.25) { - if(rand > 0.9) + if (rand > 0.25) { + if (rand > 0.9) { type = 2; - else type = 0; + } else { + type = 0; + } } explosion.putInt("Type", type); - if(Math.random() < 0.05) - if(Math.random() < 0.5) + if (Math.random() < 0.05) { + if (Math.random() < 0.5) { explosion.putBoolean("Flicker", true); - else explosion.putBoolean("Trail", true); + } else { + explosion.putBoolean("Trail", true); + } + } ItemNBTHelper.setCompound(stack, "Explosion", explosion); diff --git a/src/main/java/vazkii/botania/common/item/lens/LensFlare.java b/src/main/java/vazkii/botania/common/item/lens/LensFlare.java index a97091539..f781111ca 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensFlare.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensFlare.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [15/11/2015, 19:13:10 (GMT)] */ package vazkii.botania.common.item.lens; @@ -14,6 +12,7 @@ import net.minecraft.item.DyeColor; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.MathHelper; + import vazkii.botania.api.mana.IManaSpreader; import vazkii.botania.client.fx.WispParticleData; @@ -26,8 +25,9 @@ public class LensFlare extends Lens { @Override public void onControlledSpreaderTick(ItemStack stack, IManaSpreader spreader, boolean redstone) { - if(!redstone) + if (!redstone) { emitParticles(stack, spreader, redstone); + } } @Override @@ -49,9 +49,9 @@ public class LensFlare extends Lens { int hex = -1; TileEntity tile = (TileEntity) spreader; - if(storedColor == 16) { + if (storedColor == 16) { hex = MathHelper.hsvToRGB(tile.getWorld().getGameTime() * 2 % 360 / 360F, 1F, 1F); - } else if(storedColor >= 0) { + } else if (storedColor >= 0) { hex = DyeColor.byId(storedColor).colorValue; } @@ -59,8 +59,8 @@ public class LensFlare extends Lens { float g = ((hex & 0xFF00) >> 8) / 255F; float b = (hex & 0xFF) / 255F; - WispParticleData data = WispParticleData.wisp(0.4F, r, g, b); - tile.getWorld().addParticle(data, tile.getPos().getX() + 0.5, tile.getPos().getY() + 0.5, tile.getPos().getZ() + 0.5, mx, my, mz); - } + WispParticleData data = WispParticleData.wisp(0.4F, r, g, b); + tile.getWorld().addParticle(data, tile.getPos().getX() + 0.5, tile.getPos().getY() + 0.5, tile.getPos().getZ() + 0.5, mx, my, mz); + } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensGravity.java b/src/main/java/vazkii/botania/common/item/lens/LensGravity.java index 6feda7b0d..6ef1bf3dd 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensGravity.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensGravity.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 24, 2015, 4:35:52 PM (GMT)] */ package vazkii.botania.common.item.lens; import net.minecraft.item.ItemStack; + import vazkii.botania.api.mana.BurstProperties; public class LensGravity extends Lens { diff --git a/src/main/java/vazkii/botania/common/item/lens/LensInfluence.java b/src/main/java/vazkii/botania/common/item/lens/LensInfluence.java index 95376615d..7f363e883 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensInfluence.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensInfluence.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 24, 2015, 4:42:33 PM (GMT)] */ package vazkii.botania.common.item.lens; import com.google.common.base.Predicates; + import net.minecraft.entity.Entity; import net.minecraft.entity.item.ExperienceOrbEntity; import net.minecraft.entity.item.FallingBlockEntity; @@ -19,6 +18,7 @@ import net.minecraft.entity.projectile.AbstractArrowEntity; import net.minecraft.entity.projectile.ThrowableEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.math.AxisAlignedBB; + import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.common.item.ModItems; @@ -28,7 +28,7 @@ public class LensInfluence extends Lens { @Override public void updateBurst(IManaBurst burst, ThrowableEntity entity, ItemStack stack) { - if(!burst.isFake()) { + if (!burst.isFake()) { double range = 3.5; AxisAlignedBB bounds = new AxisAlignedBB(entity.getX() - range, entity.getY() - range, entity.getZ() - range, entity.getX() + range, entity.getY() + range, entity.getZ() + range); List movables = entity.world.getEntitiesWithinAABB(ItemEntity.class, bounds); @@ -37,15 +37,17 @@ public class LensInfluence extends Lens { movables.addAll(entity.world.getEntitiesWithinAABB(FallingBlockEntity.class, bounds)); movables.addAll(entity.world.getEntitiesWithinAABB(ThrowableEntity.class, bounds, Predicates.instanceOf(IManaBurst.class))); - for(Entity movable : movables) { - if(movable == burst) + for (Entity movable : movables) { + if (movable == burst) { continue; + } - if(movable instanceof IManaBurst) { + if (movable instanceof IManaBurst) { IManaBurst otherBurst = (IManaBurst) movable; ItemStack lens = otherBurst.getSourceLens(); - if(!lens.isEmpty() && lens.getItem() == ModItems.lensInfluence) + if (!lens.isEmpty() && lens.getItem() == ModItems.lensInfluence) { continue; + } ((IManaBurst) movable).setBurstMotion(entity.getMotion().getX(), entity.getMotion().getY(), entity.getMotion().getZ()); diff --git a/src/main/java/vazkii/botania/common/item/lens/LensLight.java b/src/main/java/vazkii/botania/common/item/lens/LensLight.java index f54ec4723..a79812d7a 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensLight.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensLight.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 24, 2015, 4:47:20 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -19,6 +17,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.RayTraceResult; + import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.tile.TileManaFlame; @@ -28,22 +27,23 @@ public class LensLight extends Lens { @Override public boolean collideBurst(IManaBurst burst, ThrowableEntity entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) { BlockPos coords = burst.getBurstSourceBlockPos(); - if(!entity.world.isRemote && pos.getType() == RayTraceResult.Type.BLOCK && !burst.isFake() && !isManaBlock) { + if (!entity.world.isRemote && pos.getType() == RayTraceResult.Type.BLOCK && !burst.isFake() && !isManaBlock) { BlockRayTraceResult rtr = (BlockRayTraceResult) pos; - if(!coords.equals(rtr.getPos())) { + if (!coords.equals(rtr.getPos())) { BlockPos neighborPos = rtr.getPos().offset(rtr.getFace()); Block blockAt = entity.world.getBlockState(rtr.getPos()).getBlock(); BlockState neighbor = entity.world.getBlockState(neighborPos); - if(blockAt == ModBlocks.manaFlame) + if (blockAt == ModBlocks.manaFlame) { entity.world.setBlockState(rtr.getPos(), Blocks.AIR.getDefaultState()); - else if(neighbor.isAir(entity.world, neighborPos) || neighbor.getMaterial().isReplaceable()) { + } else if (neighbor.isAir(entity.world, neighborPos) || neighbor.getMaterial().isReplaceable()) { entity.world.setBlockState(neighborPos, ModBlocks.manaFlame.getDefaultState()); TileEntity tile = entity.world.getTileEntity(neighborPos); - if(tile instanceof TileManaFlame) + if (tile instanceof TileManaFlame) { ((TileManaFlame) tile).setColor(burst.getColor()); + } } } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensMagnet.java b/src/main/java/vazkii/botania/common/item/lens/LensMagnet.java index 95c45edfa..96f010bda 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensMagnet.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensMagnet.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 24, 2015, 4:39:58 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -14,6 +12,7 @@ import net.minecraft.entity.projectile.ThrowableEntity; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; + import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.api.mana.IManaReceiver; import vazkii.botania.common.core.helper.Vector3; @@ -31,25 +30,26 @@ public class LensMagnet extends Lens { boolean magnetized = entity.getPersistentData().contains(TAG_MAGNETIZED); int range = 3; - magnetize : { + magnetize: { for (BlockPos pos : BlockPos.getAllInBoxMutable(basePos.add(-range, -range, -range), basePos.add(range, range, range))) { - if(entity.world.getTileEntity(pos) instanceof IManaReceiver) { + if (entity.world.getTileEntity(pos) instanceof IManaReceiver) { TileEntity tile = entity.world.getTileEntity(pos); - if(magnetized) { + if (magnetized) { int magX = entity.getPersistentData().getInt(TAG_MAGNETIZED_X); int magY = entity.getPersistentData().getInt(TAG_MAGNETIZED_Y); int magZ = entity.getPersistentData().getInt(TAG_MAGNETIZED_Z); - if(tile.getPos().getX() != magX || tile.getPos().getY() != magY || tile.getPos().getZ() != magZ) + if (tile.getPos().getX() != magX || tile.getPos().getY() != magY || tile.getPos().getZ() != magZ) { continue; + } } IManaReceiver receiver = (IManaReceiver) tile; BlockPos srcCoords = burst.getBurstSourceBlockPos(); - if(tile.getPos().distanceSq(srcCoords) > 9 && receiver.canRecieveManaFromBursts() && !receiver.isFull()) { + if (tile.getPos().distanceSq(srcCoords) > 9 && receiver.canRecieveManaFromBursts() && !receiver.isFull()) { Vector3 burstVec = Vector3.fromEntity(entity); Vector3 tileVec = Vector3.fromTileEntityCenter(tile).add(0, -0.1, 0); Vector3 motionVec = new Vector3(entity.getMotion()); @@ -59,7 +59,7 @@ public class LensMagnet extends Lens { Vector3 differenceVec = normalMotionVec.subtract(magnetVec).multiply(motionVec.mag() * 0.1); Vector3 finalMotionVec = motionVec.subtract(differenceVec); - if(!magnetized) { + if (!magnetized) { finalMotionVec = finalMotionVec.multiply(0.75); entity.getPersistentData().putBoolean(TAG_MAGNETIZED, true); entity.getPersistentData().putInt(TAG_MAGNETIZED_X, tile.getPos().getX()); diff --git a/src/main/java/vazkii/botania/common/item/lens/LensMessenger.java b/src/main/java/vazkii/botania/common/item/lens/LensMessenger.java index 6ba9aa53f..a0187506d 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensMessenger.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensMessenger.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [01/10/2016, 20:37:46 (GMT)] */ package vazkii.botania.common.item.lens; import net.minecraft.item.ItemStack; + import vazkii.botania.api.mana.BurstProperties; public class LensMessenger extends Lens { 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 d6197c1a4..7a920b56f 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensMine.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensMine.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 24, 2015, 4:36:20 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -21,6 +19,7 @@ import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; + import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.api.mana.IManaBlock; import vazkii.botania.common.block.ModBlocks; @@ -34,8 +33,9 @@ public class LensMine extends Lens { public boolean collideBurst(IManaBurst burst, ThrowableEntity entity, RayTraceResult rtr, boolean isManaBlock, boolean dead, ItemStack stack) { World world = entity.world; - if (world.isRemote || rtr.getType() != RayTraceResult.Type.BLOCK) + if (world.isRemote || rtr.getType() != RayTraceResult.Type.BLOCK) { return false; + } BlockPos collidePos = ((BlockRayTraceResult) rtr).getPos(); BlockState state = world.getBlockState(collidePos); @@ -44,8 +44,9 @@ public class LensMine extends Lens { ItemStack composite = ((ItemLens) stack.getItem()).getCompositeLens(stack); boolean warp = !composite.isEmpty() && composite.getItem() == ModItems.lensWarp; - if(warp && (block == ModBlocks.pistonRelay || block == Blocks.PISTON || block == Blocks.MOVING_PISTON || block == Blocks.PISTON_HEAD)) + if (warp && (block == ModBlocks.pistonRelay || block == Blocks.PISTON || block == Blocks.MOVING_PISTON || block == Blocks.PISTON_HEAD)) { return false; + } int harvestLevel = ConfigHandler.COMMON.harvestLevelBore.get(); @@ -56,24 +57,25 @@ public class LensMine extends Lens { int mana = burst.getMana(); BlockPos source = burst.getBurstSourceBlockPos(); - if(!source.equals(collidePos) + if (!source.equals(collidePos) && !(tile instanceof IManaBlock) && neededHarvestLevel <= harvestLevel && hardness != -1 && hardness < 50F && (burst.isFake() || mana >= 24)) { - if(!burst.hasAlreadyCollidedAt(collidePos)) { - if(!burst.isFake()) { + if (!burst.hasAlreadyCollidedAt(collidePos)) { + if (!burst.isFake()) { List items = Block.getDrops(state, (ServerWorld) world, collidePos, tile); world.removeBlock(collidePos, false); - if(ConfigHandler.COMMON.blockBreakParticles.get()) + if (ConfigHandler.COMMON.blockBreakParticles.get()) { world.playEvent(2001, collidePos, Block.getStateId(state)); + } boolean offBounds = source.getY() < 0; boolean doWarp = warp && !offBounds; BlockPos dropCoord = doWarp ? source : collidePos; - for(ItemStack stack_ : items) { + for (ItemStack stack_ : items) { Block.spawnAsEntity(world, dropCoord, stack_); } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensPaint.java b/src/main/java/vazkii/botania/common/item/lens/LensPaint.java index 353255c0f..47c356424 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensPaint.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensPaint.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 24, 2015, 4:44:01 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -22,6 +20,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.EntityRayTraceResult; import net.minecraft.util.math.RayTraceResult; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.common.network.PacketBotaniaEffect; @@ -36,8 +35,8 @@ public class LensPaint extends Lens { @Override public boolean collideBurst(IManaBurst burst, ThrowableEntity entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) { int storedColor = ItemLens.getStoredColor(stack); - if(!entity.world.isRemote && !burst.isFake() && storedColor > -1 && storedColor < 17) { - if(pos.getType() == RayTraceResult.Type.ENTITY + if (!entity.world.isRemote && !burst.isFake() && storedColor > -1 && storedColor < 17) { + if (pos.getType() == RayTraceResult.Type.ENTITY && ((EntityRayTraceResult) pos).getEntity() instanceof SheepEntity) { int r = 20; SheepEntity sheep = (SheepEntity) ((EntityRayTraceResult) pos).getEntity(); @@ -45,42 +44,44 @@ public class LensPaint extends Lens { List sheepList = entity.world.getEntitiesWithinAABB(SheepEntity.class, new AxisAlignedBB(sheep.getX() - r, sheep.getY() - r, sheep.getZ() - r, sheep.getX() + r, sheep.getY() + r, sheep.getZ() + r)); - for(SheepEntity other : sheepList) { - if(other.getFleeceColor() == sheepColor) + for (SheepEntity other : sheepList) { + if (other.getFleeceColor() == sheepColor) { other.setFleeceColor(DyeColor.byId(storedColor == 16 ? other.world.rand.nextInt(16) : storedColor)); + } } dead = true; } else if (pos.getType() == RayTraceResult.Type.BLOCK) { BlockPos hit = ((BlockRayTraceResult) pos).getPos(); BlockState state = entity.world.getBlockState(hit); Block block = state.getBlock(); - if(BotaniaAPI.paintableBlocks.containsKey(block.delegate)) { + if (BotaniaAPI.paintableBlocks.containsKey(block.delegate)) { List coordsToPaint = new ArrayList<>(); List coordsFound = new ArrayList<>(); coordsFound.add(hit); do { List iterCoords = new ArrayList<>(coordsFound); - for(BlockPos coords : iterCoords) { + for (BlockPos coords : iterCoords) { coordsFound.remove(coords); coordsToPaint.add(coords); - for(Direction dir : Direction.values()) { + for (Direction dir : Direction.values()) { BlockState state_ = entity.world.getBlockState(coords.offset(dir)); BlockPos coords_ = new BlockPos(coords.offset(dir)); - if(state_ == state && !coordsFound.contains(coords_) && !coordsToPaint.contains(coords_)) + if (state_ == state && !coordsFound.contains(coords_) && !coordsToPaint.contains(coords_)) { coordsFound.add(coords_); + } } } - } while(!coordsFound.isEmpty() && coordsToPaint.size() < 1000); + } while (!coordsFound.isEmpty() && coordsToPaint.size() < 1000); - for(BlockPos coords : coordsToPaint) { + for (BlockPos coords : coordsToPaint) { DyeColor placeColor = DyeColor.byId(storedColor == 16 ? entity.world.rand.nextInt(16) : storedColor); BlockState stateThere = entity.world.getBlockState(coords); Function f = BotaniaAPI.paintableBlocks.get(block.delegate); Block newBlock = f.apply(placeColor); - if(newBlock != stateThere.getBlock()) { + if (newBlock != stateThere.getBlock()) { entity.world.setBlockState(coords, newBlock.getDefaultState()); PacketHandler.sendToNearby(entity.world, coords, new PacketBotaniaEffect(PacketBotaniaEffect.EffectType.PAINT_LENS, coords.getX(), coords.getY(), coords.getZ(), placeColor.getId())); diff --git a/src/main/java/vazkii/botania/common/item/lens/LensPhantom.java b/src/main/java/vazkii/botania/common/item/lens/LensPhantom.java index 5173a600c..75ea41a31 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensPhantom.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensPhantom.java @@ -1,25 +1,24 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 24, 2015, 4:39:24 PM (GMT)] */ package vazkii.botania.common.item.lens; import net.minecraft.entity.projectile.ThrowableEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.math.RayTraceResult; + import vazkii.botania.api.internal.IManaBurst; public class LensPhantom extends Lens { @Override public boolean collideBurst(IManaBurst burst, ThrowableEntity entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) { - if(!isManaBlock) { + if (!isManaBlock) { dead = false; burst.setMinManaLoss(Math.max(0, burst.getMinManaLoss() - 4)); } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensPiston.java b/src/main/java/vazkii/botania/common/item/lens/LensPiston.java index 3d199283a..3e470e460 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensPiston.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensPiston.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 24, 2015, 4:46:39 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -19,6 +17,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.RayTraceResult; + import vazkii.botania.api.internal.IManaBurst; public class LensPiston extends Lens { @@ -26,19 +25,19 @@ public class LensPiston extends Lens { @Override public boolean collideBurst(IManaBurst burst, ThrowableEntity entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) { BlockPos coords = burst.getBurstSourceBlockPos(); - if(!entity.world.isRemote + if (!entity.world.isRemote && pos.getType() == RayTraceResult.Type.BLOCK && !burst.isFake() && !isManaBlock) { BlockRayTraceResult rtr = (BlockRayTraceResult) pos; - if(!coords.equals(rtr.getPos())) { + if (!coords.equals(rtr.getPos())) { BlockPos pos_ = rtr.getPos().offset(rtr.getFace().getOpposite()); - if(entity.world.isAirBlock(pos_) || entity.world.getBlockState(pos_).getMaterial().isReplaceable()) { + if (entity.world.isAirBlock(pos_) || entity.world.getBlockState(pos_).getMaterial().isReplaceable()) { BlockState state = entity.world.getBlockState(rtr.getPos()); TileEntity tile = entity.world.getTileEntity(rtr.getPos()); - if(state.getPushReaction() == PushReaction.NORMAL && state.getBlock() != Blocks.OBSIDIAN + if (state.getPushReaction() == PushReaction.NORMAL && state.getBlock() != Blocks.OBSIDIAN && state.getBlockHardness(entity.world, pos_) >= 0 && tile == null) { entity.world.destroyBlock(rtr.getPos(), false); entity.world.setBlockState(pos_, state); diff --git a/src/main/java/vazkii/botania/common/item/lens/LensPower.java b/src/main/java/vazkii/botania/common/item/lens/LensPower.java index 185c0a192..670eba7b2 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensPower.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensPower.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 24, 2015, 4:33:14 PM (GMT)] */ package vazkii.botania.common.item.lens; import net.minecraft.item.ItemStack; + import vazkii.botania.api.mana.BurstProperties; public class LensPower extends Lens { diff --git a/src/main/java/vazkii/botania/common/item/lens/LensRedirect.java b/src/main/java/vazkii/botania/common/item/lens/LensRedirect.java index 935339c1e..fd7c819c6 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensRedirect.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensRedirect.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [15/11/2015, 19:13:03 (GMT)] */ package vazkii.botania.common.item.lens; @@ -18,6 +16,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.shapes.VoxelShape; + import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.api.mana.IDirectioned; import vazkii.botania.api.mana.IThrottledPacket; @@ -28,45 +27,50 @@ public class LensRedirect extends Lens { @Override public boolean collideBurst(IManaBurst burst, ThrowableEntity entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) { BlockPos coords = burst.getBurstSourceBlockPos(); - if(!entity.world.isRemote && pos.getType() == RayTraceResult.Type.BLOCK + if (!entity.world.isRemote && pos.getType() == RayTraceResult.Type.BLOCK && coords.getY() != -1 && !((BlockRayTraceResult) pos).getPos().equals(coords)) { TileEntity tile = entity.world.getTileEntity(((BlockRayTraceResult) pos).getPos()); - if(tile instanceof IDirectioned) { - if(!burst.isFake()) { + if (tile instanceof IDirectioned) { + if (!burst.isFake()) { IDirectioned redir = (IDirectioned) tile; Vector3 tileVec = Vector3.fromTileEntityCenter(tile); Vector3 sourceVec = new Vector3(coords.getX() + 0.5, coords.getY() + 0.5, coords.getZ() + 0.5); - AxisAlignedBB axis; VoxelShape collideShape = entity.world.getBlockState(coords).getCollisionShape(entity.world, coords); - if(collideShape.isEmpty()) + if (collideShape.isEmpty()) { axis = new AxisAlignedBB(coords, coords.add(1, 1, 1)); - else axis = collideShape.getBoundingBox().offset(coords); // todo 1.13 more granular collisions? + } else { + axis = collideShape.getBoundingBox().offset(coords); // todo 1.13 more granular collisions? + } - if(!sourceVec.isInside(axis)) + if (!sourceVec.isInside(axis)) { sourceVec = new Vector3(axis.minX + (axis.maxX - axis.minX) / 2, axis.minY + (axis.maxY - axis.minY) / 2, axis.minZ + (axis.maxZ - axis.minZ) / 2); + } - Vector3 diffVec = sourceVec.subtract(tileVec); + Vector3 diffVec = sourceVec.subtract(tileVec); Vector3 diffVec2D = new Vector3(diffVec.x, diffVec.z, 0); Vector3 rotVec = new Vector3(0, 1, 0); double angle = rotVec.angle(diffVec2D) / Math.PI * 180.0; - if(sourceVec.x < tileVec.x) + if (sourceVec.x < tileVec.x) { angle = -angle; + } redir.setRotationX((float) angle + 90F); rotVec = new Vector3(diffVec.x, 0, diffVec.z); angle = diffVec.angle(rotVec) * 180F / Math.PI; - if(sourceVec.y < tileVec.y) + if (sourceVec.y < tileVec.y) { angle = -angle; + } redir.setRotationY((float) angle); redir.commitRedirection(); - if(redir instanceof IThrottledPacket) + if (redir instanceof IThrottledPacket) { ((IThrottledPacket) redir).markDispatchable(); + } } } } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensSpeed.java b/src/main/java/vazkii/botania/common/item/lens/LensSpeed.java index 0a590589f..3816899a0 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensSpeed.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensSpeed.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 24, 2015, 4:32:47 PM (GMT)] */ package vazkii.botania.common.item.lens; import net.minecraft.item.ItemStack; + import vazkii.botania.api.mana.BurstProperties; public class LensSpeed extends Lens { diff --git a/src/main/java/vazkii/botania/common/item/lens/LensStorm.java b/src/main/java/vazkii/botania/common/item/lens/LensStorm.java index 89c618e52..ea3b9b904 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensStorm.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensStorm.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 25, 2015, 2:10:26 AM (GMT)] */ package vazkii.botania.common.item.lens; @@ -16,19 +14,23 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.Explosion; + import vazkii.botania.api.internal.IManaBurst; public class LensStorm extends Lens { @Override public boolean collideBurst(IManaBurst burst, ThrowableEntity entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) { - if(!entity.world.isRemote && !burst.isFake()) { + if (!entity.world.isRemote && !burst.isFake()) { BlockPos coords = burst.getBurstSourceBlockPos(); - if(pos.getType() == RayTraceResult.Type.BLOCK + if (pos.getType() == RayTraceResult.Type.BLOCK && !isManaBlock - && !coords.equals(((BlockRayTraceResult) pos).getPos())) + && !coords.equals(((BlockRayTraceResult) pos).getPos())) { entity.world.createExplosion(entity, entity.getX(), entity.getY(), entity.getZ(), 5F, Explosion.Mode.DESTROY); - } else dead = false; + } + } else { + dead = false; + } return dead; } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensTime.java b/src/main/java/vazkii/botania/common/item/lens/LensTime.java index a7b56559c..0c5524c6d 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensTime.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensTime.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 24, 2015, 4:33:41 PM (GMT)] */ package vazkii.botania.common.item.lens; import net.minecraft.item.ItemStack; + import vazkii.botania.api.mana.BurstProperties; public class LensTime extends Lens { diff --git a/src/main/java/vazkii/botania/common/item/lens/LensTripwire.java b/src/main/java/vazkii/botania/common/item/lens/LensTripwire.java index 48c32d870..2e57836d9 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensTripwire.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensTripwire.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [02/10/2016, 18:27:42 (GMT)] */ package vazkii.botania.common.item.lens; @@ -15,6 +13,7 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.entity.projectile.ThrowableEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.math.AxisAlignedBB; + import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.api.mana.IManaSpreader; @@ -33,13 +32,14 @@ public class LensTripwire extends Lens { @Override public void updateBurst(IManaBurst burst, ThrowableEntity entity, ItemStack stack) { - if(burst.isFake()) { - if(entity.world.isRemote) + if (burst.isFake()) { + if (entity.world.isRemote) { return; + } AxisAlignedBB axis = new AxisAlignedBB(entity.getX(), entity.getY(), entity.getZ(), entity.lastTickPosX, entity.lastTickPosY, entity.lastTickPosZ).grow(0.25); List entities = entity.world.getEntitiesWithinAABB(LivingEntity.class, axis); - if(!entities.isEmpty()) { + if (!entities.isEmpty()) { Entity e = (Entity) burst; e.getPersistentData().putBoolean(TAG_TRIPPED, true); } diff --git a/src/main/java/vazkii/botania/common/item/lens/LensWarp.java b/src/main/java/vazkii/botania/common/item/lens/LensWarp.java index 3d35fbab7..d79a2778b 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensWarp.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensWarp.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 8, 2015, 2:17:01 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -15,29 +13,29 @@ import net.minecraft.entity.projectile.ThrowableEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.GlobalPos; import net.minecraft.util.math.RayTraceResult; + import vazkii.botania.api.internal.IManaBurst; -import vazkii.botania.api.mana.IManaReceiver; import vazkii.botania.common.block.BlockPistonRelay; import vazkii.botania.common.block.ModBlocks; public class LensWarp extends Lens { public static final String TAG_WARPED = "botania:warped"; - + @Override public boolean collideBurst(IManaBurst burst, ThrowableEntity entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) { - if(burst.isFake() || pos.getType() != RayTraceResult.Type.BLOCK) + if (burst.isFake() || pos.getType() != RayTraceResult.Type.BLOCK) { return dead; + } BlockPos hit = ((BlockRayTraceResult) pos).getPos(); Block block = entity.world.getBlockState(hit).getBlock(); - if(block == ModBlocks.pistonRelay) { + if (block == ModBlocks.pistonRelay) { BlockPistonRelay.WorldData data = BlockPistonRelay.WorldData.get(entity.world); BlockPos dest = data.mapping.get(hit); - if(dest != null) { + if (dest != null) { entity.setPosition(dest.getX() + 0.5, dest.getY() + 0.5, dest.getZ() + 0.5); burst.setCollidedAt(dest); diff --git a/src/main/java/vazkii/botania/common/item/lens/LensWeight.java b/src/main/java/vazkii/botania/common/item/lens/LensWeight.java index d3712bf31..2d0dbccc6 100644 --- a/src/main/java/vazkii/botania/common/item/lens/LensWeight.java +++ b/src/main/java/vazkii/botania/common/item/lens/LensWeight.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 24, 2015, 4:43:16 PM (GMT)] */ package vazkii.botania.common.item.lens; @@ -21,13 +19,14 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.server.ServerWorld; + import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.common.core.handler.ConfigHandler; public class LensWeight extends Lens { @Override public boolean collideBurst(IManaBurst burst, ThrowableEntity entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) { - if(!entity.world.isRemote && !burst.isFake() && pos.getType() == RayTraceResult.Type.BLOCK) { + if (!entity.world.isRemote && !burst.isFake() && pos.getType() == RayTraceResult.Type.BLOCK) { int harvestLevel = ConfigHandler.COMMON.harvestLevelWeight.get(); BlockPos bPos = ((BlockRayTraceResult) pos).getPos(); @@ -35,7 +34,7 @@ public class LensWeight extends Lens { BlockState state = entity.world.getBlockState(bPos); int neededHarvestLevel = block.getHarvestLevel(state); - if(entity.world.isAirBlock(bPos.down()) + if (entity.world.isAirBlock(bPos.down()) && state.getBlockHardness(entity.world, bPos) != -1 && neededHarvestLevel <= harvestLevel && entity.world.getTileEntity(bPos) == null) { diff --git a/src/main/java/vazkii/botania/common/item/material/ItemDye.java b/src/main/java/vazkii/botania/common/item/material/ItemDye.java index f2d8c5260..3d8655ddd 100644 --- a/src/main/java/vazkii/botania/common/item/material/ItemDye.java +++ b/src/main/java/vazkii/botania/common/item/material/ItemDye.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 19, 2014, 4:10:47 PM (GMT)] */ package vazkii.botania.common.item.material; @@ -23,9 +21,9 @@ import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import vazkii.botania.api.ColorHelper; import vazkii.botania.api.mana.IManaPool; -import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.item.Item16Colors; import javax.annotation.Nonnull; @@ -44,16 +42,16 @@ public class ItemDye extends Item16Colors { BlockPos pos = ctx.getPos(); Block block = world.getBlockState(pos).getBlock(); - if(shouldRecolor(block)) { + if (shouldRecolor(block)) { world.setBlockState(pos, recolor(block, color)); stack.shrink(1); return ActionResultType.SUCCESS; } TileEntity tile = world.getTileEntity(pos); - if(tile instanceof IManaPool) { + if (tile instanceof IManaPool) { IManaPool pool = (IManaPool) tile; - if(color != pool.getColor()) { + if (color != pool.getColor()) { pool.setColor(color); stack.shrink(1); return ActionResultType.SUCCESS; @@ -65,10 +63,10 @@ public class ItemDye extends Item16Colors { @Override public boolean itemInteractionForEntity(ItemStack stack, PlayerEntity player, LivingEntity target, Hand hand) { - if(target instanceof SheepEntity) { - SheepEntity entitysheep = (SheepEntity)target; + if (target instanceof SheepEntity) { + SheepEntity entitysheep = (SheepEntity) target; - if(!entitysheep.getSheared() && entitysheep.getFleeceColor() != color) { + if (!entitysheep.getSheared() && entitysheep.getFleeceColor() != color) { entitysheep.setFleeceColor(color); stack.shrink(1); } @@ -80,12 +78,14 @@ public class ItemDye extends Item16Colors { private boolean shouldRecolor(Block block) { DyeColor woolColor = ColorHelper.WOOL_MAP.inverse().get(block.delegate); - if(woolColor != null) + if (woolColor != null) { return woolColor != this.color; + } DyeColor carpetColor = ColorHelper.CARPET_MAP.inverse().get(block.delegate); - if(carpetColor != null) + if (carpetColor != null) { return carpetColor != this.color; + } return false; } diff --git a/src/main/java/vazkii/botania/common/item/material/ItemEnderAir.java b/src/main/java/vazkii/botania/common/item/material/ItemEnderAir.java index 101d9eabc..bfb1c11a7 100644 --- a/src/main/java/vazkii/botania/common/item/material/ItemEnderAir.java +++ b/src/main/java/vazkii/botania/common/item/material/ItemEnderAir.java @@ -1,6 +1,15 @@ +/* + * This class is 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 + */ package vazkii.botania.common.item.material; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.util.ActionResult; @@ -14,8 +23,8 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.items.ItemHandlerHelper; + import vazkii.botania.common.entity.EntityEnderAirBottle; -import net.minecraft.item.Item; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibMisc; @@ -23,49 +32,51 @@ import javax.annotation.Nonnull; @Mod.EventBusSubscriber(modid = LibMisc.MOD_ID) public class ItemEnderAir extends Item { - public ItemEnderAir(Properties props) { - super(props); - } + public ItemEnderAir(Properties props) { + super(props); + } - @SubscribeEvent - public static void onPlayerInteract(PlayerInteractEvent.RightClickBlock event) { - ItemStack stack = event.getItemStack(); - boolean correctStack = !stack.isEmpty() && stack.getItem() == Items.GLASS_BOTTLE; - boolean ender = event.getWorld().getDimension() instanceof EndDimension; + @SubscribeEvent + public static void onPlayerInteract(PlayerInteractEvent.RightClickBlock event) { + ItemStack stack = event.getItemStack(); + boolean correctStack = !stack.isEmpty() && stack.getItem() == Items.GLASS_BOTTLE; + boolean ender = event.getWorld().getDimension() instanceof EndDimension; - if(correctStack && ender) { - if (event.getWorld().isRemote) { - event.getPlayer().swingArm(event.getHand()); - } else { - ItemStack stack1 = new ItemStack(ModItems.enderAirBottle); + if (correctStack && ender) { + if (event.getWorld().isRemote) { + event.getPlayer().swingArm(event.getHand()); + } else { + ItemStack stack1 = new ItemStack(ModItems.enderAirBottle); - ItemHandlerHelper.giveItemToPlayer(event.getPlayer(), stack1); + ItemHandlerHelper.giveItemToPlayer(event.getPlayer(), stack1); - stack.shrink(1); + stack.shrink(1); - event.getWorld().playSound(null, event.getPos(), SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.5F, 1F); - } + event.getWorld().playSound(null, event.getPos(), SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.5F, 1F); + } - event.setCanceled(true); - event.setCancellationResult(ActionResultType.SUCCESS); - } - } + event.setCanceled(true); + event.setCancellationResult(ActionResultType.SUCCESS); + } + } - @Nonnull - @Override - public ActionResult onItemRightClick(World world, PlayerEntity player, @Nonnull Hand hand) { - ItemStack stack = player.getHeldItem(hand); - if(!player.abilities.isCreativeMode) - stack.shrink(1); + @Nonnull + @Override + public ActionResult onItemRightClick(World world, PlayerEntity player, @Nonnull Hand hand) { + ItemStack stack = player.getHeldItem(hand); + if (!player.abilities.isCreativeMode) { + stack.shrink(1); + } - world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F)); + world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F)); - if(!world.isRemote) { - EntityEnderAirBottle b = new EntityEnderAirBottle(player, world); - b.shoot(player, player.rotationPitch, player.rotationYaw, 0F, 1.5F, 1F); - world.addEntity(b); - } - else player.swingArm(hand); - return ActionResult.success(stack); - } + if (!world.isRemote) { + EntityEnderAirBottle b = new EntityEnderAirBottle(player, world); + b.shoot(player, player.rotationPitch, player.rotationYaw, 0F, 1.5F, 1F); + world.addEntity(b); + } else { + player.swingArm(hand); + } + return ActionResult.success(stack); + } } diff --git a/src/main/java/vazkii/botania/common/item/material/ItemManaResource.java b/src/main/java/vazkii/botania/common/item/material/ItemManaResource.java index bba5b1ec6..099810dcf 100644 --- a/src/main/java/vazkii/botania/common/item/material/ItemManaResource.java +++ b/src/main/java/vazkii/botania/common/item/material/ItemManaResource.java @@ -1,21 +1,20 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 30, 2014, 4:49:16 PM (GMT)] */ package vazkii.botania.common.item.material; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; import net.minecraft.item.Items; import net.minecraft.util.ActionResultType; + import vazkii.botania.common.entity.EntityDoppleganger; -import net.minecraft.item.Item; import vazkii.botania.common.item.ModItems; import javax.annotation.Nonnull; @@ -30,9 +29,9 @@ public class ItemManaResource extends Item { public ActionResultType onItemUse(ItemUseContext ctx) { ItemStack stack = ctx.getItem(); - if(this == ModItems.terrasteel || this == ModItems.gaiaIngot) + if (this == ModItems.terrasteel || this == ModItems.gaiaIngot) { return EntityDoppleganger.spawn(ctx.getPlayer(), stack, ctx.getWorld(), ctx.getPos(), this == ModItems.gaiaIngot) ? ActionResultType.SUCCESS : ActionResultType.FAIL; - else if(this == ModItems.livingroot) { + } else if (this == ModItems.livingroot) { return Items.BONE_MEAL.onItemUse(ctx); } diff --git a/src/main/java/vazkii/botania/common/item/material/ItemPetal.java b/src/main/java/vazkii/botania/common/item/material/ItemPetal.java index 30c9e6f4f..dfa189737 100644 --- a/src/main/java/vazkii/botania/common/item/material/ItemPetal.java +++ b/src/main/java/vazkii/botania/common/item/material/ItemPetal.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 19, 2014, 3:28:21 PM (GMT)] */ package vazkii.botania.common.item.material; @@ -14,6 +12,7 @@ import net.minecraft.block.Block; import net.minecraft.item.BlockItem; import net.minecraft.item.DyeColor; import net.minecraft.item.ItemStack; + import vazkii.botania.api.recipe.ICustomApothecaryColor; import javax.annotation.Nonnull; diff --git a/src/main/java/vazkii/botania/common/item/material/ItemRune.java b/src/main/java/vazkii/botania/common/item/material/ItemRune.java index 2136ae50a..e0f3237b4 100644 --- a/src/main/java/vazkii/botania/common/item/material/ItemRune.java +++ b/src/main/java/vazkii/botania/common/item/material/ItemRune.java @@ -1,19 +1,17 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Feb 7, 2014, 9:46:24 PM (GMT)] */ package vazkii.botania.common.item.material; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; + import vazkii.botania.api.recipe.ICustomApothecaryColor; -import net.minecraft.item.Item; public class ItemRune extends Item implements ICustomApothecaryColor { diff --git a/src/main/java/vazkii/botania/common/item/material/ItemSelfReturning.java b/src/main/java/vazkii/botania/common/item/material/ItemSelfReturning.java index e15dd5add..ae0221210 100644 --- a/src/main/java/vazkii/botania/common/item/material/ItemSelfReturning.java +++ b/src/main/java/vazkii/botania/common/item/material/ItemSelfReturning.java @@ -1,18 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 19, 2014, 7:00:34 PM (GMT)] */ package vazkii.botania.common.item.material; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.item.Item; public class ItemSelfReturning extends Item { diff --git a/src/main/java/vazkii/botania/common/item/record/ItemModRecord.java b/src/main/java/vazkii/botania/common/item/record/ItemModRecord.java index d1736340b..a5dd06d55 100644 --- a/src/main/java/vazkii/botania/common/item/record/ItemModRecord.java +++ b/src/main/java/vazkii/botania/common/item/record/ItemModRecord.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 11, 2015, 9:56:00 PM (GMT)] */ package vazkii.botania.common.item.record; diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemDice.java b/src/main/java/vazkii/botania/common/item/relic/ItemDice.java index c4d42febf..7fe8df8dd 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemDice.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemDice.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 30, 2015, 6:52:35 PM (GMT)] */ package vazkii.botania.common.item.relic; @@ -16,20 +14,20 @@ import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; -import net.minecraft.util.text.Style; import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.fml.server.ServerLifecycleHooks; + import vazkii.botania.api.item.IRelic; import vazkii.botania.common.item.ModItems; import javax.annotation.Nonnull; + import java.util.ArrayList; import java.util.List; @@ -39,7 +37,7 @@ public class ItemDice extends ItemRelic { } public static Item[] getRelics() { - return new Item[]{ + return new Item[] { ModItems.infiniteFruit, ModItems.kingKey, ModItems.flugelEye, @@ -54,19 +52,21 @@ public class ItemDice extends ItemRelic { public ActionResult onItemRightClick(World world, PlayerEntity player, @Nonnull Hand hand) { ItemStack stack = player.getHeldItem(hand); - if(isRightPlayer(player, stack)) { - if(world.isRemote) + if (isRightPlayer(player, stack)) { + if (world.isRemote) { return ActionResult.success(stack); + } world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); List possible = new ArrayList<>(); - for(int i = 0; i < 6; i++) { - if(!hasRelicAlready(player, i)) + for (int i = 0; i < 6; i++) { + if (!hasRelicAlready(player, i)) { possible.add(i); + } } - if(possible.isEmpty()) { + if (possible.isEmpty()) { player.sendMessage(new TranslationTextComponent("botaniamisc.dudDiceRoll", world.rand.nextInt(6) + 1).applyTextStyle(TextFormatting.DARK_GREEN)); stack.shrink(1); return ActionResult.success(stack); @@ -86,14 +86,15 @@ public class ItemDice extends ItemRelic { } private boolean hasRelicAlready(PlayerEntity player, int relic) { - if(relic < 0 || relic > 6 || !(player instanceof ServerPlayerEntity)) + if (relic < 0 || relic > 6 || !(player instanceof ServerPlayerEntity)) { return true; + } ServerPlayerEntity mpPlayer = (ServerPlayerEntity) player; Item item = getRelics()[relic]; ResourceLocation advId = ((IRelic) item).getAdvancement(); - if(advId != null) { + if (advId != null) { Advancement adv = ServerLifecycleHooks.getCurrentServer().getAdvancementManager().getAdvancement(advId); return adv != null && mpPlayer.getAdvancements().getProgress(adv).isDone(); } diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemFlugelEye.java b/src/main/java/vazkii/botania/common/item/relic/ItemFlugelEye.java index ab4017111..4aa4939c3 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemFlugelEye.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemFlugelEye.java @@ -1,20 +1,18 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 29, 2015, 10:13:26 PM (GMT)] */ package vazkii.botania.common.item.relic; import com.mojang.datafixers.Dynamic; + import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; import net.minecraft.item.UseAction; @@ -29,7 +27,7 @@ import net.minecraft.util.SoundEvents; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.GlobalPos; import net.minecraft.world.World; -import net.minecraft.world.dimension.DimensionType; + import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.api.wand.ICoordBoundItem; @@ -57,9 +55,9 @@ public class ItemFlugelEye extends ItemRelic implements ICoordBoundItem, IManaUs BlockPos pos = ctx.getPos(); PlayerEntity player = ctx.getPlayer(); - if(player != null && player.isSneaking()) { - if(world.isRemote) { - for(int i = 0; i < 10; i++) { + if (player != null && player.isSneaking()) { + if (world.isRemote) { + for (int i = 0; i < 10; i++) { float x1 = (float) (pos.getX() + Math.random()); float y1 = pos.getY() + 1; float z1 = (float) (pos.getZ() + Math.random()); @@ -86,7 +84,7 @@ public class ItemFlugelEye extends ItemRelic implements ICoordBoundItem, IManaUs float z = (float) (living.getZ() - Math.random() * living.getWidth()); WispParticleData data = WispParticleData.wisp((float) Math.random() * 0.7F, (float) Math.random(), (float) Math.random(), (float) Math.random(), 1); living.world.addParticle(data, x, y, z, 0, 0.05F + (float) Math.random() * 0.05F, 0); - } + } @Nonnull @Override @@ -99,8 +97,9 @@ public class ItemFlugelEye extends ItemRelic implements ICoordBoundItem, IManaUs @Override public ItemStack onItemUseFinish(@Nonnull ItemStack stack, World world, LivingEntity living) { INBT nbt = ItemNBTHelper.get(stack, TAG_LOCATION); - if(nbt == null) + if (nbt == null) { return stack; + } GlobalPos loc = GlobalPos.deserialize(new Dynamic<>(NBTDynamicOps.INSTANCE, nbt)); int x = loc.getPos().getX(); int y = loc.getPos().getY(); @@ -108,8 +107,8 @@ public class ItemFlugelEye extends ItemRelic implements ICoordBoundItem, IManaUs int cost = (int) (MathHelper.pointDistanceSpace(x + 0.5, y + 0.5, z + 0.5, living.getX(), living.getY(), living.getZ()) * 10); - if(loc.getDimension() == world.getDimension().getType() - && (!(living instanceof PlayerEntity) || ManaItemHandler.requestManaExact(stack, (PlayerEntity) living, cost, true))) { + if (loc.getDimension() == world.getDimension().getType() + && (!(living instanceof PlayerEntity) || ManaItemHandler.requestManaExact(stack, (PlayerEntity) living, cost, true))) { moveParticlesAndSound(living); living.setPositionAndUpdate(x + 0.5, y + 1.5, z + 0.5); moveParticlesAndSound(living); @@ -137,8 +136,9 @@ public class ItemFlugelEye extends ItemRelic implements ICoordBoundItem, IManaUs @Override public BlockPos getBinding(ItemStack stack) { INBT nbt = ItemNBTHelper.get(stack, TAG_LOCATION); - if(nbt != null) + if (nbt != null) { return GlobalPos.deserialize(new Dynamic<>(NBTDynamicOps.INSTANCE, nbt)).getPos(); + } return null; } diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemInfiniteFruit.java b/src/main/java/vazkii/botania/common/item/relic/ItemInfiniteFruit.java index c4c298efa..fa463c465 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemInfiniteFruit.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemInfiniteFruit.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 29, 2015, 10:12:55 PM (GMT)] */ package vazkii.botania.common.item.relic; @@ -15,15 +13,16 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.UseAction; import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.Locale; public class ItemInfiniteFruit extends ItemRelic implements IManaUsingItem { @@ -48,7 +47,7 @@ public class ItemInfiniteFruit extends ItemRelic implements IManaUsingItem { @Override public ActionResult onItemRightClick(World world, PlayerEntity player, @Nonnull Hand hand) { ItemStack stack = player.getHeldItem(hand); - if(player.canEat(false) && isRightPlayer(player, stack)) { + if (player.canEat(false) && isRightPlayer(player, stack)) { player.setActiveHand(hand); return ActionResult.success(stack); } @@ -58,16 +57,20 @@ public class ItemInfiniteFruit extends ItemRelic implements IManaUsingItem { @Override public void onUsingTick(ItemStack stack, LivingEntity living, int count) { super.onUsingTick(stack, living, count); - if(!(living instanceof PlayerEntity)) + if (!(living instanceof PlayerEntity)) { return; + } PlayerEntity player = (PlayerEntity) living; - if(ManaItemHandler.requestManaExact(stack, player, 500, true)) { - if(count % 5 == 0) + if (ManaItemHandler.requestManaExact(stack, player, 500, true)) { + if (count % 5 == 0) { player.getFoodStats().addStats(1, 1F); + } - if(count == 5) - if(player.canEat(false)) + if (count == 5) { + if (player.canEat(false)) { player.activeItemStackUseCount = 20; + } + } } } diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemKingKey.java b/src/main/java/vazkii/botania/common/item/relic/ItemKingKey.java index ca26a4c19..c20d42737 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemKingKey.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemKingKey.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 16, 2015, 2:54:35 PM (GMT)] */ package vazkii.botania.common.item.relic; @@ -15,11 +13,11 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.UseAction; import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; + import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.common.core.handler.ModSounds; @@ -29,6 +27,7 @@ import vazkii.botania.common.entity.EntityBabylonWeapon; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.util.Random; public class ItemKingKey extends ItemRelic implements IManaUsingItem { @@ -54,7 +53,7 @@ public class ItemKingKey extends ItemRelic implements IManaUsingItem { @Override public void onPlayerStoppedUsing(ItemStack stack, World world, LivingEntity living, int time) { int spawned = getWeaponsSpawned(stack); - if(spawned == 20) { + if (spawned == 20) { setCharging(stack, false); setWeaponsSpawned(stack, 0); } @@ -64,13 +63,14 @@ public class ItemKingKey extends ItemRelic implements IManaUsingItem { public void onUsingTick(ItemStack stack, LivingEntity living, int count) { int spawned = getWeaponsSpawned(stack); - if(count != getUseDuration(stack) && spawned < 20 && !living.world.isRemote && (!(living instanceof PlayerEntity) || ManaItemHandler.requestManaExact(stack, (PlayerEntity) living, 150, true))) { + if (count != getUseDuration(stack) && spawned < 20 && !living.world.isRemote && (!(living instanceof PlayerEntity) || ManaItemHandler.requestManaExact(stack, (PlayerEntity) living, 150, true))) { Vector3 look = new Vector3(living.getLookVec()).multiply(1, 0, 1); - + double playerRot = Math.toRadians(living.rotationYaw + 90); - if(look.x == 0 && look.z == 0) + if (look.x == 0 && look.z == 0) { look = new Vector3(Math.cos(playerRot), 0, Math.sin(playerRot)); - + } + look = look.normalize().multiply(-2); int div = spawned / 5; @@ -84,8 +84,9 @@ public class ItemKingKey extends ItemRelic implements IManaUsingItem { double rot = mod * Math.PI / 4 - Math.PI / 2; Vector3 axis1 = axis.multiply(div * 3.5 + 5).rotate(rot, look); - if(axis1.y < 0) + if (axis1.y < 0) { axis1 = axis1.multiply(1, -1, 1); + } Vector3 end = pl.add(axis1); @@ -113,7 +114,6 @@ public class ItemKingKey extends ItemRelic implements IManaUsingItem { return 72000; } - public static boolean isCharging(ItemStack stack) { return ItemNBTHelper.getBoolean(stack, TAG_CHARGING, false); } diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemLokiRing.java b/src/main/java/vazkii/botania/common/item/relic/ItemLokiRing.java index 1612718e4..0f22d7b16 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemLokiRing.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemLokiRing.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 29, 2015, 10:13:32 PM (GMT)] */ package vazkii.botania.common.item.relic; import com.google.common.collect.ImmutableList; + import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.entity.LivingEntity; @@ -33,6 +32,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.api.item.ISequentialBreaker; import vazkii.botania.api.item.IWireframeCoordinateListProvider; import vazkii.botania.api.mana.IManaUsingItem; @@ -69,27 +69,29 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat public static void onPlayerInteract(PlayerInteractEvent.RightClickBlock event) { PlayerEntity player = event.getPlayer(); ItemStack lokiRing = getLokiRing(player); - if(lokiRing.isEmpty() || !player.isSneaking()) + if (lokiRing.isEmpty() || !player.isSneaking()) { return; + } ItemStack stack = event.getItemStack(); BlockRayTraceResult lookPos = ToolCommons.raytraceFromEntity(player, 10F, true); List cursors = getCursorList(lokiRing); int cost = Math.min(cursors.size(), (int) Math.pow(Math.E, cursors.size() * 0.25)); - if(lookPos.getType() != RayTraceResult.Type.BLOCK) + if (lookPos.getType() != RayTraceResult.Type.BLOCK) { return; + } BlockPos hit = lookPos.getPos(); - if(stack.isEmpty()) { + if (stack.isEmpty()) { BlockPos originCoords = getOriginPos(lokiRing); - if(!event.getWorld().isRemote) { - if(originCoords.getY() == -1) { + if (!event.getWorld().isRemote) { + if (originCoords.getY() == -1) { // Initiate a new pending list of positions setOriginPos(lokiRing, hit); setCursorList(lokiRing, null); } else { - if(originCoords.equals(hit)) { + if (originCoords.equals(hit)) { // Finalize the pending list of positions setOriginPos(lokiRing, new BlockPos(0, -1, 0)); } else { @@ -110,9 +112,9 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat } else { ItemStack original = stack.copy(); int successes = 0; - for(BlockPos cursor : cursors) { + for (BlockPos cursor : cursors) { BlockPos pos = hit.add(cursor); - if(ManaItemHandler.requestManaExact(lokiRing, player, cost, false)) { + if (ManaItemHandler.requestManaExact(lokiRing, player, cost, false)) { Vec3d lookHit = lookPos.getHitVec(); Vec3d newHitVec = new Vec3d(pos.getX() + MathHelper.frac(lookHit.getX()), pos.getY() + MathHelper.frac(lookHit.getY()), pos.getZ() + MathHelper.frac(lookHit.getZ())); BlockRayTraceResult newHit = new BlockRayTraceResult(newHitVec, lookPos.getFace(), pos, false); @@ -139,14 +141,15 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat public static void breakOnAllCursors(PlayerEntity player, Item item, ItemStack stack, BlockPos pos, Direction side) { ItemStack lokiRing = getLokiRing(player); - if(lokiRing.isEmpty() || player.world.isRemote || !(item instanceof ISequentialBreaker)) + if (lokiRing.isEmpty() || player.world.isRemote || !(item instanceof ISequentialBreaker)) { return; + } List cursors = getCursorList(lokiRing); ISequentialBreaker breaker = (ISequentialBreaker) item; boolean dispose = breaker.disposeOfTrashBlocks(stack); - for(BlockPos offset : cursors) { + for (BlockPos offset : cursors) { BlockPos coords = pos.add(offset); BlockState state = player.world.getBlockState(coords); breaker.breakOtherBlock(player, stack, coords, pos, side); @@ -163,19 +166,20 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat @Override @OnlyIn(Dist.CLIENT) public List getWireframesToDraw(PlayerEntity player, ItemStack stack) { - if(getLokiRing(player) != stack) + if (getLokiRing(player) != stack) { return ImmutableList.of(); + } RayTraceResult lookPos = Minecraft.getInstance().objectMouseOver; - if(lookPos != null + if (lookPos != null && lookPos.getType() == RayTraceResult.Type.BLOCK && !player.world.isAirBlock(((BlockRayTraceResult) lookPos).getPos())) { List list = getCursorList(stack); BlockPos origin = getOriginPos(stack); - for(int i = 0; i < list.size(); i++) { - if(origin.getY() != -1) { + for (int i = 0; i < list.size(); i++) { + if (origin.getY() != -1) { list.set(i, list.get(i).add(origin)); } else { list.set(i, list.get(i).add(((BlockRayTraceResult) lookPos).getPos())); @@ -210,7 +214,6 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat return EquipmentHandler.findOrEmpty(ModItems.lokiRing, player); } - private static BlockPos getOriginPos(ItemStack stack) { int x = ItemNBTHelper.getInt(stack, TAG_X_ORIGIN, 0); int y = ItemNBTHelper.getInt(stack, TAG_Y_ORIGIN, -1); @@ -229,7 +232,7 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat List cursors = new ArrayList<>(); int count = cmp.getInt(TAG_CURSOR_COUNT); - for(int i = 0; i < count; i++) { + for (int i = 0; i < count; i++) { CompoundNBT cursorCmp = cmp.getCompound(TAG_CURSOR_PREFIX + i); int x = cursorCmp.getInt(TAG_X_OFFSET); int y = cursorCmp.getInt(TAG_Y_OFFSET); @@ -241,13 +244,14 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat } private static void setCursorList(ItemStack stack, List cursors) { - if(stack == null) + if (stack == null) { return; + } CompoundNBT cmp = new CompoundNBT(); - if(cursors != null) { + if (cursors != null) { int i = 0; - for(BlockPos cursor : cursors) { + for (BlockPos cursor : cursors) { CompoundNBT cursorCmp = cursorToCmp(cursor); cmp.put(TAG_CURSOR_PREFIX + i, cursorCmp); i++; @@ -285,4 +289,3 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat } } - diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemOdinRing.java b/src/main/java/vazkii/botania/common/item/relic/ItemOdinRing.java index 397404b7f..b647a42ea 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemOdinRing.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemOdinRing.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 29, 2015, 10:13:41 PM (GMT)] */ package vazkii.botania.common.item.relic; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; + import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.PlayerEntity; @@ -21,6 +20,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.event.entity.living.LivingAttackEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; + import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.core.handler.EquipmentHandler; import vazkii.botania.common.item.ModItems; @@ -49,8 +49,9 @@ public class ItemOdinRing extends ItemRelicBauble { @Override public void onValidPlayerWornTick(PlayerEntity player) { - if(player.isBurning() && ConfigHandler.COMMON.ringOfOdinFireResist.get()) + if (player.isBurning() && ConfigHandler.COMMON.ringOfOdinFireResist.get()) { player.extinguish(); + } } @Override @@ -63,13 +64,14 @@ public class ItemOdinRing extends ItemRelicBauble { @SubscribeEvent public static void onPlayerAttacked(LivingAttackEvent event) { - if(event.getEntityLiving() instanceof PlayerEntity) { + if (event.getEntityLiving() instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity) event.getEntityLiving(); boolean negate = damageNegations.contains(event.getSource().damageType) || (ConfigHandler.COMMON.ringOfOdinFireResist.get() && fireNegations.contains(event.getSource().damageType)); boolean hasRing = !EquipmentHandler.findOrEmpty(ModItems.odinRing, player).isEmpty(); - if(hasRing && negate) + if (hasRing && negate) { event.setCanceled(true); + } } } @@ -79,4 +81,3 @@ public class ItemOdinRing extends ItemRelicBauble { } } - diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemRelic.java b/src/main/java/vazkii/botania/common/item/relic/ItemRelic.java index 88b862fc5..a0326cd10 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemRelic.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemRelic.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 29, 2015, 7:54:40 PM (GMT)] */ package vazkii.botania.common.item.relic; @@ -16,6 +14,7 @@ import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Rarity; import net.minecraft.util.DamageSource; @@ -26,14 +25,15 @@ import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.item.IRelic; import vazkii.botania.common.advancements.RelicBindTrigger; import vazkii.botania.common.core.helper.ItemNBTHelper; -import net.minecraft.item.Item; import vazkii.botania.common.item.ModItems; import javax.annotation.Nonnull; + import java.util.List; import java.util.UUID; @@ -47,8 +47,9 @@ public class ItemRelic extends Item implements IRelic { @Override public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) { - if(!world.isRemote && entity instanceof PlayerEntity) + if (!world.isRemote && entity instanceof PlayerEntity) { updateRelic(stack, (PlayerEntity) entity); + } } @OnlyIn(Dist.CLIENT) @@ -59,22 +60,27 @@ public class ItemRelic extends Item implements IRelic { @OnlyIn(Dist.CLIENT) public void addBindInfo(List list, ItemStack stack) { - if(Screen.hasShiftDown()) { - if(!hasUUID(stack)) { + if (Screen.hasShiftDown()) { + if (!hasUUID(stack)) { list.add(new TranslationTextComponent("botaniamisc.relicUnbound")); } else { - if(!getSoulbindUUID(stack).equals(Minecraft.getInstance().player.getUniqueID())) + if (!getSoulbindUUID(stack).equals(Minecraft.getInstance().player.getUniqueID())) { list.add(new TranslationTextComponent("botaniamisc.notYourSagittarius")); - else list.add(new TranslationTextComponent("botaniamisc.relicSoulbound", Minecraft.getInstance().player.getName())); + } else { + list.add(new TranslationTextComponent("botaniamisc.relicSoulbound", Minecraft.getInstance().player.getName())); + } } - if(stack.getItem() == ModItems.dice) { + if (stack.getItem() == ModItems.dice) { list.add(new StringTextComponent("")); String name = stack.getTranslationKey() + ".poem"; - for(int i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { list.add(new TranslationTextComponent(name + i).applyTextStyles(TextFormatting.GRAY, TextFormatting.ITALIC)); + } } - } else list.add(new TranslationTextComponent("botaniamisc.shiftinfo")); + } else { + list.add(new TranslationTextComponent("botaniamisc.shiftinfo")); + } } public boolean shouldDamageWrongPlayer() { @@ -87,21 +93,24 @@ public class ItemRelic extends Item implements IRelic { } public void updateRelic(ItemStack stack, PlayerEntity player) { - if(stack.isEmpty() || !(stack.getItem() instanceof IRelic)) + if (stack.isEmpty() || !(stack.getItem() instanceof IRelic)) { return; + } boolean rightPlayer = true; - if(!hasUUID(stack)) { + if (!hasUUID(stack)) { bindToUUID(player.getUniqueID(), stack); - if(player instanceof ServerPlayerEntity) + if (player instanceof ServerPlayerEntity) { RelicBindTrigger.INSTANCE.trigger((ServerPlayerEntity) player, stack); + } } else if (!getSoulbindUUID(stack).equals(player.getUniqueID())) { rightPlayer = false; } - if(!rightPlayer && player.ticksExisted % 10 == 0 && (!(stack.getItem() instanceof ItemRelic) || ((ItemRelic) stack.getItem()).shouldDamageWrongPlayer())) + if (!rightPlayer && player.ticksExisted % 10 == 0 && (!(stack.getItem() instanceof ItemRelic) || ((ItemRelic) stack.getItem()).shouldDamageWrongPlayer())) { player.attackEntityFrom(damageSource(), 2); + } } public boolean isRightPlayer(PlayerEntity player, ItemStack stack) { @@ -119,7 +128,7 @@ public class ItemRelic extends Item implements IRelic { @Override public UUID getSoulbindUUID(ItemStack stack) { - if(ItemNBTHelper.verifyExistance(stack, TAG_SOULBIND_UUID)) { + if (ItemNBTHelper.verifyExistance(stack, TAG_SOULBIND_UUID)) { try { return UUID.fromString(ItemNBTHelper.getString(stack, TAG_SOULBIND_UUID, "")); } catch (IllegalArgumentException ex) { // Bad UUID in tag diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemRelicBauble.java b/src/main/java/vazkii/botania/common/item/relic/ItemRelicBauble.java index 3aaec7a62..9a227862a 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemRelicBauble.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemRelicBauble.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 29, 2015, 7:56:27 PM (GMT)] */ package vazkii.botania.common.item.relic; @@ -20,11 +18,13 @@ import net.minecraft.util.text.ITextComponent; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.item.IRelic; import vazkii.botania.common.item.equipment.bauble.ItemBauble; import javax.annotation.Nonnull; + import java.util.List; import java.util.UUID; @@ -42,8 +42,9 @@ public abstract class ItemRelicBauble extends ItemBauble implements IRelic { @Override public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean held) { - if(entity instanceof PlayerEntity) + if (entity instanceof PlayerEntity) { dummy.updateRelic(stack, (PlayerEntity) entity); + } } @OnlyIn(Dist.CLIENT) @@ -81,15 +82,16 @@ public abstract class ItemRelicBauble extends ItemBauble implements IRelic { @Override public void onWornTick(ItemStack stack, LivingEntity entity) { - if(entity instanceof PlayerEntity) { + if (entity instanceof PlayerEntity) { PlayerEntity ePlayer = (PlayerEntity) entity; dummy.updateRelic(stack, ePlayer); - if(dummy.isRightPlayer(ePlayer, stack)) + if (dummy.isRightPlayer(ePlayer, stack)) { onValidPlayerWornTick(ePlayer); + } } } - public void onValidPlayerWornTick(PlayerEntity player) { } + public void onValidPlayerWornTick(PlayerEntity player) {} @Override public boolean canEquip(ItemStack stack, LivingEntity entity) { diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemThorRing.java b/src/main/java/vazkii/botania/common/item/relic/ItemThorRing.java index 0a30aaaa5..284b72f2c 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemThorRing.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemThorRing.java @@ -1,18 +1,17 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Mar 29, 2015, 10:13:37 PM (GMT)] */ package vazkii.botania.common.item.relic; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; + import vazkii.botania.common.core.handler.EquipmentHandler; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibMisc; diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemCobbleRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemCobbleRod.java index 6ece4d788..10e242076 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemCobbleRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemCobbleRod.java @@ -1,25 +1,24 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 24, 2015, 10:28:03 PM (GMT)] */ package vazkii.botania.common.item.rod; import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; import net.minecraft.util.ActionResultType; + import vazkii.botania.api.item.IBlockProvider; import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; -import net.minecraft.item.Item; import javax.annotation.Nonnull; @@ -44,15 +43,17 @@ public class ItemCobbleRod extends Item implements IManaUsingItem, IBlockProvide @Override public boolean provideBlock(PlayerEntity player, ItemStack requestor, ItemStack stack, Block block, boolean doit) { - if(block == Blocks.COBBLESTONE) + if (block == Blocks.COBBLESTONE) { return !doit || ManaItemHandler.requestManaExactForTool(requestor, player, COST, true); + } return false; } @Override public int getBlockCount(PlayerEntity player, ItemStack requestor, ItemStack stack, Block block) { - if(block == Blocks.COBBLESTONE) + if (block == Blocks.COBBLESTONE) { return -1; + } return 0; } diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemDirtRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemDirtRod.java index 8c134b68a..1877a3be6 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemDirtRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemDirtRod.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 11, 2014, 2:53:41 PM (GMT)] */ package vazkii.botania.common.item.rod; @@ -15,6 +13,7 @@ import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; import net.minecraft.tileentity.TileEntity; @@ -24,6 +23,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import vazkii.botania.api.item.IAvatarTile; import vazkii.botania.api.item.IAvatarWieldable; import vazkii.botania.api.item.IBlockProvider; @@ -32,7 +32,6 @@ import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.client.fx.SparkleParticleData; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.core.helper.PlayerHelper; -import net.minecraft.item.Item; import javax.annotation.Nonnull; @@ -59,20 +58,20 @@ public class ItemDirtRod extends Item implements IManaUsingItem, IBlockProvider, Direction side = ctx.getFace(); BlockPos pos = ctx.getPos(); - if(player != null && ManaItemHandler.requestManaExactForTool(stack, player, cost, false)) { + if (player != null && ManaItemHandler.requestManaExactForTool(stack, player, cost, false)) { int entities = world.getEntitiesWithinAABB(LivingEntity.class, new AxisAlignedBB(pos.offset(side), pos.offset(side).add(1, 1, 1))).size(); - if(entities == 0) { + if (entities == 0) { ItemStack stackToPlace = new ItemStack(block); PlayerHelper.substituteUse(ctx, stackToPlace); - if(stackToPlace.isEmpty()) { + if (stackToPlace.isEmpty()) { ManaItemHandler.requestManaExactForTool(stack, player, cost, true); SparkleParticleData data = SparkleParticleData.sparkle(1F, r, g, b, 5); - for(int i = 0; i < 6; i++) { - world.addParticle(data, pos.getX() + side.getXOffset() + Math.random(), pos.getY() + side.getYOffset() + Math.random(), pos.getZ() + side.getZOffset() + Math.random(), 0, 0, 0); - } + for (int i = 0; i < 6; i++) { + world.addParticle(data, pos.getX() + side.getXOffset() + Math.random(), pos.getY() + side.getYOffset() + Math.random(), pos.getZ() + side.getZOffset() + Math.random(), 0, 0, 0); + } return ActionResultType.SUCCESS; } } @@ -90,15 +89,17 @@ public class ItemDirtRod extends Item implements IManaUsingItem, IBlockProvider, @Override public boolean provideBlock(PlayerEntity player, ItemStack requestor, ItemStack stack, Block block, boolean doit) { - if(block == Blocks.DIRT) + if (block == Blocks.DIRT) { return !doit || ManaItemHandler.requestManaExactForTool(requestor, player, COST, true); + } return false; } @Override public int getBlockCount(PlayerEntity player, ItemStack requestor, ItemStack stack, Block block) { - if(block == Blocks.DIRT) + if (block == Blocks.DIRT) { return -1; + } return 0; } @@ -106,10 +107,10 @@ public class ItemDirtRod extends Item implements IManaUsingItem, IBlockProvider, public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) { TileEntity te = (TileEntity) tile; World world = te.getWorld(); - if(!world.isRemote && tile.getCurrentMana() >= COST && tile.getElapsedFunctionalTicks() % 4 == 0 && world.rand.nextInt(8) == 0 && tile.isEnabled()) { + if (!world.isRemote && tile.getCurrentMana() >= COST && tile.getElapsedFunctionalTicks() % 4 == 0 && world.rand.nextInt(8) == 0 && tile.isEnabled()) { BlockPos pos = ((TileEntity) tile).getPos().offset(tile.getAvatarFacing()); BlockState state = world.getBlockState(pos); - if(state.getBlock().isAir(state, world, pos)) { + if (state.getBlock().isAir(state, world, pos)) { world.setBlockState(pos, Blocks.DIRT.getDefaultState()); world.playEvent(2001, pos, Block.getStateId(Blocks.DIRT.getDefaultState())); tile.recieveMana(-COST); @@ -122,5 +123,4 @@ public class ItemDirtRod extends Item implements IManaUsingItem, IBlockProvider, return avatarOverlay; } - -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemDiviningRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemDiviningRod.java index f7b2cc173..a521834e5 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemDiviningRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemDiviningRod.java @@ -1,18 +1,17 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 25, 2014, 2:57:16 PM (GMT)] */ package vazkii.botania.common.item.rod; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ActionResult; @@ -22,6 +21,7 @@ import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.Tags; + import vazkii.botania.api.item.IAvatarTile; import vazkii.botania.api.item.IAvatarWieldable; import vazkii.botania.api.item.IManaProficiencyArmor; @@ -30,9 +30,9 @@ import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.client.fx.WispParticleData; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.core.handler.ModSounds; -import net.minecraft.item.Item; import javax.annotation.Nonnull; + import java.util.Random; public class ItemDiviningRod extends Item implements IManaUsingItem, IAvatarWieldable { @@ -49,13 +49,15 @@ public class ItemDiviningRod extends Item implements IManaUsingItem, IAvatarWiel @Override public ActionResult onItemRightClick(World world, PlayerEntity p, @Nonnull Hand hand) { ItemStack stack = p.getHeldItem(hand); - if(ManaItemHandler.requestManaExactForTool(stack, p, COST, true)) { - if(world.isRemote) { + if (ManaItemHandler.requestManaExactForTool(stack, p, COST, true)) { + if (world.isRemote) { int range = IManaProficiencyArmor.hasProficiency(p, stack) ? 20 : 15; long seedxor = world.rand.nextLong(); doHighlight(world, new BlockPos(p), range, seedxor); p.swingArm(hand); - } else world.playSound(null, p.getX(), p.getY(), p.getZ(), ModSounds.divinationRod, SoundCategory.PLAYERS, 1F, 1F); + } else { + world.playSound(null, p.getX(), p.getY(), p.getZ(), ModSounds.divinationRod, SoundCategory.PLAYERS, 1F, 1F); + } return ActionResult.success(stack); } @@ -63,12 +65,12 @@ public class ItemDiviningRod extends Item implements IManaUsingItem, IAvatarWiel } private void doHighlight(World world, BlockPos pos, int range, long seedxor) { - for(BlockPos pos_ : BlockPos.getAllInBoxMutable(pos.add(-range, -range, -range), + for (BlockPos pos_ : BlockPos.getAllInBoxMutable(pos.add(-range, -range, -range), pos.add(range, range, range))) { BlockState state = world.getBlockState(pos_); Block block = state.getBlock(); - if(Tags.Blocks.ORES.contains(block)) { + if (Tags.Blocks.ORES.contains(block)) { Random rand = new Random(block.getRegistryName().hashCode() ^ seedxor); WispParticleData data = WispParticleData.wisp(0.25F, rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), 8, false); world.addParticle(data, pos_.getX() + world.rand.nextFloat(), @@ -88,7 +90,7 @@ public class ItemDiviningRod extends Item implements IManaUsingItem, IAvatarWiel public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) { TileEntity te = (TileEntity) tile; World world = te.getWorld(); - if(tile.getCurrentMana() >= COST && tile.getElapsedFunctionalTicks() % 200 == 0 && tile.isEnabled()) { + if (tile.getCurrentMana() >= COST && tile.getElapsedFunctionalTicks() % 200 == 0 && tile.isEnabled()) { doHighlight(world, te.getPos(), 18, te.getPos().hashCode()); tile.recieveMana(-COST); } @@ -98,4 +100,4 @@ public class ItemDiviningRod extends Item implements IManaUsingItem, IAvatarWiel public ResourceLocation getOverlayResource(IAvatarTile tile, ItemStack stack) { return avatarOverlay; } -} \ No newline at end of file +} 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 b47be8cd8..f467d1972 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemExchangeRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemExchangeRod.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 20, 2015, 8:08:34 PM (GMT)] */ package vazkii.botania.common.item.rod; import com.google.common.collect.ImmutableList; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; @@ -38,6 +37,7 @@ import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.item.IBlockProvider; import vazkii.botania.api.item.IManaProficiencyArmor; @@ -49,6 +49,7 @@ import vazkii.botania.common.block.BlockPlatform; import vazkii.botania.common.core.helper.ItemNBTHelper; import javax.annotation.Nonnull; + import java.util.ArrayList; import java.util.List; @@ -79,20 +80,20 @@ public class ItemExchangeRod extends Item implements IManaUsingItem, IWireframeC ItemStack stack = ctx.getItem(); BlockState wstate = world.getBlockState(pos); - if(player != null && player.isSneaking()) { + if (player != null && player.isSneaking()) { TileEntity tile = world.getTileEntity(pos); - if(tile == null) { - if(BlockPlatform.isValidBlock(wstate, world, pos)) { + if (tile == null) { + if (BlockPlatform.isValidBlock(wstate, world, pos)) { setBlock(stack, wstate); displayRemainderCounter(player, stack); return ActionResultType.SUCCESS; } } - } else if(canExchange(stack) && !ItemNBTHelper.getBoolean(stack, TAG_SWAPPING, false)) { + } else if (canExchange(stack) && !ItemNBTHelper.getBoolean(stack, TAG_SWAPPING, false)) { BlockState state = getState(stack); List swap = getTargetPositions(world, stack, state, pos, wstate.getBlock()); - if(swap.size() > 0) { + if (swap.size() > 0) { ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, true); ItemNBTHelper.setInt(stack, TAG_SELECT_X, pos.getX()); ItemNBTHelper.setInt(stack, TAG_SELECT_Y, pos.getY()); @@ -106,27 +107,30 @@ public class ItemExchangeRod extends Item implements IManaUsingItem, IWireframeC private void onLeftClick(PlayerInteractEvent.LeftClickBlock event) { ItemStack stack = event.getItemStack(); - if(!stack.isEmpty() && stack.getItem() == this && canExchange(stack) && ManaItemHandler.requestManaExactForTool(stack, event.getPlayer(), COST, false)) { - if(exchange(event.getWorld(), event.getPlayer(), event.getPos(), stack, getState(stack))) + if (!stack.isEmpty() && stack.getItem() == this && canExchange(stack) && ManaItemHandler.requestManaExactForTool(stack, event.getPlayer(), COST, false)) { + if (exchange(event.getWorld(), event.getPlayer(), event.getPos(), stack, getState(stack))) { ManaItemHandler.requestManaExactForTool(stack, event.getPlayer(), COST, true); + } } } @Override public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean equipped) { - if(!canExchange(stack) || !(entity instanceof PlayerEntity)) + if (!canExchange(stack) || !(entity instanceof PlayerEntity)) { return; + } PlayerEntity player = (PlayerEntity) entity; int extraRange = ItemNBTHelper.getInt(stack, TAG_EXTRA_RANGE, 1); int extraRangeNew = IManaProficiencyArmor.hasProficiency(player, stack) ? 3 : 1; - if(extraRange != extraRangeNew) + if (extraRange != extraRangeNew) { ItemNBTHelper.setInt(stack, TAG_EXTRA_RANGE, extraRangeNew); + } BlockState state = getState(stack); - if(ItemNBTHelper.getBoolean(stack, TAG_SWAPPING, false)) { - if(!ManaItemHandler.requestManaExactForTool(stack, player, COST, false)) { + if (ItemNBTHelper.getBoolean(stack, TAG_SWAPPING, false)) { + if (!ManaItemHandler.requestManaExactForTool(stack, player, COST, false)) { ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false); return; } @@ -136,16 +140,18 @@ public class ItemExchangeRod extends Item implements IManaUsingItem, IWireframeC int z = ItemNBTHelper.getInt(stack, TAG_SELECT_Z, 0); Block target = getTargetState(stack); List swap = getTargetPositions(world, stack, state, new BlockPos(x, y, z), target); - if(swap.size() == 0) { + if (swap.size() == 0) { ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false); return; } BlockPos coords = swap.get(world.rand.nextInt(swap.size())); boolean exchange = exchange(world, player, coords, stack, state); - if(exchange) + if (exchange) { ManaItemHandler.requestManaExactForTool(stack, player, COST, true); - else ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false); + } else { + ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false); + } } } @@ -158,51 +164,56 @@ public class ItemExchangeRod extends Item implements IManaUsingItem, IWireframeC int effRange = RANGE + ItemNBTHelper.getInt(stack, TAG_EXTRA_RANGE, 1) - 1; // Iterate in all 3 dimensions through our possible positions. - for(int offsetX = -effRange; offsetX <= effRange; offsetX++) - for(int offsetY = -effRange; offsetY <= effRange; offsetY++) - for(int offsetZ = -effRange; offsetZ <= effRange; offsetZ++) { + for (int offsetX = -effRange; offsetX <= effRange; offsetX++) { + for (int offsetY = -effRange; offsetY <= effRange; offsetY++) { + for (int offsetZ = -effRange; offsetZ <= effRange; offsetZ++) { BlockPos pos_ = pos.add(offsetX, offsetY, offsetZ); BlockState currentState = world.getBlockState(pos_); // If this block is not our target, ignore it, as we don't need // to consider replacing it - if(currentState.getBlock() != toReplace) + if (currentState.getBlock() != toReplace) { continue; + } // If this block is already the block we're swapping to, // we don't need to swap again - if(currentState == toPlace) + if (currentState == toPlace) { continue; + } // Check to see if the block is visible on any side: - for(Direction dir : Direction.values()) { + for (Direction dir : Direction.values()) { BlockPos adjPos = pos_.offset(dir); BlockState adjState = world.getBlockState(adjPos); - if(!Block.hasSolidSide(adjState, world, adjPos, dir.getOpposite())) { + if (!Block.hasSolidSide(adjState, world, adjPos, dir.getOpposite())) { coordsList.add(pos_); break; } } } + } + } return coordsList; } public boolean exchange(World world, PlayerEntity player, BlockPos pos, ItemStack stack, BlockState state) { TileEntity tile = world.getTileEntity(pos); - if(tile != null) + if (tile != null) { return false; + } ItemStack placeStack = removeFromInventory(player, stack, state.getBlock(), false); - if(!placeStack.isEmpty()) { + if (!placeStack.isEmpty()) { BlockState stateAt = world.getBlockState(pos); Block blockAt = stateAt.getBlock(); - if(!blockAt.isAir(world.getBlockState(pos), world, pos) && stateAt.getPlayerRelativeBlockHardness(player, world, pos) > 0 && stateAt != state) { - if(!world.isRemote) { + if (!blockAt.isAir(world.getBlockState(pos), world, pos) && stateAt.getPlayerRelativeBlockHardness(player, world, pos) > 0 && stateAt != state) { + if (!world.isRemote) { world.destroyBlock(pos, !player.abilities.isCreativeMode); - if(!player.abilities.isCreativeMode) { + if (!player.abilities.isCreativeMode) { removeFromInventory(player, stack, state.getBlock(), true); } world.setBlockState(pos, state); @@ -220,57 +231,66 @@ public class ItemExchangeRod extends Item implements IManaUsingItem, IWireframeC return !getState(stack).isAir(); } - public static ItemStack removeFromInventory(PlayerEntity player, LazyOptional inv, ItemStack stack, Block block, boolean doit) { return inv.map(handler -> removeFromInventory(player, handler, stack, block, doit)).orElse(ItemStack.EMPTY); } public static ItemStack removeFromInventory(PlayerEntity player, IItemHandler inv, ItemStack stack, Block block, boolean doit) { List providers = new ArrayList<>(); - for(int i = inv.getSlots() - 1; i >= 0; i--) { + for (int i = inv.getSlots() - 1; i >= 0; i--) { ItemStack invStack = inv.getStackInSlot(i); - if(invStack.isEmpty()) + if (invStack.isEmpty()) { continue; + } Item item = invStack.getItem(); - if(item == block.asItem()) { + if (item == block.asItem()) { return inv.extractItem(i, 1, !doit); } - if(item instanceof IBlockProvider) + if (item instanceof IBlockProvider) { providers.add(invStack); + } } - for(ItemStack provStack : providers) { + for (ItemStack provStack : providers) { IBlockProvider prov = (IBlockProvider) provStack.getItem(); - if(prov.provideBlock(player, stack, provStack, block, doit)) + if (prov.provideBlock(player, stack, provStack, block, doit)) { return new ItemStack(block); + } } return ItemStack.EMPTY; } public static ItemStack removeFromInventory(PlayerEntity player, ItemStack stack, Block block, boolean doit) { - if(player.abilities.isCreativeMode) + if (player.abilities.isCreativeMode) { return new ItemStack(block); + } ItemStack outStack = removeFromInventory(player, BotaniaAPI.internalHandler.getAccessoriesInventory(player), stack, block, doit); - if (outStack.isEmpty()) + if (outStack.isEmpty()) { outStack = removeFromInventory(player, player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY), stack, block, doit); + } return outStack; } public static int getInventoryItemCount(PlayerEntity player, ItemStack stack, Block block) { - if(player.abilities.isCreativeMode) + if (player.abilities.isCreativeMode) { return -1; + } int baubleCount = getInventoryItemCount(player, BotaniaAPI.internalHandler.getAccessoriesInventory(player), stack, block); - if (baubleCount == -1) return -1; + if (baubleCount == -1) { + return -1; + } int count = getInventoryItemCount(player, player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY), stack, block); - if (count == -1) return -1; + if (count == -1) { + return -1; + } - return count+baubleCount; + return count + baubleCount; } public static int getInventoryItemCount(PlayerEntity player, LazyOptional inv, ItemStack stack, Block block) { @@ -278,24 +298,28 @@ public class ItemExchangeRod extends Item implements IManaUsingItem, IWireframeC } public static int getInventoryItemCount(PlayerEntity player, IItemHandler inv, ItemStack stack, Block block) { - if(player.abilities.isCreativeMode) + if (player.abilities.isCreativeMode) { return -1; + } int count = 0; - for(int i = 0; i < inv.getSlots(); i++) { + for (int i = 0; i < inv.getSlots(); i++) { ItemStack invStack = inv.getStackInSlot(i); - if(invStack.isEmpty()) + if (invStack.isEmpty()) { continue; + } Item item = invStack.getItem(); - if(item == block.asItem()) + if (item == block.asItem()) { count += invStack.getCount(); + } - if(item instanceof IBlockProvider) { + if (item instanceof IBlockProvider) { IBlockProvider prov = (IBlockProvider) item; int provCount = prov.getBlockCount(player, stack, invStack, block); - if(provCount == -1) + if (provCount == -1) { return -1; + } count += provCount; } } @@ -306,8 +330,9 @@ public class ItemExchangeRod extends Item implements IManaUsingItem, IWireframeC public void displayRemainderCounter(PlayerEntity player, ItemStack stack) { Block block = getState(stack).getBlock(); int count = getInventoryItemCount(player, stack, block); - if(!player.world.isRemote) + if (!player.world.isRemote) { ItemsRemainingRenderHandler.set(new ItemStack(block), count); + } } @Override @@ -351,25 +376,26 @@ public class ItemExchangeRod extends Item implements IManaUsingItem, IWireframeC @OnlyIn(Dist.CLIENT) public List getWireframesToDraw(PlayerEntity player, ItemStack stack) { ItemStack holding = player.getHeldItemMainhand(); - if(holding != stack || !canExchange(stack)) + if (holding != stack || !canExchange(stack)) { return ImmutableList.of(); + } BlockState state = getState(stack); RayTraceResult pos = Minecraft.getInstance().objectMouseOver; - if(pos != null && pos.getType() == RayTraceResult.Type.BLOCK) { + if (pos != null && pos.getType() == RayTraceResult.Type.BLOCK) { BlockPos bPos = ((BlockRayTraceResult) pos).getPos(); Block target = Minecraft.getInstance().world.getBlockState(bPos).getBlock(); - if(ItemNBTHelper.getBoolean(stack, TAG_SWAPPING, false)) { + if (ItemNBTHelper.getBoolean(stack, TAG_SWAPPING, false)) { bPos = new BlockPos( ItemNBTHelper.getInt(stack, TAG_SELECT_X, 0), ItemNBTHelper.getInt(stack, TAG_SELECT_Y, 0), ItemNBTHelper.getInt(stack, TAG_SELECT_Z, 0) - ); + ); target = getTargetState(stack); } - if(!player.world.isAirBlock(bPos)) { + if (!player.world.isAirBlock(bPos)) { List coordsList = getTargetPositions(player.world, stack, state, bPos, target); coordsList.removeIf(bPos::equals); return coordsList; diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemFireRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemFireRod.java index 27da7d2af..a852a526b 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemFireRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemFireRod.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 26, 2014, 12:08:06 AM (GMT)] */ package vazkii.botania.common.item.rod; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; import net.minecraft.tileentity.TileEntity; @@ -20,6 +19,7 @@ import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import vazkii.botania.api.item.IAvatarTile; import vazkii.botania.api.item.IAvatarWieldable; import vazkii.botania.api.item.IManaProficiencyArmor; @@ -27,7 +27,6 @@ import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.entity.EntityFlameRing; -import net.minecraft.item.Item; import javax.annotation.Nonnull; @@ -50,7 +49,7 @@ public class ItemFireRod extends Item implements IManaUsingItem, IAvatarWieldabl ItemStack stack = ctx.getItem(); BlockPos pos = ctx.getPos(); - if(!world.isRemote && player != null && ManaItemHandler.requestManaExactForTool(stack, player, COST, false)) { + if (!world.isRemote && player != null && ManaItemHandler.requestManaExactForTool(stack, player, COST, false)) { EntityFlameRing entity = new EntityFlameRing(world); entity.setPosition(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5); world.addEntity(entity); @@ -74,7 +73,7 @@ public class ItemFireRod extends Item implements IManaUsingItem, IAvatarWieldabl TileEntity te = (TileEntity) tile; World world = te.getWorld(); - if(!world.isRemote && tile.getCurrentMana() >= COST && tile.getElapsedFunctionalTicks() % 300 == 0 && tile.isEnabled()) { + if (!world.isRemote && tile.getCurrentMana() >= COST && tile.getElapsedFunctionalTicks() % 300 == 0 && tile.isEnabled()) { EntityFlameRing entity = new EntityFlameRing(world); entity.setPosition(te.getPos().getX() + 0.5, te.getPos().getY(), te.getPos().getZ() + 0.5); world.addEntity(entity); 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 ec59d24b1..d1951200a 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemGravityRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemGravityRod.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Aug 25, 2014, 2:57:16 PM (GMT)] */ package vazkii.botania.common.item.rod; @@ -15,6 +13,7 @@ import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Effects; @@ -23,6 +22,7 @@ import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.world.World; + import vazkii.botania.api.item.IManaProficiencyArmor; import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; @@ -31,11 +31,11 @@ import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.core.helper.MathHelper; import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.entity.EntityThrownItem; -import net.minecraft.item.Item; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.ModTags; import javax.annotation.Nonnull; + import java.util.ArrayList; import java.util.List; @@ -60,30 +60,34 @@ public class ItemGravityRod extends Item implements IManaUsingItem { @Override public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean held) { - if(!(entity instanceof PlayerEntity)) + if (!(entity instanceof PlayerEntity)) { return; + } int ticksTillExpire = ItemNBTHelper.getInt(stack, TAG_TICKS_TILL_EXPIRE, 0); int ticksCooldown = ItemNBTHelper.getInt(stack, TAG_TICKS_COOLDOWN, 0); - if(ticksTillExpire == 0) { + if (ticksTillExpire == 0) { ItemNBTHelper.setInt(stack, TAG_TARGET, -1); ItemNBTHelper.setDouble(stack, TAG_DIST, -1); } - if(ticksCooldown > 0) + if (ticksCooldown > 0) { ticksCooldown--; + } - if (ticksTillExpire >= 0) + if (ticksTillExpire >= 0) { ticksTillExpire--; + } ItemNBTHelper.setInt(stack, TAG_TICKS_TILL_EXPIRE, ticksTillExpire); ItemNBTHelper.setInt(stack, TAG_TICKS_COOLDOWN, ticksCooldown); PlayerEntity player = (PlayerEntity) entity; EffectInstance haste = player.getActivePotionEffect(Effects.HASTE); float check = haste == null ? 0.16666667F : haste.getAmplifier() == 1 ? 0.5F : 0.4F; - if(player.getHeldItemMainhand() == stack && player.swingProgress == check && !world.isRemote) + if (player.getHeldItemMainhand() == stack && player.swingProgress == check && !world.isRemote) { leftClick(player); + } } @Nonnull @@ -94,66 +98,73 @@ public class ItemGravityRod extends Item implements IManaUsingItem { int ticksCooldown = ItemNBTHelper.getInt(stack, TAG_TICKS_COOLDOWN, 0); double length = ItemNBTHelper.getDouble(stack, TAG_DIST, -1); - if(ticksCooldown == 0) { + if (ticksCooldown == 0) { Entity target = null; - if(targetID != -1 && player.world.getEntityByID(targetID) != null) { + if (targetID != -1 && player.world.getEntityByID(targetID) != null) { Entity taritem = player.world.getEntityByID(targetID); boolean found = false; Vector3 targetVec = Vector3.fromEntityCenter(player); List entities = new ArrayList<>(); int distance = 1; - while(entities.size() == 0 && distance < 25) { + while (entities.size() == 0 && distance < 25) { targetVec = targetVec.add(new Vector3(player.getLookVec()).multiply(distance)).add(0, 0.5, 0); entities = player.world.getEntitiesWithinAABBExcludingEntity(player, new AxisAlignedBB(targetVec.x - RANGE, targetVec.y - RANGE, targetVec.z - RANGE, targetVec.x + RANGE, targetVec.y + RANGE, targetVec.z + RANGE)); distance++; - if(entities.contains(taritem)) + if (entities.contains(taritem)) { found = true; + } } - if(found) + if (found) { target = player.world.getEntityByID(targetID); + } } - if(target == null) { + if (target == null) { Vector3 targetVec = Vector3.fromEntityCenter(player); List entities = new ArrayList<>(); int distance = 1; - while(entities.size() == 0 && distance < 25) { + while (entities.size() == 0 && distance < 25) { targetVec = targetVec.add(new Vector3(player.getLookVec()).multiply(distance)).add(0, 0.5, 0); entities = player.world.getEntitiesWithinAABBExcludingEntity(player, new AxisAlignedBB(targetVec.x - RANGE, targetVec.y - RANGE, targetVec.z - RANGE, targetVec.x + RANGE, targetVec.y + RANGE, targetVec.z + RANGE)); distance++; } - if(entities.size() > 0) { + if (entities.size() > 0) { target = entities.get(0); length = 5.5D; - if(target instanceof ItemEntity) + if (target instanceof ItemEntity) { length = 2.0D; + } } } - if(target != null) { - if(BLACKLIST.contains(target.getType())) + if (target != null) { + if (BLACKLIST.contains(target.getType())) { return ActionResult.fail(stack); + } - if(ManaItemHandler.requestManaExactForTool(stack, player, COST, true)) { - if(target instanceof ItemEntity) + if (ManaItemHandler.requestManaExactForTool(stack, player, COST, true)) { + if (target instanceof ItemEntity) { ((ItemEntity) target).setPickupDelay(5); + } - if(target instanceof LivingEntity) { - LivingEntity targetEntity = (LivingEntity)target; + if (target instanceof LivingEntity) { + LivingEntity targetEntity = (LivingEntity) target; targetEntity.fallDistance = 0.0F; - if(targetEntity.getActivePotionEffect(Effects.SLOWNESS) == null) + if (targetEntity.getActivePotionEffect(Effects.SLOWNESS) == null) { targetEntity.addPotionEffect(new EffectInstance(Effects.SLOWNESS, 2, 3, true, true)); + } } Vector3 target3 = Vector3.fromEntityCenter(player) .add(new Vector3(player.getLookVec()).multiply(length)).add(0, 0.5, 0); - if(target instanceof ItemEntity) + if (target instanceof ItemEntity) { target3 = target3.add(0, 0.25, 0); + } - for(int i = 0; i < 4; i++) { + 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; @@ -161,9 +172,9 @@ public class ItemGravityRod extends Item implements IManaUsingItem { float xm = ((float) Math.random() - 0.5F) * m; float ym = ((float) Math.random() - 0.5F) * m; float zm = ((float) Math.random() - 0.5F) * m; - WispParticleData data = WispParticleData.wisp(s, r, 0F, b); - world.addParticle(data, target.getX() + target.getWidth() / 2, target.getY() + target.getHeight() / 2, target.getZ() + target.getWidth() / 2, xm, ym, zm); - } + WispParticleData data = WispParticleData.wisp(s, r, 0F, b); + world.addParticle(data, target.getX() + target.getWidth() / 2, target.getY() + target.getHeight() / 2, target.getZ() + target.getWidth() / 2, xm, ym, zm); + } MathHelper.setEntityMotionFromVector(target, target3, 0.3333333F); @@ -185,36 +196,37 @@ public class ItemGravityRod extends Item implements IManaUsingItem { private static void leftClick(PlayerEntity player) { ItemStack stack = player.getHeldItemMainhand(); - if(!stack.isEmpty() && stack.getItem() == ModItems.gravityRod) { + if (!stack.isEmpty() && stack.getItem() == ModItems.gravityRod) { int targetID = ItemNBTHelper.getInt(stack, TAG_TARGET, -1); ItemNBTHelper.getDouble(stack, TAG_DIST, -1); Entity item; - if(targetID != -1 && player.world.getEntityByID(targetID) != null) { + if (targetID != -1 && player.world.getEntityByID(targetID) != null) { Entity taritem = player.world.getEntityByID(targetID); boolean found = false; Vector3 target = Vector3.fromEntityCenter(player); List entities = new ArrayList<>(); int distance = 1; - while(entities.size() == 0 && distance < 25) { + while (entities.size() == 0 && distance < 25) { target = target.add(new Vector3(player.getLookVec()).multiply(distance)).add(0, 0.5, 0); entities = player.world.getEntitiesWithinAABBExcludingEntity(player, new AxisAlignedBB(target.x - RANGE, target.y - RANGE, target.z - RANGE, target.x + RANGE, target.y + RANGE, target.z + RANGE)); distance++; - if(entities.contains(taritem)) + if (entities.contains(taritem)) { found = true; + } } - if(found) { + if (found) { item = taritem; ItemNBTHelper.setInt(stack, TAG_TARGET, -1); ItemNBTHelper.setDouble(stack, TAG_DIST, -1); Vector3 moveVector = new Vector3(player.getLookVec().normalize()); - if(item instanceof ItemEntity) { + if (item instanceof ItemEntity) { ((ItemEntity) item).setPickupDelay(20); float mot = IManaProficiencyArmor.hasProficiency(player, stack) ? 2.25F : 1.5F; item.setMotion(moveVector.x * mot, moveVector.y, moveVector.z * mot); - if(!player.world.isRemote) { + if (!player.world.isRemote) { EntityThrownItem thrown = new EntityThrownItem(item.world, item.getX(), item.getY(), item.getZ(), (ItemEntity) item); item.world.addEntity(thrown); } @@ -227,4 +239,4 @@ public class ItemGravityRod extends Item implements IManaUsingItem { } } } -} \ No newline at end of file +} diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemMissileRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemMissileRod.java index 33a1446ec..7acabd506 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemMissileRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemMissileRod.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 24, 2014, 5:58:16 PM (GMT)] */ package vazkii.botania.common.item.rod; @@ -20,6 +18,7 @@ import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + import vazkii.botania.api.item.IAvatarTile; import vazkii.botania.api.item.IAvatarWieldable; import vazkii.botania.api.item.IManaProficiencyArmor; @@ -56,27 +55,32 @@ public class ItemMissileRod extends Item implements IManaUsingItem, IAvatarWield @Override public void onUsingTick(ItemStack stack, LivingEntity living, int count) { - if(!(living instanceof PlayerEntity)) return; + if (!(living instanceof PlayerEntity)) { + return; + } PlayerEntity player = (PlayerEntity) living; - if(count != getUseDuration(stack) && count % (IManaProficiencyArmor.hasProficiency(player, stack) ? 1 : 2) == 0 && !player.world.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, COST_PER, false)) { - if(spawnMissile(player.world, player, player.getX() + (Math.random() - 0.5 * 0.1), player.getY() + 2.4 + (Math.random() - 0.5 * 0.1), player.getZ() + (Math.random() - 0.5 * 0.1))) + if (count != getUseDuration(stack) && count % (IManaProficiencyArmor.hasProficiency(player, stack) ? 1 : 2) == 0 && !player.world.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, COST_PER, false)) { + if (spawnMissile(player.world, player, player.getX() + (Math.random() - 0.5 * 0.1), player.getY() + 2.4 + (Math.random() - 0.5 * 0.1), player.getZ() + (Math.random() - 0.5 * 0.1))) { ManaItemHandler.requestManaExactForTool(stack, player, COST_PER, true); + } - SparkleParticleData data = SparkleParticleData.sparkle(6F, 1F, 0.4F, 1F, 6); - player.world.addParticle(data, player.getX(), player.getY() + 2.4, player.getZ(), 0, 0, 0); - } + SparkleParticleData data = SparkleParticleData.sparkle(6F, 1F, 0.4F, 1F, 6); + player.world.addParticle(data, player.getX(), player.getY() + 2.4, player.getZ(), 0, 0, 0); + } } public boolean spawnMissile(World world, LivingEntity thrower, double x, double y, double z) { EntityMagicMissile missile; - if(thrower != null) + if (thrower != null) { missile = new EntityMagicMissile(thrower, false); - else missile = new EntityMagicMissile(world); + } else { + missile = new EntityMagicMissile(world); + } missile.setPosition(x, y, z); - if(missile.findTarget()) { - if(!world.isRemote) { + if (missile.findTarget()) { + if (!world.isRemote) { missile.playSound(ModSounds.missile, 0.6F, 0.8F + (float) Math.random() * 0.2F); world.addEntity(missile); } @@ -102,13 +106,15 @@ public class ItemMissileRod extends Item implements IManaUsingItem, IAvatarWield public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) { TileEntity te = (TileEntity) tile; World world = te.getWorld(); - if(tile.getCurrentMana() >= COST_AVATAR && tile.getElapsedFunctionalTicks() % 3 == 0 && tile.isEnabled()) - if(spawnMissile(world, null, te.getPos().getX() + 0.5 + (Math.random() - 0.5 * 0.1), te.getPos().getY() + 2.5 + (Math.random() - 0.5 * 0.1), te.getPos().getZ() + (Math.random() - 0.5 * 0.1))) { - if(!world.isRemote) + if (tile.getCurrentMana() >= COST_AVATAR && tile.getElapsedFunctionalTicks() % 3 == 0 && tile.isEnabled()) { + if (spawnMissile(world, null, te.getPos().getX() + 0.5 + (Math.random() - 0.5 * 0.1), te.getPos().getY() + 2.5 + (Math.random() - 0.5 * 0.1), te.getPos().getZ() + (Math.random() - 0.5 * 0.1))) { + if (!world.isRemote) { tile.recieveMana(-COST_AVATAR); - SparkleParticleData data = SparkleParticleData.sparkle(6F, 1F, 0.4F, 1F, 6); - world.addParticle(data, te.getPos().getX() + 0.5, te.getPos().getY() + 2.5, te.getPos().getZ() + 0.5, 0, 0, 0); - } + } + SparkleParticleData data = SparkleParticleData.sparkle(6F, 1F, 0.4F, 1F, 6); + world.addParticle(data, te.getPos().getX() + 0.5, te.getPos().getY() + 2.5, te.getPos().getZ() + 0.5, 0, 0, 0); + } + } } @Override diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemRainbowRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemRainbowRod.java index 107ae3ae8..1606ddb5f 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemRainbowRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemRainbowRod.java @@ -1,17 +1,16 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 20, 2014, 7:09:51 PM (GMT)] */ package vazkii.botania.common.item.rod; import net.minecraft.block.Block; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.TileEntity; @@ -24,6 +23,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; + import vazkii.botania.api.item.IAvatarTile; import vazkii.botania.api.item.IAvatarWieldable; import vazkii.botania.api.item.IManaProficiencyArmor; @@ -34,9 +34,9 @@ import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.tile.TileBifrost; import vazkii.botania.common.core.handler.ModSounds; import vazkii.botania.common.core.helper.Vector3; -import net.minecraft.item.Item; import javax.annotation.Nonnull; + import java.util.List; public class ItemRainbowRod extends Item implements IManaUsingItem, IAvatarWieldable { @@ -55,7 +55,7 @@ public class ItemRainbowRod extends Item implements IManaUsingItem, IAvatarWield @Override public ActionResult onItemRightClick(World world, PlayerEntity player, @Nonnull Hand hand) { ItemStack stack = player.getHeldItem(hand); - if(!world.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, MANA_COST, false)) { + if (!world.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, MANA_COST, false)) { Block place = ModBlocks.bifrost; Vector3 vector = new Vector3(player.getLookVec()).normalize(); @@ -80,26 +80,27 @@ public class ItemRainbowRod extends Item implements IManaUsingItem, IAvatarWield if (!lastChecker.equals(pos)) { if (y >= world.getHeight() || y <= 0 - || !world.isAirBlock(pos) && world.getBlockState(pos).getBlock() != place) + || !world.isAirBlock(pos) && world.getBlockState(pos).getBlock() != place) { break; + } - for(int i = -2; i < 1; i++) - for(int j = -2; j < 1; j++) { + for (int i = -2; i < 1; i++) { + for (int j = -2; j < 1; j++) { placePos.setPos(pos.getX() + i, pos.getY(), pos.getZ() + j); - if(world.isAirBlock(placePos) + if (world.isAirBlock(placePos) || world.getBlockState(placePos).getBlock() == place) { world.setBlockState(placePos, place.getDefaultState(), 2); TileBifrost tile = (TileBifrost) world.getTileEntity(placePos); - if(tile != null) { + if (tile != null) { tile.ticks = time; } } } + } count++; } - lastX = x; lastY = y; lastZ = z; @@ -110,7 +111,7 @@ public class ItemRainbowRod extends Item implements IManaUsingItem, IAvatarWield pos.setPos(x, y, z); } - if(count > 0) { + if (count > 0) { world.playSound(null, player.getX(), player.getY(), player.getZ(), ModSounds.bifrostRod, SoundCategory.PLAYERS, 0.5F, 0.25F); ManaItemHandler.requestManaExactForTool(stack, player, MANA_COST, false); player.getCooldownTracker().setCooldown(this, TIME); @@ -141,8 +142,9 @@ public class ItemRainbowRod extends Item implements IManaUsingItem, IAvatarWield TileEntity te = (TileEntity) tile; World world = te.getWorld(); - if(world.isRemote || tile.getCurrentMana() < MANA_COST_AVATAR * 25 || !tile.isEnabled()) + if (world.isRemote || tile.getCurrentMana() < MANA_COST_AVATAR * 25 || !tile.isEnabled()) { return; + } BlockPos tePos = te.getPos(); int w = 1; @@ -150,54 +152,56 @@ public class ItemRainbowRod extends Item implements IManaUsingItem, IAvatarWield int l = 20; AxisAlignedBB axis = null; - switch(world.getBlockState(tePos).get(BlockStateProperties.HORIZONTAL_FACING)) { - case NORTH : + switch (world.getBlockState(tePos).get(BlockStateProperties.HORIZONTAL_FACING)) { + case NORTH: axis = new AxisAlignedBB(tePos.add(-w, -h, -l), tePos.add(w + 1, h, 0)); break; - case SOUTH : + case SOUTH: axis = new AxisAlignedBB(tePos.add(-w, -h, 1), tePos.add(w + 1, h, l + 1)); break; - case WEST : + case WEST: axis = new AxisAlignedBB(tePos.add(-l, -h, -w), tePos.add(0, h, w + 1)); break; - case EAST : + case EAST: axis = new AxisAlignedBB(tePos.add(1, -h, -w), tePos.add(l + 1, h, w + 1)); - default: break; + default: + break; } List players = world.getEntitiesWithinAABB(PlayerEntity.class, axis); - for(PlayerEntity p : players) { + for (PlayerEntity p : players) { int px = MathHelper.floor(p.getX()); int py = MathHelper.floor(p.getY()) - 1; int pz = MathHelper.floor(p.getZ()); int dist = 5; int diff = dist / 2; - for(int i = 0; i < dist; i++) - for(int j = 0; j < dist; j++) { + for (int i = 0; i < dist; i++) { + for (int j = 0; j < dist; j++) { int ex = px + i - diff; int ez = pz + j - diff; - if(!axis.contains(new Vec3d(ex + 0.5, py + 1, ez + 0.5))) + if (!axis.contains(new Vec3d(ex + 0.5, py + 1, ez + 0.5))) { continue; + } BlockPos pos = new BlockPos(ex, py, ez); Block block = world.getBlockState(pos).getBlock(); - if(block.isAir(world.getBlockState(pos), world, pos)) { + if (block.isAir(world.getBlockState(pos), world, pos)) { world.setBlockState(pos, ModBlocks.bifrost.getDefaultState()); TileBifrost tileBifrost = (TileBifrost) world.getTileEntity(pos); tileBifrost.ticks = 10; tile.recieveMana(-MANA_COST_AVATAR); - } else if(block == ModBlocks.bifrost) { + } else if (block == ModBlocks.bifrost) { TileBifrost tileBifrost = (TileBifrost) world.getTileEntity(pos); - if(tileBifrost.ticks < 2) { + if (tileBifrost.ticks < 2) { tileBifrost.ticks = 10; tile.recieveMana(-MANA_COST_AVATAR); } } } + } } - } @Override diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemSkyDirtRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemSkyDirtRod.java index dd1802f80..0df96870b 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemSkyDirtRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemSkyDirtRod.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 23, 2014, 1:06:51 AM (GMT)] */ package vazkii.botania.common.item.rod; @@ -16,7 +14,6 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.Hand; import net.minecraft.util.math.AxisAlignedBB; @@ -25,6 +22,7 @@ import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; + import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.client.fx.SparkleParticleData; import vazkii.botania.common.core.helper.PlayerHelper; @@ -42,7 +40,7 @@ public class ItemSkyDirtRod extends ItemDirtRod { @Override public ActionResult onItemRightClick(World world, PlayerEntity player, @Nonnull Hand hand) { ItemStack stack = player.getHeldItem(hand); - if(!world.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, COST * 2, false)) { + if (!world.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, COST * 2, false)) { Vector3 playerVec = Vector3.fromEntityCenter(player); Vector3 lookVec = new Vector3(player.getLookVec()).multiply(3); Vector3 placeVec = playerVec.add(lookVec); @@ -53,22 +51,23 @@ public class ItemSkyDirtRod extends ItemDirtRod { int entities = world.getEntitiesWithinAABB(LivingEntity.class, new AxisAlignedBB(x, y, z, x + 1, y + 1, z + 1)).size(); - if(entities == 0) { + if (entities == 0) { ItemStack stackToPlace = new ItemStack(Blocks.DIRT); BlockRayTraceResult hit = new BlockRayTraceResult(Vec3d.ZERO, Direction.DOWN, new BlockPos(x, y, z), false); PlayerHelper.substituteUse(new ItemUseContext(player, hand, hit), stackToPlace); - if(stackToPlace.isEmpty()) { + if (stackToPlace.isEmpty()) { ManaItemHandler.requestManaExactForTool(stack, player, COST * 2, true); SparkleParticleData data = SparkleParticleData.sparkle(1F, 0.35F, 0.2F, 0.05F, 5); - for(int i = 0; i < 6; i++) { + for (int i = 0; i < 6; i++) { world.addParticle(data, x + Math.random(), y + Math.random(), z + Math.random(), 0, 0, 0); } } } } - if(world.isRemote) + if (world.isRemote) { player.swingArm(hand); + } return ActionResult.success(stack); } diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemSmeltRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemSmeltRod.java index 62bd19419..a3ce2dee4 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemSmeltRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemSmeltRod.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 24, 2015, 11:05:41 PM (GMT)] */ package vazkii.botania.common.item.rod; @@ -17,6 +15,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Inventory; import net.minecraft.item.BlockItem; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.UseAction; import net.minecraft.item.crafting.IRecipeType; @@ -25,17 +24,17 @@ import net.minecraft.util.Hand; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceContext; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; + import vazkii.botania.api.item.IManaProficiencyArmor; import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.client.fx.WispParticleData; -import net.minecraft.item.Item; import vazkii.botania.common.item.equipment.tool.ToolCommons; import javax.annotation.Nonnull; + import java.util.Map; import java.util.Optional; import java.util.WeakHashMap; @@ -72,37 +71,40 @@ public class ItemSmeltRod extends Item implements IManaUsingItem { @Override public void onUsingTick(ItemStack stack, LivingEntity living, int time) { - if(!(living instanceof PlayerEntity)) return; + if (!(living instanceof PlayerEntity)) { + return; + } PlayerEntity p = (PlayerEntity) living; IInventory dummyInv = new Inventory(1); - if(!ManaItemHandler.requestManaExactForTool(stack, p, COST_PER_TICK, false)) + if (!ManaItemHandler.requestManaExactForTool(stack, p, COST_PER_TICK, false)) { return; + } BlockRayTraceResult pos = ToolCommons.raytraceFromEntity(p, 32, false); - if(pos.getType() == RayTraceResult.Type.BLOCK) { + if (pos.getType() == RayTraceResult.Type.BLOCK) { BlockState state = p.world.getBlockState(pos.getPos()); dummyInv.setInventorySlotContents(0, new ItemStack(state.getBlock())); - Optional maybeResult= p.world.getRecipeManager() + Optional maybeResult = p.world.getRecipeManager() .getRecipe(IRecipeType.SMELTING, dummyInv, p.world) .map(r -> r.getCraftingResult(dummyInv)); - if(maybeResult.isPresent() + if (maybeResult.isPresent() && !maybeResult.get().isEmpty() && maybeResult.get().getItem() instanceof BlockItem) { ItemStack result = maybeResult.get(); boolean decremented = false; - if(playerData.containsKey(p)) { + if (playerData.containsKey(p)) { SmeltData data = playerData.get(p); - if(data.equalPos(pos)) { + if (data.equalPos(pos)) { data.progress--; decremented = true; - if(data.progress <= 0) { - if(!p.world.isRemote) { + if (data.progress <= 0) { + if (!p.world.isRemote) { p.world.setBlockState(pos.getPos(), Block.getBlockFromItem(result.getItem()).getDefaultState()); p.world.playSound(null, p.getX(), p.getY(), p.getZ(), SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.PLAYERS, 0.6F, 1F); p.world.playSound(null, p.getX(), p.getY(), p.getZ(), SoundEvents.BLOCK_FIRE_AMBIENT, SoundCategory.PLAYERS, 1F, 1F); @@ -113,7 +115,7 @@ public class ItemSmeltRod extends Item implements IManaUsingItem { } WispParticleData data1 = WispParticleData.wisp(0.5F, 1F, 0.2F, 0.2F, 1); - for(int i = 0; i < 25; i++) { + for (int i = 0; i < 25; i++) { double x = pos.getPos().getX() + Math.random(); double y = pos.getPos().getY() + Math.random(); double z = pos.getPos().getZ() + Math.random(); @@ -123,18 +125,19 @@ public class ItemSmeltRod extends Item implements IManaUsingItem { } } - if(!decremented) + if (!decremented) { playerData.put(p, new SmeltData(pos, IManaProficiencyArmor.hasProficiency(p, stack) ? (int) (TIME * 0.6) : TIME)); - else { - for(int i = 0; i < 2; i++) { + } else { + for (int i = 0; i < 2; i++) { double x = pos.getPos().getX() + Math.random(); double y = pos.getPos().getY() + Math.random(); double z = pos.getPos().getZ() + Math.random(); - WispParticleData data = WispParticleData.wisp(0.5F, 1F, 0.2F, 0.2F, 1); - p.world.addParticle(data, x, y, z, 0, (float) Math.random() / 10F, 0); - } - if(time % 10 == 0) + WispParticleData data = WispParticleData.wisp(0.5F, 1F, 0.2F, 0.2F, 1); + p.world.addParticle(data, x, y, z, 0, (float) Math.random() / 10F, 0); + } + if (time % 10 == 0) { p.world.playSound(null, p.getX(), p.getY(), p.getZ(), SoundEvents.BLOCK_FIRE_AMBIENT, SoundCategory.PLAYERS, (float) Math.random() / 2F + 0.5F, 1F); + } } } } diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemTerraformRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemTerraformRod.java index 20ffea5d9..6e1efe89d 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemTerraformRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemTerraformRod.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Apr 11, 2014, 2:56:39 PM (GMT)] */ package vazkii.botania.common.item.rod; import com.google.common.collect.ImmutableList; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -28,6 +27,7 @@ import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import vazkii.botania.api.item.IBlockProvider; import vazkii.botania.api.item.IManaProficiencyArmor; import vazkii.botania.api.mana.IManaUsingItem; @@ -37,6 +37,7 @@ import vazkii.botania.common.core.helper.MathHelper; import vazkii.botania.common.lib.ModTags; import javax.annotation.Nonnull; + import java.util.ArrayList; import java.util.List; @@ -55,7 +56,7 @@ public class ItemTerraformRod extends Item implements IManaUsingItem, IBlockProv "blockMarble", "limestone", "blockLimestone" - ); + ); public ItemTerraformRod(Properties props) { super(props); @@ -74,8 +75,9 @@ public class ItemTerraformRod extends Item implements IManaUsingItem, IBlockProv @Override public void onUsingTick(ItemStack stack, LivingEntity living, int count) { - if(count != getUseDuration(stack) && count % 10 == 0 && living instanceof PlayerEntity) + if (count != getUseDuration(stack) && count % 10 == 0 && living instanceof PlayerEntity) { terraform(stack, living.world, (PlayerEntity) living); + } } @Nonnull @@ -90,36 +92,42 @@ public class ItemTerraformRod extends Item implements IManaUsingItem, IBlockProv BlockPos startCenter = new BlockPos(player).down(); - if(startCenter.getY() < world.getSeaLevel()) // Not below sea level + if (startCenter.getY() < world.getSeaLevel()) // Not below sea level + { return; + } List blocks = new ArrayList<>(); - for(BlockPos pos : BlockPos.getAllInBoxMutable(startCenter.add(-range, -range, -range), startCenter.add(range, range, range))) { + for (BlockPos pos : BlockPos.getAllInBoxMutable(startCenter.add(-range, -range, -range), startCenter.add(range, range, range))) { BlockState state = world.getBlockState(pos); - if(state.isAir(world, pos)) + if (state.isAir(world, pos)) { continue; + } - if(ModTags.Blocks.TERRAFORMABLE.contains(state.getBlock())) { + if (ModTags.Blocks.TERRAFORMABLE.contains(state.getBlock())) { List airBlocks = new ArrayList<>(); - for(Direction dir : MathHelper.HORIZONTALS) { + for (Direction dir : MathHelper.HORIZONTALS) { BlockPos pos_ = pos.offset(dir); BlockState state_ = world.getBlockState(pos_); Block block_ = state_.getBlock(); - if(state_.isAir(world, pos_) || state_.getMaterial().isReplaceable() + if (state_.isAir(world, pos_) || state_.getMaterial().isReplaceable() || block_ instanceof FlowerBlock && !block_.isIn(ModTags.Blocks.SPECIAL_FLOWERS) || block_ instanceof DoublePlantBlock) { airBlocks.add(pos_); } } - if(!airBlocks.isEmpty()) { - if(pos.getY() > startCenter.getY()) + if (!airBlocks.isEmpty()) { + if (pos.getY() > startCenter.getY()) { blocks.add(new CoordsWithBlock(pos, Blocks.AIR)); - else for(BlockPos coords : airBlocks) { - if(!world.isAirBlock(coords.down())) - blocks.add(new CoordsWithBlock(coords, Blocks.DIRT)); + } else { + for (BlockPos coords : airBlocks) { + if (!world.isAirBlock(coords.down())) { + blocks.add(new CoordsWithBlock(coords, Blocks.DIRT)); + } + } } } } @@ -127,17 +135,21 @@ public class ItemTerraformRod extends Item implements IManaUsingItem, IBlockProv int cost = COST_PER * blocks.size(); - if(world.isRemote || ManaItemHandler.requestManaExactForTool(stack, player, cost, true)) { - if(!world.isRemote) - for(CoordsWithBlock block : blocks) + if (world.isRemote || ManaItemHandler.requestManaExactForTool(stack, player, cost, true)) { + if (!world.isRemote) { + for (CoordsWithBlock block : blocks) { world.setBlockState(block, block.block.getDefaultState()); + } + } - if(!blocks.isEmpty()) { - for(int i = 0; i < 10; i++) + if (!blocks.isEmpty()) { + for (int i = 0; i < 10; i++) { world.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.BLOCK_SAND_STEP, SoundCategory.BLOCKS, 1F, 0.4F); + } SparkleParticleData data = SparkleParticleData.sparkle(2F, 0.35F, 0.2F, 0.05F, 5); - for(int i = 0; i < 120; i++) - world.addParticle(data, startCenter.getX() - range + range * 2 * Math.random(), startCenter.getY() + 2 + (Math.random() - 0.5) * 2, startCenter.getZ() - range + range * 2 * Math.random(), 0, 0, 0); + for (int i = 0; i < 120; i++) { + world.addParticle(data, startCenter.getX() - range + range * 2 * Math.random(), startCenter.getY() + 2 + (Math.random() - 0.5) * 2, startCenter.getZ() - range + range * 2 * Math.random(), 0, 0, 0); + } } } } @@ -160,15 +172,17 @@ public class ItemTerraformRod extends Item implements IManaUsingItem, IBlockProv @Override public boolean provideBlock(PlayerEntity player, ItemStack requestor, ItemStack stack, Block block, boolean doit) { - if(block == Blocks.DIRT) + if (block == Blocks.DIRT) { return !doit || ManaItemHandler.requestManaExactForTool(requestor, player, ItemDirtRod.COST, true); + } return false; } @Override public int getBlockCount(PlayerEntity player, ItemStack requestor, ItemStack stack, Block block) { - if(block == Blocks.DIRT) + if (block == Blocks.DIRT) { return -1; + } return 0; } } diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemTornadoRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemTornadoRod.java index 496f981f3..9e07fe9d9 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemTornadoRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemTornadoRod.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jun 25, 2014, 4:36:13 PM (GMT)] */ package vazkii.botania.common.item.rod; @@ -23,6 +21,7 @@ import net.minecraft.util.SoundCategory; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; + import vazkii.botania.api.item.IAvatarTile; import vazkii.botania.api.item.IAvatarWieldable; import vazkii.botania.api.item.IManaProficiencyArmor; @@ -35,6 +34,7 @@ import vazkii.botania.common.core.handler.ModSounds; import vazkii.botania.common.core.helper.ItemNBTHelper; import javax.annotation.Nonnull; + import java.util.List; public class ItemTornadoRod extends Item implements IManaUsingItem, IAvatarWieldable { @@ -56,37 +56,40 @@ public class ItemTornadoRod extends Item implements IManaUsingItem, IAvatarWield @Override public void inventoryTick(ItemStack stack, World world, Entity ent, int slot, boolean active) { - if(ent instanceof PlayerEntity) { + if (ent instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity) ent; boolean damaged = getFlyCounter(stack) > 0; boolean held = player.getHeldItemMainhand() == stack || player.getHeldItemOffhand() == stack; - if(damaged && !isFlying(stack)) + if (damaged && !isFlying(stack)) { setFlyCounter(stack, getFlyCounter(stack) - 1); + } - if(getFlyCounter(stack) >= MAX_COUNTER) { + if (getFlyCounter(stack) >= MAX_COUNTER) { setFlying(stack, false); - } else if(isFlying(stack)) { - if(held) { + } else if (isFlying(stack)) { + if (held) { player.fallDistance = 0F; - double my = IManaProficiencyArmor.hasProficiency(player, stack) ? 1.6 : 1.25; + double my = IManaProficiencyArmor.hasProficiency(player, stack) ? 1.6 : 1.25; Vec3d oldMot = player.getMotion(); player.setMotion(new Vec3d(oldMot.getX(), my, oldMot.getZ())); player.playSound(ModSounds.airRod, 0.1F, 0.25F); - for(int i = 0; i < 5; i++) { + for (int i = 0; i < 5; i++) { WispParticleData data = WispParticleData.wisp(0.35F + (float) Math.random() * 0.1F, 0.25F, 0.25F, 0.25F); world.addParticle(data, player.getX(), player.getY(), player.getZ(), 0.2F * (float) (Math.random() - 0.5), -0.01F * (float) Math.random(), 0.2F * (float) (Math.random() - 0.5)); } } setFlyCounter(stack, getFlyCounter(stack) + FALL_MULTIPLIER); - if(getFlyCounter(stack) == MAX_COUNTER) + if (getFlyCounter(stack) == MAX_COUNTER) { setFlying(stack, false); + } } - if(damaged) + if (damaged) { player.fallDistance = 0; + } } } @@ -105,7 +108,7 @@ public class ItemTornadoRod extends Item implements IManaUsingItem, IAvatarWield public ActionResult onItemRightClick(World world, PlayerEntity player, @Nonnull Hand hand) { ItemStack stack = player.getHeldItem(hand); int fly = getFlyCounter(stack); - if(fly == 0 && ManaItemHandler.requestManaExactForTool(stack, player, COST, false)) { + if (fly == 0 && ManaItemHandler.requestManaExactForTool(stack, player, COST, false)) { ManaItemHandler.requestManaExactForTool(stack, player, COST, true); setFlying(stack, true); return ActionResult.success(stack); @@ -139,21 +142,22 @@ public class ItemTornadoRod extends Item implements IManaUsingItem, IAvatarWield public void onAvatarUpdate(IAvatarTile tile, ItemStack stack) { TileEntity te = (TileEntity) tile; World world = te.getWorld(); - if(tile.getCurrentMana() >= COST && tile.isEnabled()) { + if (tile.getCurrentMana() >= COST && tile.isEnabled()) { int range = 5; int rangeY = 3; List players = world.getEntitiesWithinAABB(PlayerEntity.class, new AxisAlignedBB(te.getPos().add(-0.5 - range, -0.5 - rangeY, -0.5 - range), te.getPos().add(0.5 + range, 0.5 + rangeY, 0.5 + range))); - for(PlayerEntity p : players) { - if(p.getMotion().getY() > 0.3 && p.getMotion().getY() < 2 && !p.isSneaking()) { + for (PlayerEntity p : players) { + if (p.getMotion().getY() > 0.3 && p.getMotion().getY() < 2 && !p.isSneaking()) { p.setMotion(p.getMotion().getX(), 2.8, p.getMotion().getZ()); - for(int i = 0; i < 20; i++) - for(int j = 0; j < 5; j++) { - WispParticleData data = WispParticleData.wisp(0.35F + (float) Math.random() * 0.1F, 0.25F, 0.25F, 0.25F); - world.addParticle(data, p.getX(), p.getY() + i, p.getZ(), 0.2F * (float) (Math.random() - 0.5), -0.01F * (float) Math.random(), 0.2F * (float) (Math.random() - 0.5)); - } + for (int i = 0; i < 20; i++) { + for (int j = 0; j < 5; j++) { + WispParticleData data = WispParticleData.wisp(0.35F + (float) Math.random() * 0.1F, 0.25F, 0.25F, 0.25F); + world.addParticle(data, p.getX(), p.getY() + i, p.getZ(), 0.2F * (float) (Math.random() - 0.5), -0.01F * (float) Math.random(), 0.2F * (float) (Math.random() - 0.5)); + } + } - if(!world.isRemote) { + if (!world.isRemote) { p.world.playSound(null, p.getX(), p.getY(), p.getZ(), ModSounds.dash, SoundCategory.PLAYERS, 1F, 1F); p.addPotionEffect(new EffectInstance(ModPotions.featherfeet, 100, 0)); tile.recieveMana(-COST); diff --git a/src/main/java/vazkii/botania/common/item/rod/ItemWaterRod.java b/src/main/java/vazkii/botania/common/item/rod/ItemWaterRod.java index 8fc759ee4..b390692e2 100644 --- a/src/main/java/vazkii/botania/common/item/rod/ItemWaterRod.java +++ b/src/main/java/vazkii/botania/common/item/rod/ItemWaterRod.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.common.item.rod; import net.minecraft.advancements.CriteriaTriggers; @@ -18,10 +26,10 @@ import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.RayTraceContext; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; + import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.client.fx.SparkleParticleData; -import net.minecraft.item.Item; import javax.annotation.Nonnull; @@ -40,13 +48,15 @@ public class ItemWaterRod extends Item implements IManaUsingItem { ItemStack itemstack = playerIn.getHeldItem(handIn); RayTraceResult raytraceresult = rayTrace(worldIn, playerIn, RayTraceContext.FluidMode.NONE); ActionResult ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(playerIn, worldIn, itemstack, raytraceresult); - if (ret != null) return ret; + if (ret != null) { + return ret; + } if (raytraceresult.getType() == RayTraceResult.Type.MISS) { return new ActionResult<>(ActionResultType.PASS, itemstack); } else if (raytraceresult.getType() != RayTraceResult.Type.BLOCK) { return new ActionResult<>(ActionResultType.PASS, itemstack); } else { - BlockRayTraceResult blockraytraceresult = (BlockRayTraceResult)raytraceresult; + BlockRayTraceResult blockraytraceresult = (BlockRayTraceResult) raytraceresult; BlockPos blockpos = blockraytraceresult.getPos(); if (worldIn.isBlockModifiable(playerIn, blockpos) && playerIn.canPlayerEdit(blockpos, blockraytraceresult.getFace(), itemstack)) { BlockState blockstate = worldIn.getBlockState(blockpos); @@ -54,13 +64,14 @@ public class ItemWaterRod extends Item implements IManaUsingItem { if (ManaItemHandler.requestManaExactForTool(itemstack, playerIn, COST, true) && ((BucketItem) Items.WATER_BUCKET).tryPlaceContainedLiquid(playerIn, worldIn, blockpos1, blockraytraceresult)) { if (playerIn instanceof ServerPlayerEntity) { - CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayerEntity)playerIn, blockpos1, itemstack); + CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayerEntity) playerIn, blockpos1, itemstack); } playerIn.addStat(Stats.ITEM_USED.get(this)); SparkleParticleData data = SparkleParticleData.sparkle(1F, 0.2F, 0.2F, 1F, 5); - for(int i = 0; i < 6; i++) - playerIn.world.addParticle(data, blockpos1.getX() + Math.random(), blockpos1.getY() + Math.random(), blockpos1.getZ() + Math.random(), 0, 0, 0); + for (int i = 0; i < 6; i++) { + playerIn.world.addParticle(data, blockpos1.getX() + Math.random(), blockpos1.getY() + Math.random(), blockpos1.getZ() + Math.random(), 0, 0, 0); + } return new ActionResult<>(ActionResultType.SUCCESS, itemstack); } else { return new ActionResult<>(ActionResultType.FAIL, itemstack); diff --git a/src/main/java/vazkii/botania/common/lib/LibBlockNames.java b/src/main/java/vazkii/botania/common/lib/LibBlockNames.java index 9623e6930..bfd3a0953 100644 --- a/src/main/java/vazkii/botania/common/lib/LibBlockNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibBlockNames.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 16, 2014, 5:55:03 PM (GMT)] */ package vazkii.botania.common.lib; @@ -54,14 +52,14 @@ public final class LibBlockNames { public static final String OPEN_CRATE = "open_crate"; public static final String CRAFT_CRATE = "crafty_crate"; public static final String FOREST_EYE = "forest_eye"; - public static final String MANASTEEL_BLOCK = "manasteel_block"; - public static final String TERRASTEEL_BLOCK = "terrasteel_block"; - public static final String ELEMENTIUM_BLOCK = "elementium_block"; - public static final String MANA_DIAMOND_BLOCK = "mana_diamond_block"; - public static final String DRAGONSTONE_BLOCK = "dragonstone_block"; + public static final String MANASTEEL_BLOCK = "manasteel_block"; + public static final String TERRASTEEL_BLOCK = "terrasteel_block"; + public static final String ELEMENTIUM_BLOCK = "elementium_block"; + public static final String MANA_DIAMOND_BLOCK = "mana_diamond_block"; + public static final String DRAGONSTONE_BLOCK = "dragonstone_block"; public static final String DRUM_WILD = "drum_wild"; - public static final String DRUM_GATHERING = "drum_gathering"; - public static final String DRUM_CANOPY = "drum_canopy"; + public static final String DRUM_GATHERING = "drum_gathering"; + public static final String DRUM_CANOPY = "drum_canopy"; public static final String SHINY_FLOWER_SUFFIX = "_shiny_flower"; public static final String PLATFORM = "platform"; public static final String PLATFORM_ABSTRUSE = "abstruse_platform"; @@ -142,12 +140,12 @@ public final class LibBlockNames { public static final String ALT_GRASS_SUFFIX = "_grass"; public static final String ANIMATED_TORCH = "animated_torch"; public static final String METAMORPHIC_PREFIX = "metamorphic_"; - public static final String[] METAMORPHIC_VARIANTS = { + public static final String[] METAMORPHIC_VARIANTS = { "forest", "plains", "mountain", "fungal", "swamp", "desert", "taiga", "mesa" }; public static final String SLAB_SUFFIX = "_slab"; - public static final String STAIR_SUFFIX = "_stairs"; + public static final String STAIR_SUFFIX = "_stairs"; public static final String WALL_SUFFIX = "_wall"; public static final String FENCE_SUFFIX = "_fence"; public static final String FENCE_GATE_SUFFIX = "_fence_gate"; diff --git a/src/main/java/vazkii/botania/common/lib/LibBrewNames.java b/src/main/java/vazkii/botania/common/lib/LibBrewNames.java index edef26c82..94038a12c 100644 --- a/src/main/java/vazkii/botania/common/lib/LibBrewNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibBrewNames.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 1, 2014, 7:03:57 PM (GMT)] */ package vazkii.botania.common.lib; diff --git a/src/main/java/vazkii/botania/common/lib/LibEntityNames.java b/src/main/java/vazkii/botania/common/lib/LibEntityNames.java index 6f6012580..c8df5393c 100644 --- a/src/main/java/vazkii/botania/common/lib/LibEntityNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibEntityNames.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 26, 2014, 5:30:03 PM (GMT)] */ package vazkii.botania.common.lib; @@ -32,7 +30,7 @@ public final class LibEntityNames { public static final ResourceLocation MANA_STORM = makeName("mana_storm"); public static final ResourceLocation BABYLON_WEAPON = makeName("babylon_weapon"); public static final ResourceLocation FALLING_STAR = makeName("falling_star"); - + private static ResourceLocation makeName(String s) { return new ResourceLocation(LibMisc.MOD_ID, s); } diff --git a/src/main/java/vazkii/botania/common/lib/LibGuiIDs.java b/src/main/java/vazkii/botania/common/lib/LibGuiIDs.java index 5160ed97c..2bd4c6bc1 100644 --- a/src/main/java/vazkii/botania/common/lib/LibGuiIDs.java +++ b/src/main/java/vazkii/botania/common/lib/LibGuiIDs.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 14, 2014, 6:50:36 PM (GMT)] */ package vazkii.botania.common.lib; diff --git a/src/main/java/vazkii/botania/common/lib/LibItemNames.java b/src/main/java/vazkii/botania/common/lib/LibItemNames.java index 0ced26e7c..239ea7348 100644 --- a/src/main/java/vazkii/botania/common/lib/LibItemNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibItemNames.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 14, 2014, 5:49:06 PM (GMT)] */ package vazkii.botania.common.lib; @@ -19,7 +17,7 @@ public final class LibItemNames { public static final String DYE_SUFFIX = "_" + DYE; public static final String PESTLE_AND_MORTAR = "pestle_and_mortar"; public static final String TWIG_WAND = "twig_wand"; - + public static final String RUNE_WATER = "rune_water"; public static final String RUNE_FIRE = "rune_fire"; public static final String RUNE_EARTH = "rune_earth"; @@ -87,7 +85,7 @@ public final class LibItemNames { public static final String DIVA_CHARM = "diva_charm"; public static final String FLIGHT_TIARA = "flight_tiara"; public static final String ENDER_DAGGER = "ender_dagger"; - + public static final String QUARTZ_DARK = "quartz_dark"; public static final String QUARTZ_MANA = "quartz_mana"; public static final String QUARTZ_BLAZE = "quartz_blaze"; @@ -253,5 +251,5 @@ public final class LibItemNames { public static final String PEBBLE = "pebble"; public static final String MANAWEAVE_CLOTH = "manaweave_cloth"; public static final String MANA_POWDER = "mana_powder"; - + } diff --git a/src/main/java/vazkii/botania/common/lib/LibMisc.java b/src/main/java/vazkii/botania/common/lib/LibMisc.java index 810977c8b..244115ed0 100644 --- a/src/main/java/vazkii/botania/common/lib/LibMisc.java +++ b/src/main/java/vazkii/botania/common/lib/LibMisc.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 13, 2014, 6:32:05 PM (GMT)] */ package vazkii.botania.common.lib; diff --git a/src/main/java/vazkii/botania/common/lib/LibObfuscation.java b/src/main/java/vazkii/botania/common/lib/LibObfuscation.java index 09dc76361..3fc22d69f 100644 --- a/src/main/java/vazkii/botania/common/lib/LibObfuscation.java +++ b/src/main/java/vazkii/botania/common/lib/LibObfuscation.java @@ -1,29 +1,28 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jan 17, 2014, 4:52:15 PM (GMT)] */ package vazkii.botania.common.lib; -import cpw.mods.modlauncher.api.INameMappingService; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.reflect.Field; +import cpw.mods.modlauncher.api.INameMappingService; + public final class LibObfuscation { // EntityLiving public static final String GET_LIVING_SOUND = "func_184639_G"; - + // RecipeBookGui public static final String RECIPE_BOOK_PAGE = "field_193022_s"; - + // RecipeBookPage public static final String HOVERED_BUTTON = "field_194201_b"; diff --git a/src/main/java/vazkii/botania/common/lib/LibPotionNames.java b/src/main/java/vazkii/botania/common/lib/LibPotionNames.java index 45b9ad170..22cc679d3 100644 --- a/src/main/java/vazkii/botania/common/lib/LibPotionNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibPotionNames.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Nov 2, 2014, 10:33:37 PM (GMT)] */ package vazkii.botania.common.lib; diff --git a/src/main/java/vazkii/botania/common/lib/LibTriggerNames.java b/src/main/java/vazkii/botania/common/lib/LibTriggerNames.java index 6fc99c6bb..b65d90797 100644 --- a/src/main/java/vazkii/botania/common/lib/LibTriggerNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibTriggerNames.java @@ -1,6 +1,13 @@ +/* + * This class is 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 + */ package vazkii.botania.common.lib; - public class LibTriggerNames { public static final String TRIGGER_PREFIX = "botania.triggers."; diff --git a/src/main/java/vazkii/botania/common/lib/ModTags.java b/src/main/java/vazkii/botania/common/lib/ModTags.java index a3b7f57c4..4f2cd6e06 100644 --- a/src/main/java/vazkii/botania/common/lib/ModTags.java +++ b/src/main/java/vazkii/botania/common/lib/ModTags.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Oct 06 2019, 8:12 PM (GMT)] */ package vazkii.botania.common.lib; @@ -101,7 +99,7 @@ public class ModTags { public static final Tag RUNES_WATER = tag("runes/water"); public static final Tag RUNES_WINTER = tag("runes/winter"); public static final Tag RUNES_WRATH = tag("runes/wrath"); - + public static Tag getFlowerTag(DyeColor color) { switch (color) { default: @@ -194,4 +192,3 @@ public class ModTags { } } } - diff --git a/src/main/java/vazkii/botania/common/lib/ResourceLocationHelper.java b/src/main/java/vazkii/botania/common/lib/ResourceLocationHelper.java index 1cea1f5b5..57257942e 100644 --- a/src/main/java/vazkii/botania/common/lib/ResourceLocationHelper.java +++ b/src/main/java/vazkii/botania/common/lib/ResourceLocationHelper.java @@ -1,6 +1,6 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @@ -11,7 +11,7 @@ package vazkii.botania.common.lib; import net.minecraft.util.ResourceLocation; public class ResourceLocationHelper { - public static ResourceLocation prefix(String path) { - return new ResourceLocation(LibMisc.MOD_ID, path); - } + public static ResourceLocation prefix(String path) { + return new ResourceLocation(LibMisc.MOD_ID, path); + } } diff --git a/src/main/java/vazkii/botania/common/network/ILoginPacket.java b/src/main/java/vazkii/botania/common/network/ILoginPacket.java index 2bd5fb9b3..85a441ed9 100644 --- a/src/main/java/vazkii/botania/common/network/ILoginPacket.java +++ b/src/main/java/vazkii/botania/common/network/ILoginPacket.java @@ -1,19 +1,17 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [2020-01-13, 17:34 (UTC+2)] */ package vazkii.botania.common.network; import java.util.function.IntSupplier; public interface ILoginPacket extends IntSupplier { - + void setLoginIndex(int index); int getLoginIndex(); diff --git a/src/main/java/vazkii/botania/common/network/PacketAck.java b/src/main/java/vazkii/botania/common/network/PacketAck.java index ee4fdf18b..7b12d9cdd 100644 --- a/src/main/java/vazkii/botania/common/network/PacketAck.java +++ b/src/main/java/vazkii/botania/common/network/PacketAck.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [2020-01-13, 17:43 (UTC+2)] */ package vazkii.botania.common.network; @@ -21,7 +19,7 @@ public class PacketAck implements ILoginPacket { public static PacketAck decode(PacketBuffer buf) { return new PacketAck(); } - + @Override public void setLoginIndex(int index) { this.loginIndex = index; diff --git a/src/main/java/vazkii/botania/common/network/PacketBotaniaEffect.java b/src/main/java/vazkii/botania/common/network/PacketBotaniaEffect.java index 178711d8c..ee3dac472 100644 --- a/src/main/java/vazkii/botania/common/network/PacketBotaniaEffect.java +++ b/src/main/java/vazkii/botania/common/network/PacketBotaniaEffect.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.common.network; import net.minecraft.client.Minecraft; @@ -11,6 +19,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraftforge.fml.network.NetworkEvent; + import vazkii.botania.client.fx.SparkleParticleData; import vazkii.botania.client.fx.WispParticleData; import vazkii.botania.common.block.tile.TileTerraPlate; @@ -90,7 +99,7 @@ public class PacketBotaniaEffect { } case ARENA_INDICATOR: { SparkleParticleData data = SparkleParticleData.sparkle(5F, 1, 0, 1, 120); - for(int i = 0; i < 360; i += 8) { + for (int i = 0; i < 360; i += 8) { float rad = i * (float) Math.PI / 180F; double x = message.x + 0.5 - Math.cos(rad) * EntityDoppleganger.ARENA_RANGE; double y = message.y + 0.5; @@ -101,11 +110,13 @@ public class PacketBotaniaEffect { } case ITEM_SMOKE: { Entity item = world.getEntityByID(message.args[0]); - if (item == null) return; + if (item == null) { + return; + } int p = message.args[1]; - for(int i = 0; i < p; i++) { + for (int i = 0; i < p; i++) { double m = 0.01; double d0 = item.world.rand.nextGaussian() * m; double d1 = item.world.rand.nextGaussian() * m; @@ -121,10 +132,11 @@ public class PacketBotaniaEffect { Entity e1 = world.getEntityByID(message.args[0]); Entity e2 = world.getEntityByID(message.args[1]); - if(e1 == null || e2 == null) + if (e1 == null || e2 == null) { return; + } - Vector3 orig = new Vector3(e1.getX() , e1.getY() + 0.25, e1.getZ()); + Vector3 orig = new Vector3(e1.getX(), e1.getY() + 0.25, e1.getZ()); Vector3 end = new Vector3(e2.getX(), e2.getY() + 0.25, e2.getZ()); Vector3 diff = end.subtract(orig); Vector3 movement = diff.normalize().multiply(0.1); @@ -133,7 +145,7 @@ public class PacketBotaniaEffect { float hueSum = (float) Math.random(); Vector3 currentPos = orig; - for(int i = 0; i < iters; i++) { + for (int i = 0; i < iters; i++) { float hue = i * huePer + hueSum; int color = MathHelper.hsvToRGB(hue, 1F, 1F); float r = Math.min(1F, (color >> 16 & 0xFF) / 255F + 0.4F); @@ -151,8 +163,9 @@ public class PacketBotaniaEffect { Entity e1 = world.getEntityByID(message.args[0]); Entity e2 = world.getEntityByID(message.args[1]); - if(e1 == null || e2 == null) + if (e1 == null || e2 == null) { return; + } double rc = 0.45; Vector3 thisVec = Vector3.fromEntityCenter(e1).add((Math.random() - 0.5) * rc, (Math.random() - 0.5) * rc, (Math.random() - 0.5) * rc); @@ -169,7 +182,7 @@ public class PacketBotaniaEffect { break; } case ENCHANTER_DESTROY: { - for(int i = 0; i < 50; i++) { + for (int i = 0; i < 50; i++) { float red = (float) Math.random(); float green = (float) Math.random(); float blue = (float) Math.random(); @@ -179,7 +192,7 @@ public class PacketBotaniaEffect { break; } case BLACK_LOTUS_DISSOLVE: { - for(int i = 0; i < 50; i++) { + for (int i = 0; i < 50; i++) { float r = (float) Math.random() * 0.35F; float g = 0F; float b = (float) Math.random() * 0.35F; @@ -198,7 +211,7 @@ public class PacketBotaniaEffect { } case TERRA_PLATE: { TileEntity te = world.getTileEntity(new BlockPos(message.x, message.y, message.z)); - if(te instanceof TileTerraPlate) { + if (te instanceof TileTerraPlate) { int ticks = (int) (100.0 * ((double) ((TileTerraPlate) te).getCurrentMana() / (double) TileTerraPlate.MAX_MANA)); int totalSpiritCount = 3; @@ -210,7 +223,7 @@ public class PacketBotaniaEffect { double r = Math.sin((ticks - 100) / 10D) * 2; double g = Math.sin(wticks * Math.PI / 180 * 0.55); - for(int i = 0; i < totalSpiritCount; i++) { + for (int i = 0; i < totalSpiritCount; i++) { double x = message.x + Math.sin(wticks * Math.PI / 180) * r + 0.5; double y = message.y + 0.25 + Math.abs(r) * 0.7; double z = message.z + Math.cos(wticks * Math.PI / 180) * r + 0.5; @@ -220,29 +233,30 @@ public class PacketBotaniaEffect { 0F, (float) ticks / (float) 100, 1F - (float) ticks / (float) 100 }; WispParticleData data = WispParticleData.wisp(0.85F, colorsfx[0], colorsfx[1], colorsfx[2], 0.25F); - world.addParticle(data, x, y, z, 0, (float) (-g*0.05), 0); + world.addParticle(data, x, y, z, 0, (float) (-g * 0.05), 0); data = WispParticleData.wisp((float) Math.random() * 0.1F + 0.1F, colorsfx[0], colorsfx[1], colorsfx[2], 0.9F); world.addParticle(data, x, y, z, (float) (Math.random() - 0.5) * 0.05F, (float) (Math.random() - 0.5) * 0.05F, (float) (Math.random() - 0.5) * 0.05F); - if(ticks == 100) - for(int j = 0; j < 15; j++) { + if (ticks == 100) { + for (int j = 0; j < 15; j++) { data = WispParticleData.wisp((float) Math.random() * 0.15F + 0.15F, colorsfx[0], colorsfx[1], colorsfx[2]); world.addParticle(data, message.x + 0.5, message.y + 0.5, message.z + 0.5, (float) (Math.random() - 0.5F) * 0.125F, (float) (Math.random() - 0.5F) * 0.125F, (float) (Math.random() - 0.5F) * 0.125F); } + } } } break; } case FLUGEL_EFFECT: { Entity entity = world.getEntityByID(message.args[0]); - if(entity != null) { - for(int i = 0; i < 15; i++) { + if (entity != null) { + for (int i = 0; i < 15; i++) { float x = (float) (entity.getX() + Math.random()); float y = (float) (entity.getY() + Math.random()); float z = (float) (entity.getZ() + Math.random()); - WispParticleData data = WispParticleData.wisp((float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), 1); - world.addParticle(data, x, y, z, 0, -(-0.3F + (float) Math.random() * 0.2F), 0); - } + WispParticleData data = WispParticleData.wisp((float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), 1); + world.addParticle(data, x, y, z, 0, -(-0.3F + (float) Math.random() * 0.2F), 0); + } } break; } @@ -254,16 +268,18 @@ public class PacketBotaniaEffect { } case DIVA_EFFECT: { Entity target = Minecraft.getInstance().world.getEntityByID(message.args[0]); - if(target == null) + if (target == null) { break; + } double x = target.getX(); double y = target.getY(); double z = target.getZ(); SparkleParticleData data = SparkleParticleData.sparkle(1F, 1F, 1F, 0.25F, 3); - for(int i = 0; i < 50; i++) + for (int i = 0; i < 50; i++) { world.addParticle(data, x + Math.random() * target.getWidth(), y + Math.random() * target.getHeight(), z + Math.random() * target.getWidth(), 0, 0, 0); + } break; } } @@ -275,7 +291,7 @@ public class PacketBotaniaEffect { } public enum EffectType { - PAINT_LENS(1), // Arg: EnumDyeColor + PAINT_LENS(1), // Arg: EnumDyeColor ARENA_INDICATOR(0), ITEM_SMOKE(2), // Arg: Entity ID, number of particles SPARK_NET_INDICATOR(2), // Arg: Entity ID from, Entity ID towards diff --git a/src/main/java/vazkii/botania/common/network/PacketDodge.java b/src/main/java/vazkii/botania/common/network/PacketDodge.java index 120a1c6a5..70c185b28 100644 --- a/src/main/java/vazkii/botania/common/network/PacketDodge.java +++ b/src/main/java/vazkii/botania/common/network/PacketDodge.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [22/09/2016, 13:06:44 (GMT)] */ package vazkii.botania.common.network; @@ -15,8 +13,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.network.PacketBuffer; import net.minecraft.util.SoundCategory; import net.minecraft.util.text.TranslationTextComponent; -import net.minecraftforge.fml.LogicalSide; import net.minecraftforge.fml.network.NetworkEvent; + import vazkii.botania.common.core.handler.EquipmentHandler; import vazkii.botania.common.core.handler.ModSounds; import vazkii.botania.common.core.helper.ItemNBTHelper; @@ -33,7 +31,7 @@ public class PacketDodge { } public static void handle(PacketDodge msg, Supplier ctx) { - if (ctx.get().getDirection().getReceptionSide().isServer()) + if (ctx.get().getDirection().getReceptionSide().isServer()) { ctx.get().enqueueWork(() -> { ServerPlayerEntity player = ctx.get().getSender(); player.world.playSound(null, player.getX(), player.getY(), player.getZ(), ModSounds.dash, SoundCategory.PLAYERS, 1F, 1F); @@ -47,6 +45,7 @@ public class PacketDodge { player.addExhaustion(0.3F); ItemNBTHelper.setInt(ringStack, ItemDodgeRing.TAG_DODGE_COOLDOWN, ItemDodgeRing.MAX_CD); }); + } ctx.get().setPacketHandled(true); } } diff --git a/src/main/java/vazkii/botania/common/network/PacketHandler.java b/src/main/java/vazkii/botania/common/network/PacketHandler.java index ae903a841..254e498fe 100644 --- a/src/main/java/vazkii/botania/common/network/PacketHandler.java +++ b/src/main/java/vazkii/botania/common/network/PacketHandler.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.common.network; import net.minecraft.entity.Entity; @@ -12,6 +20,7 @@ import net.minecraftforge.fml.network.NetworkDirection; import net.minecraftforge.fml.network.NetworkRegistry; import net.minecraftforge.fml.network.PacketDistributor; import net.minecraftforge.fml.network.simple.SimpleChannel; + import vazkii.botania.common.lib.LibMisc; public final class PacketHandler { @@ -32,7 +41,7 @@ public final class PacketHandler { HANDLER.registerMessage(id++, PacketItemAge.class, PacketItemAge::encode, PacketItemAge::decode, PacketItemAge::handle); HANDLER.registerMessage(id++, PacketSyncRecipes.class, PacketSyncRecipes::encode, PacketSyncRecipes::decode, PacketSyncRecipes::handle); HANDLER.registerMessage(id++, PacketIndexKeybindRequest.class, PacketIndexKeybindRequest::encode, PacketIndexKeybindRequest::decode, PacketIndexKeybindRequest::handle); - + HANDLER.messageBuilder(PacketSyncRecipes.Login.class, id++) .loginIndex(ILoginPacket::getLoginIndex, ILoginPacket::setLoginIndex) .encoder(PacketSyncRecipes.Login::encode).decoder(PacketSyncRecipes.Login::decode) @@ -50,7 +59,7 @@ public final class PacketHandler { * Send message to all within 64 blocks that have this chunk loaded */ public static void sendToNearby(World world, BlockPos pos, Object toSend) { - if(world instanceof ServerWorld) { + if (world instanceof ServerWorld) { ServerWorld ws = (ServerWorld) world; ws.getChunkProvider().chunkManager.getTrackingPlayers(new ChunkPos(pos), false) @@ -68,7 +77,7 @@ public final class PacketHandler { } public static void sendNonLocal(ServerPlayerEntity playerMP, Object toSend) { - if(playerMP.server.isDedicatedServer() || !playerMP.getGameProfile().getName().equals(playerMP.server.getServerOwner())) { + if (playerMP.server.isDedicatedServer() || !playerMP.getGameProfile().getName().equals(playerMP.server.getServerOwner())) { sendTo(playerMP, toSend); } } diff --git a/src/main/java/vazkii/botania/common/network/PacketIndexKeybindRequest.java b/src/main/java/vazkii/botania/common/network/PacketIndexKeybindRequest.java index 7c0b579e6..1d03559f0 100644 --- a/src/main/java/vazkii/botania/common/network/PacketIndexKeybindRequest.java +++ b/src/main/java/vazkii/botania/common/network/PacketIndexKeybindRequest.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [gru 25 2019, 19:33] */ package vazkii.botania.common.network; @@ -14,6 +12,7 @@ import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.network.PacketBuffer; import net.minecraftforge.fml.network.NetworkEvent; + import vazkii.botania.api.corporea.CorporeaHelper; import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex; @@ -35,11 +34,12 @@ public class PacketIndexKeybindRequest { } public static void handle(PacketIndexKeybindRequest message, Supplier ctx) { - if (ctx.get().getDirection().getReceptionSide().isServer()) + if (ctx.get().getDirection().getReceptionSide().isServer()) { ctx.get().enqueueWork(() -> { ServerPlayerEntity player = ctx.get().getSender(); - if (player.isSpectator()) + if (player.isSpectator()) { return; + } boolean checkNBT = message.stack.getTag() != null && !message.stack.getTag().isEmpty(); for (TileCorporeaIndex index : TileCorporeaIndex.InputHandler.getNearbyIndexes(player)) { @@ -48,6 +48,7 @@ public class PacketIndexKeybindRequest { } } }); + } ctx.get().setPacketHandled(true); } } diff --git a/src/main/java/vazkii/botania/common/network/PacketItemAge.java b/src/main/java/vazkii/botania/common/network/PacketItemAge.java index 8a005b310..d6818444a 100644 --- a/src/main/java/vazkii/botania/common/network/PacketItemAge.java +++ b/src/main/java/vazkii/botania/common/network/PacketItemAge.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.common.network; import net.minecraft.client.Minecraft; @@ -27,13 +35,14 @@ public class PacketItemAge { } public static void handle(PacketItemAge message, Supplier ctx) { - if (ctx.get().getDirection().getReceptionSide().isClient()) + if (ctx.get().getDirection().getReceptionSide().isClient()) { ctx.get().enqueueWork(() -> { Entity e = Minecraft.getInstance().world.getEntityByID(message.entityId); if (e instanceof ItemEntity) { ((ItemEntity) e).age = message.age; } }); + } ctx.get().setPacketHandled(true); } } diff --git a/src/main/java/vazkii/botania/common/network/PacketJump.java b/src/main/java/vazkii/botania/common/network/PacketJump.java index 37e100a1d..bc6fb2374 100644 --- a/src/main/java/vazkii/botania/common/network/PacketJump.java +++ b/src/main/java/vazkii/botania/common/network/PacketJump.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [22/10/2016, 18:18:19 (GMT)] */ package vazkii.botania.common.network; @@ -14,6 +12,7 @@ import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.network.PacketBuffer; import net.minecraftforge.fml.network.NetworkEvent; + import vazkii.botania.common.core.handler.EquipmentHandler; import vazkii.botania.common.item.equipment.bauble.ItemCloudPendant; import vazkii.botania.common.item.equipment.bauble.ItemTravelBelt; @@ -28,7 +27,7 @@ public class PacketJump { } public void handle(Supplier ctx) { - if (ctx.get().getDirection().getReceptionSide().isServer()) + if (ctx.get().getDirection().getReceptionSide().isServer()) { ctx.get().enqueueWork(() -> { ServerPlayerEntity player = ctx.get().getSender(); @@ -38,10 +37,12 @@ public class PacketJump { player.fallDistance = 0; ItemStack belt = EquipmentHandler.findOrEmpty(s -> s.getItem() instanceof ItemTravelBelt, player); - if (!belt.isEmpty()) + if (!belt.isEmpty()) { player.fallDistance = -((ItemTravelBelt) belt.getItem()).fallBuffer * ((ItemCloudPendant) amuletStack.getItem()).getMaxAllowedJumps(); + } } }); + } ctx.get().setPacketHandled(true); } } diff --git a/src/main/java/vazkii/botania/common/network/PacketLeftClick.java b/src/main/java/vazkii/botania/common/network/PacketLeftClick.java index d9bebeed0..fbe588223 100644 --- a/src/main/java/vazkii/botania/common/network/PacketLeftClick.java +++ b/src/main/java/vazkii/botania/common/network/PacketLeftClick.java @@ -1,7 +1,16 @@ +/* + * This class is 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 + */ package vazkii.botania.common.network; import net.minecraft.network.PacketBuffer; import net.minecraftforge.fml.network.NetworkEvent; + import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.terrasteel.ItemTerraSword; @@ -15,8 +24,9 @@ public class PacketLeftClick { } public static void handle(PacketLeftClick msg, Supplier ctx) { - if (ctx.get().getDirection().getReceptionSide().isServer()) + if (ctx.get().getDirection().getReceptionSide().isServer()) { ctx.get().enqueueWork(() -> ((ItemTerraSword) ModItems.terraSword).trySpawnBurst(ctx.get().getSender())); + } ctx.get().setPacketHandled(true); } } diff --git a/src/main/java/vazkii/botania/common/network/PacketSyncRecipes.java b/src/main/java/vazkii/botania/common/network/PacketSyncRecipes.java index f9921da4f..a6714fcb0 100644 --- a/src/main/java/vazkii/botania/common/network/PacketSyncRecipes.java +++ b/src/main/java/vazkii/botania/common/network/PacketSyncRecipes.java @@ -1,10 +1,18 @@ +/* + * This class is 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 + */ package vazkii.botania.common.network; -import com.google.common.base.Stopwatch; import net.minecraft.client.Minecraft; import net.minecraft.network.PacketBuffer; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.network.NetworkEvent; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipeBrew; import vazkii.botania.api.recipe.RecipeElvenTrade; @@ -12,7 +20,6 @@ import vazkii.botania.api.recipe.RecipeManaInfusion; import vazkii.botania.api.recipe.RecipePetals; import vazkii.botania.api.recipe.RecipePureDaisy; import vazkii.botania.api.recipe.RecipeRuneAltar; -import vazkii.botania.common.Botania; import java.util.Map; import java.util.function.Supplier; @@ -20,128 +27,130 @@ import java.util.stream.Collectors; import java.util.stream.Stream; public class PacketSyncRecipes { - private Map brew; - private Map elven; - private Map manaInfusion; - private Map petal; - private Map pureDaisy; - private Map runeAltar; + private Map brew; + private Map elven; + private Map manaInfusion; + private Map petal; + private Map pureDaisy; + private Map runeAltar; - public PacketSyncRecipes(Map brew, Map elven, Map manaInfusion, Map petal, Map pureDaisy, Map runeAltar) { - this.brew = brew; - this.elven = elven; - this.manaInfusion = manaInfusion; - this.petal = petal; - this.pureDaisy = pureDaisy; - this.runeAltar = runeAltar; - } + public PacketSyncRecipes(Map brew, Map elven, Map manaInfusion, Map petal, Map pureDaisy, Map runeAltar) { + this.brew = brew; + this.elven = elven; + this.manaInfusion = manaInfusion; + this.petal = petal; + this.pureDaisy = pureDaisy; + this.runeAltar = runeAltar; + } - public void encode(PacketBuffer buf) { - buf.writeVarInt(brew.size()); - for (RecipeBrew recipe : brew.values()) { - recipe.write(buf); - } - buf.writeVarInt(elven.size()); - for (RecipeElvenTrade recipe : elven.values()) { - recipe.write(buf); - } - buf.writeVarInt(manaInfusion.size()); - for (RecipeManaInfusion recipe : manaInfusion.values()) { - recipe.write(buf); - } - buf.writeVarInt(petal.size()); - for (RecipePetals recipe : petal.values()) { - recipe.write(buf); - } - buf.writeVarInt(pureDaisy.size()); - for (RecipePureDaisy recipe : pureDaisy.values()) { - recipe.write(buf); - } - buf.writeVarInt(runeAltar.size()); - for (RecipeRuneAltar recipe : runeAltar.values()) { - recipe.write(buf); - } - } + public void encode(PacketBuffer buf) { + buf.writeVarInt(brew.size()); + for (RecipeBrew recipe : brew.values()) { + recipe.write(buf); + } + buf.writeVarInt(elven.size()); + for (RecipeElvenTrade recipe : elven.values()) { + recipe.write(buf); + } + buf.writeVarInt(manaInfusion.size()); + for (RecipeManaInfusion recipe : manaInfusion.values()) { + recipe.write(buf); + } + buf.writeVarInt(petal.size()); + for (RecipePetals recipe : petal.values()) { + recipe.write(buf); + } + buf.writeVarInt(pureDaisy.size()); + for (RecipePureDaisy recipe : pureDaisy.values()) { + recipe.write(buf); + } + buf.writeVarInt(runeAltar.size()); + for (RecipeRuneAltar recipe : runeAltar.values()) { + recipe.write(buf); + } + } - public static PacketSyncRecipes decode(PacketBuffer buf) { - int brewCount = buf.readVarInt(); - Map brew = Stream.generate(() -> RecipeBrew.read(buf)) - .limit(brewCount) - .collect(Collectors.toMap(RecipeBrew::getId, r -> r)); - int elvenCount = buf.readVarInt(); - Map elven = Stream.generate(() -> RecipeElvenTrade.read(buf)) - .limit(elvenCount) - .collect(Collectors.toMap(RecipeElvenTrade::getId, r -> r)); - int manaInfusionCount = buf.readVarInt(); - Map manaInfusion = Stream.generate(() -> RecipeManaInfusion.read(buf)) - .limit(manaInfusionCount) - .collect(Collectors.toMap(RecipeManaInfusion::getId, r -> r)); - int petalCount = buf.readVarInt(); - Map petal = Stream.generate(() -> RecipePetals.read(buf)) - .limit(petalCount) - .collect(Collectors.toMap(RecipePetals::getId, r -> r)); - int pureDaisyCount = buf.readVarInt(); - Map pureDaisy = Stream.generate(() -> RecipePureDaisy.read(buf)) - .limit(pureDaisyCount) - .collect(Collectors.toMap(RecipePureDaisy::getId, r -> r)); - int runeCount = buf.readVarInt(); - Map rune = Stream.generate(() -> RecipeRuneAltar.read(buf)) - .limit(runeCount) - .collect(Collectors.toMap(RecipeRuneAltar::getId, r -> r)); - return new PacketSyncRecipes(brew, elven, manaInfusion, petal, pureDaisy, rune); - } + public static PacketSyncRecipes decode(PacketBuffer buf) { + int brewCount = buf.readVarInt(); + Map brew = Stream.generate(() -> RecipeBrew.read(buf)) + .limit(brewCount) + .collect(Collectors.toMap(RecipeBrew::getId, r -> r)); + int elvenCount = buf.readVarInt(); + Map elven = Stream.generate(() -> RecipeElvenTrade.read(buf)) + .limit(elvenCount) + .collect(Collectors.toMap(RecipeElvenTrade::getId, r -> r)); + int manaInfusionCount = buf.readVarInt(); + Map manaInfusion = Stream.generate(() -> RecipeManaInfusion.read(buf)) + .limit(manaInfusionCount) + .collect(Collectors.toMap(RecipeManaInfusion::getId, r -> r)); + int petalCount = buf.readVarInt(); + Map petal = Stream.generate(() -> RecipePetals.read(buf)) + .limit(petalCount) + .collect(Collectors.toMap(RecipePetals::getId, r -> r)); + int pureDaisyCount = buf.readVarInt(); + Map pureDaisy = Stream.generate(() -> RecipePureDaisy.read(buf)) + .limit(pureDaisyCount) + .collect(Collectors.toMap(RecipePureDaisy::getId, r -> r)); + int runeCount = buf.readVarInt(); + Map rune = Stream.generate(() -> RecipeRuneAltar.read(buf)) + .limit(runeCount) + .collect(Collectors.toMap(RecipeRuneAltar::getId, r -> r)); + return new PacketSyncRecipes(brew, elven, manaInfusion, petal, pureDaisy, rune); + } - public void handle(Supplier ctx) { - if(ctx.get().getDirection().getReceptionSide().isClient()) - ctx.get().enqueueWork(() -> { - if(Minecraft.getInstance().isSingleplayer()) - return; - BotaniaAPI.brewRecipes = brew; - BotaniaAPI.elvenTradeRecipes = elven; - BotaniaAPI.manaInfusionRecipes = manaInfusion; - BotaniaAPI.petalRecipes = petal; - BotaniaAPI.pureDaisyRecipes = pureDaisy; - BotaniaAPI.runeAltarRecipes = runeAltar; - }); - ctx.get().setPacketHandled(true); - } - - // The login packet wraps the proper one because directly extending it will cause a freeze on the handshake. - public static class Login implements ILoginPacket { - private final PacketSyncRecipes wrapped; - private int loginIndex; - - public Login() { - this(new PacketSyncRecipes(BotaniaAPI.brewRecipes, BotaniaAPI.elvenTradeRecipes, - BotaniaAPI.manaInfusionRecipes, BotaniaAPI.petalRecipes, - BotaniaAPI.pureDaisyRecipes, BotaniaAPI.runeAltarRecipes)); - } + public void handle(Supplier ctx) { + if (ctx.get().getDirection().getReceptionSide().isClient()) { + ctx.get().enqueueWork(() -> { + if (Minecraft.getInstance().isSingleplayer()) { + return; + } + BotaniaAPI.brewRecipes = brew; + BotaniaAPI.elvenTradeRecipes = elven; + BotaniaAPI.manaInfusionRecipes = manaInfusion; + BotaniaAPI.petalRecipes = petal; + BotaniaAPI.pureDaisyRecipes = pureDaisy; + BotaniaAPI.runeAltarRecipes = runeAltar; + }); + } + ctx.get().setPacketHandled(true); + } - public Login(PacketSyncRecipes packet) { - this.wrapped = packet; - } - - public static Login decode(PacketBuffer buf) { - return new Login(PacketSyncRecipes.decode(buf)); - } + // The login packet wraps the proper one because directly extending it will cause a freeze on the handshake. + public static class Login implements ILoginPacket { + private final PacketSyncRecipes wrapped; + private int loginIndex; - public void encode(PacketBuffer buf) { - wrapped.encode(buf); - } + public Login() { + this(new PacketSyncRecipes(BotaniaAPI.brewRecipes, BotaniaAPI.elvenTradeRecipes, + BotaniaAPI.manaInfusionRecipes, BotaniaAPI.petalRecipes, + BotaniaAPI.pureDaisyRecipes, BotaniaAPI.runeAltarRecipes)); + } - public void handle(Supplier ctx) { - wrapped.handle(ctx); - PacketHandler.HANDLER.reply(new PacketAck(), ctx.get()); - } + public Login(PacketSyncRecipes packet) { + this.wrapped = packet; + } - @Override - public void setLoginIndex(int index) { - this.loginIndex = index; - } + public static Login decode(PacketBuffer buf) { + return new Login(PacketSyncRecipes.decode(buf)); + } - @Override - public int getLoginIndex() { - return loginIndex; - } - } + public void encode(PacketBuffer buf) { + wrapped.encode(buf); + } + + public void handle(Supplier ctx) { + wrapped.handle(ctx); + PacketHandler.HANDLER.reply(new PacketAck(), ctx.get()); + } + + @Override + public void setLoginIndex(int index) { + this.loginIndex = index; + } + + @Override + public int getLoginIndex() { + return loginIndex; + } + } } diff --git a/src/main/java/vazkii/botania/common/world/ModFeatures.java b/src/main/java/vazkii/botania/common/world/ModFeatures.java index 9770f33c4..fdb83aa3e 100644 --- a/src/main/java/vazkii/botania/common/world/ModFeatures.java +++ b/src/main/java/vazkii/botania/common/world/ModFeatures.java @@ -1,22 +1,20 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [sie 16 2019, 19:17] */ package vazkii.botania.common.world; import com.google.common.collect.ImmutableSet; + import net.minecraft.world.biome.Biome; import net.minecraft.world.gen.ChunkGeneratorType; import net.minecraft.world.gen.GenerationStage; import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.placement.IPlacementConfig; -import net.minecraft.world.gen.placement.NoPlacementConfig; import net.minecraft.world.gen.placement.Placement; import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.event.RegistryEvent; @@ -24,6 +22,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.IForgeRegistry; + import vazkii.botania.common.lib.LibMisc; import java.util.Set; @@ -56,9 +55,9 @@ public class ModFeatures { public static void registerChunkGenerators(RegistryEvent.Register> evt) { register(evt.getRegistry(), SkyblockChunkGenerator.TYPE, "garden_of_glass"); } - + public static void addWorldgen() { - for(Biome biome : ForgeRegistries.BIOMES) { + for (Biome biome : ForgeRegistries.BIOMES) { if (BiomeDictionary.getTypes(biome).stream().noneMatch(TYPE_BLACKLIST::contains)) { biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, MYSTICAL_FLOWERS.configure(new MysticalFlowerConfig()).createDecoratedFeature(Placement.NOPE.configure(IPlacementConfig.NO_PLACEMENT_CONFIG))); } diff --git a/src/main/java/vazkii/botania/common/world/MysticalFlowerConfig.java b/src/main/java/vazkii/botania/common/world/MysticalFlowerConfig.java index a4c788253..49428728f 100644 --- a/src/main/java/vazkii/botania/common/world/MysticalFlowerConfig.java +++ b/src/main/java/vazkii/botania/common/world/MysticalFlowerConfig.java @@ -1,44 +1,54 @@ +/* + * This class is 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 + */ package vazkii.botania.common.world; import com.mojang.datafixers.Dynamic; import com.mojang.datafixers.types.DynamicOps; + import net.minecraft.world.gen.feature.IFeatureConfig; + import vazkii.botania.common.core.handler.ConfigHandler; import javax.annotation.Nonnull; public class MysticalFlowerConfig implements IFeatureConfig { - public int getPatchSize() { - return ConfigHandler.COMMON.flowerPatchSize.get(); - } + public int getPatchSize() { + return ConfigHandler.COMMON.flowerPatchSize.get(); + } - public int getPatchCount() { - return ConfigHandler.COMMON.flowerQuantity.get(); - } + public int getPatchCount() { + return ConfigHandler.COMMON.flowerQuantity.get(); + } - public int getPatchDensity() { - return ConfigHandler.COMMON.flowerDensity.get(); - } + public int getPatchDensity() { + return ConfigHandler.COMMON.flowerDensity.get(); + } - public int getPatchChance() { - return ConfigHandler.COMMON.flowerPatchChance.get(); - } + public int getPatchChance() { + return ConfigHandler.COMMON.flowerPatchChance.get(); + } - public double getTallChance() { - return ConfigHandler.COMMON.flowerTallChance.get(); - } + public double getTallChance() { + return ConfigHandler.COMMON.flowerTallChance.get(); + } - public int getMushroomPatchSize() { - return ConfigHandler.COMMON.mushroomQuantity.get(); - } + public int getMushroomPatchSize() { + return ConfigHandler.COMMON.mushroomQuantity.get(); + } - @Nonnull - @Override - public Dynamic serialize(@Nonnull DynamicOps ops) { - return new Dynamic<>(ops); - } + @Nonnull + @Override + public Dynamic serialize(@Nonnull DynamicOps ops) { + return new Dynamic<>(ops); + } - public static MysticalFlowerConfig deserialize(Dynamic dynamic) { - return new MysticalFlowerConfig(); - } + public static MysticalFlowerConfig deserialize(Dynamic dynamic) { + return new MysticalFlowerConfig(); + } } diff --git a/src/main/java/vazkii/botania/common/world/MysticalFlowerFeature.java b/src/main/java/vazkii/botania/common/world/MysticalFlowerFeature.java index 8138e88f5..3a8ece617 100644 --- a/src/main/java/vazkii/botania/common/world/MysticalFlowerFeature.java +++ b/src/main/java/vazkii/botania/common/world/MysticalFlowerFeature.java @@ -1,6 +1,15 @@ +/* + * This class is 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 + */ package vazkii.botania.common.world; import com.mojang.datafixers.Dynamic; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.DoublePlantBlock; @@ -11,62 +20,66 @@ import net.minecraft.world.gen.ChunkGenerator; import net.minecraft.world.gen.GenerationSettings; import net.minecraft.world.gen.Heightmap; import net.minecraft.world.gen.feature.Feature; + import vazkii.botania.api.item.IFlowerlessBiome; import vazkii.botania.api.item.IFlowerlessWorld; import vazkii.botania.common.block.BlockModFlower; import vazkii.botania.common.block.ModBlocks; import javax.annotation.Nonnull; + import java.util.Random; import java.util.function.Function; public class MysticalFlowerFeature extends Feature { - public MysticalFlowerFeature(Function, ? extends MysticalFlowerConfig> configFactoryIn) { - super(configFactoryIn); - } + public MysticalFlowerFeature(Function, ? extends MysticalFlowerConfig> configFactoryIn) { + super(configFactoryIn); + } - @Override - public boolean place(@Nonnull IWorld world, @Nonnull ChunkGenerator generator, @Nonnull Random rand, @Nonnull BlockPos pos, @Nonnull MysticalFlowerConfig config) { - boolean flowers = true; - if(world.getDimension() instanceof IFlowerlessWorld) - flowers = ((IFlowerlessWorld) world.getDimension()).generateFlowers(world); - else if(world.getBiome(pos) instanceof IFlowerlessBiome) - flowers = ((IFlowerlessBiome) world.getBiome(pos)).canGenerateFlowers(world, pos.getX(), pos.getZ()); + @Override + public boolean place(@Nonnull IWorld world, @Nonnull ChunkGenerator generator, @Nonnull Random rand, @Nonnull BlockPos pos, @Nonnull MysticalFlowerConfig config) { + boolean flowers = true; + if (world.getDimension() instanceof IFlowerlessWorld) { + flowers = ((IFlowerlessWorld) world.getDimension()).generateFlowers(world); + } else if (world.getBiome(pos) instanceof IFlowerlessBiome) { + flowers = ((IFlowerlessBiome) world.getBiome(pos)).canGenerateFlowers(world, pos.getX(), pos.getZ()); + } - if(!flowers) - return false; + if (!flowers) { + return false; + } - boolean any = false; - int dist = Math.min(8, Math.max(1, config.getPatchSize())); - for(int i = 0; i < config.getPatchCount(); i++) { - if(rand.nextInt(config.getPatchChance()) == 0) { - int x = pos.getX() + rand.nextInt(16); - int z = pos.getZ() + rand.nextInt(16); - int y = world.getHeight(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, x, z); + boolean any = false; + int dist = Math.min(8, Math.max(1, config.getPatchSize())); + for (int i = 0; i < config.getPatchCount(); i++) { + if (rand.nextInt(config.getPatchChance()) == 0) { + int x = pos.getX() + rand.nextInt(16); + int z = pos.getZ() + rand.nextInt(16); + int y = world.getHeight(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, x, z); - DyeColor color = DyeColor.byId(rand.nextInt(16)); - BlockState flower = ModBlocks.getFlower(color).getDefaultState(); + DyeColor color = DyeColor.byId(rand.nextInt(16)); + BlockState flower = ModBlocks.getFlower(color).getDefaultState(); - for(int j = 0; j < config.getPatchDensity() * config.getPatchChance(); j++) { - int x1 = x + rand.nextInt(dist * 2) - dist; - int y1 = y + rand.nextInt(4) - rand.nextInt(4); - int z1 = z + rand.nextInt(dist * 2) - dist; - BlockPos pos2 = new BlockPos(x1, y1, z1); - if(world.isAirBlock(pos2) && (!world.getDimension().isNether() || y1 < 127) && flower.isValidPosition(world, pos2)) { - world.setBlockState(pos2, flower, 2); - any = true; - if(rand.nextDouble() < config.getTallChance() - && ((BlockModFlower) flower.getBlock()).canGrow(world, pos2, world.getBlockState(pos2), false)) { - Block block = ModBlocks.getDoubleFlower(color); - if(block instanceof DoublePlantBlock) { - ((DoublePlantBlock) block).placeAt(world, pos2, 3); - } - } - } - } - } - } + for (int j = 0; j < config.getPatchDensity() * config.getPatchChance(); j++) { + int x1 = x + rand.nextInt(dist * 2) - dist; + int y1 = y + rand.nextInt(4) - rand.nextInt(4); + int z1 = z + rand.nextInt(dist * 2) - dist; + BlockPos pos2 = new BlockPos(x1, y1, z1); + if (world.isAirBlock(pos2) && (!world.getDimension().isNether() || y1 < 127) && flower.isValidPosition(world, pos2)) { + world.setBlockState(pos2, flower, 2); + any = true; + if (rand.nextDouble() < config.getTallChance() + && ((BlockModFlower) flower.getBlock()).canGrow(world, pos2, world.getBlockState(pos2), false)) { + Block block = ModBlocks.getDoubleFlower(color); + if (block instanceof DoublePlantBlock) { + ((DoublePlantBlock) block).placeAt(world, pos2, 3); + } + } + } + } + } + } - return any; - } + return any; + } } diff --git a/src/main/java/vazkii/botania/common/world/MysticalMushroomFeature.java b/src/main/java/vazkii/botania/common/world/MysticalMushroomFeature.java index 9b0838396..c2d63d220 100644 --- a/src/main/java/vazkii/botania/common/world/MysticalMushroomFeature.java +++ b/src/main/java/vazkii/botania/common/world/MysticalMushroomFeature.java @@ -1,6 +1,15 @@ +/* + * This class is 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 + */ package vazkii.botania.common.world; import com.mojang.datafixers.Dynamic; + import net.minecraft.block.BlockState; import net.minecraft.item.DyeColor; import net.minecraft.util.math.BlockPos; @@ -8,43 +17,47 @@ import net.minecraft.world.IWorld; import net.minecraft.world.gen.ChunkGenerator; import net.minecraft.world.gen.GenerationSettings; import net.minecraft.world.gen.feature.Feature; + import vazkii.botania.api.item.IFlowerlessBiome; import vazkii.botania.api.item.IFlowerlessWorld; import vazkii.botania.common.block.ModBlocks; import javax.annotation.Nonnull; + import java.util.Random; import java.util.function.Function; public class MysticalMushroomFeature extends Feature { - public MysticalMushroomFeature(Function, ? extends MysticalFlowerConfig> configFactory) { - super(configFactory); - } + public MysticalMushroomFeature(Function, ? extends MysticalFlowerConfig> configFactory) { + super(configFactory); + } - @Override - public boolean place(@Nonnull IWorld world, @Nonnull ChunkGenerator generator, @Nonnull Random rand, @Nonnull BlockPos pos, @Nonnull MysticalFlowerConfig config) { - boolean spawn = true; - if(world.getDimension() instanceof IFlowerlessWorld) - spawn = ((IFlowerlessWorld) world.getDimension()).generateFlowers(world); - else if(world.getBiome(pos) instanceof IFlowerlessBiome) - spawn = ((IFlowerlessBiome) world.getBiome(pos)).canGenerateFlowers(world, pos.getX(), pos.getZ()); + @Override + public boolean place(@Nonnull IWorld world, @Nonnull ChunkGenerator generator, @Nonnull Random rand, @Nonnull BlockPos pos, @Nonnull MysticalFlowerConfig config) { + boolean spawn = true; + if (world.getDimension() instanceof IFlowerlessWorld) { + spawn = ((IFlowerlessWorld) world.getDimension()).generateFlowers(world); + } else if (world.getBiome(pos) instanceof IFlowerlessBiome) { + spawn = ((IFlowerlessBiome) world.getBiome(pos)).canGenerateFlowers(world, pos.getX(), pos.getZ()); + } - if(!spawn) - return false; + if (!spawn) { + return false; + } - boolean any = false; - for(int i = 0; i < config.getMushroomPatchSize(); i++) { - int x = pos.getX() + rand.nextInt(16) + 8; - int z = pos.getZ() + rand.nextInt(16) + 8; - int y = rand.nextInt(26) + 4; - BlockPos pos3 = new BlockPos(x, y, z); - DyeColor color = DyeColor.byId(rand.nextInt(16)); - BlockState mushroom = ModBlocks.getMushroom(color).getDefaultState(); - if(world.isAirBlock(pos3) && mushroom.isValidPosition(world, pos3)) { - world.setBlockState(pos3, mushroom, 2); - any = true; - } - } - return any; - } + boolean any = false; + for (int i = 0; i < config.getMushroomPatchSize(); i++) { + int x = pos.getX() + rand.nextInt(16) + 8; + int z = pos.getZ() + rand.nextInt(16) + 8; + int y = rand.nextInt(26) + 4; + BlockPos pos3 = new BlockPos(x, y, z); + DyeColor color = DyeColor.byId(rand.nextInt(16)); + BlockState mushroom = ModBlocks.getMushroom(color).getDefaultState(); + if (world.isAirBlock(pos3) && mushroom.isValidPosition(world, pos3)) { + world.setBlockState(pos3, mushroom, 2); + any = true; + } + } + return any; + } } diff --git a/src/main/java/vazkii/botania/common/world/SkyblockChunkGenerator.java b/src/main/java/vazkii/botania/common/world/SkyblockChunkGenerator.java index e9c9153a2..74d849080 100644 --- a/src/main/java/vazkii/botania/common/world/SkyblockChunkGenerator.java +++ b/src/main/java/vazkii/botania/common/world/SkyblockChunkGenerator.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.common.world; import net.minecraft.world.IWorld; @@ -11,21 +19,21 @@ import net.minecraft.world.gen.OverworldGenSettings; import net.minecraft.world.gen.WorldGenRegion; public class SkyblockChunkGenerator extends OverworldChunkGenerator { - public static final ChunkGeneratorType TYPE = new ChunkGeneratorType<>(SkyblockChunkGenerator::new, false, OverworldGenSettings::new); + public static final ChunkGeneratorType TYPE = new ChunkGeneratorType<>(SkyblockChunkGenerator::new, false, OverworldGenSettings::new); - private SkyblockChunkGenerator(IWorld worldIn, BiomeProvider provider, OverworldGenSettings settingsIn) { - super(worldIn, provider, settingsIn); - } + private SkyblockChunkGenerator(IWorld worldIn, BiomeProvider provider, OverworldGenSettings settingsIn) { + super(worldIn, provider, settingsIn); + } - @Override - public void makeBase(IWorld worldIn, IChunk chunkIn) {} + @Override + public void makeBase(IWorld worldIn, IChunk chunkIn) {} - @Override - public void buildSurface(WorldGenRegion region, IChunk chunkIn) {} + @Override + public void buildSurface(WorldGenRegion region, IChunk chunkIn) {} - @Override - public void decorate(WorldGenRegion region) {} + @Override + public void decorate(WorldGenRegion region) {} - @Override - public void carve(BiomeManager biomeManager, IChunk chunkIn, GenerationStage.Carving carvingSettings) {} + @Override + public void carve(BiomeManager biomeManager, IChunk chunkIn, GenerationStage.Carving carvingSettings) {} } diff --git a/src/main/java/vazkii/botania/common/world/SkyblockWorldEvents.java b/src/main/java/vazkii/botania/common/world/SkyblockWorldEvents.java index 1a9b62d24..aff3a18a2 100644 --- a/src/main/java/vazkii/botania/common/world/SkyblockWorldEvents.java +++ b/src/main/java/vazkii/botania/common/world/SkyblockWorldEvents.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 7, 2015, 6:14:18 PM (GMT)] */ package vazkii.botania.common.world; @@ -24,7 +22,6 @@ import net.minecraft.util.ActionResultType; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceContext; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; import net.minecraft.world.dimension.DimensionType; @@ -34,6 +31,7 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.server.ServerLifecycleHooks; import net.minecraftforge.items.ItemHandlerHelper; + import vazkii.botania.common.Botania; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.tile.TileManaFlame; @@ -55,27 +53,28 @@ public final class SkyblockWorldEvents { @SubscribeEvent public static void onPlayerUpdate(LivingUpdateEvent event) { - if(event.getEntityLiving() instanceof PlayerEntity && !event.getEntityLiving().world.isRemote) { + if (event.getEntityLiving() instanceof PlayerEntity && !event.getEntityLiving().world.isRemote) { PlayerEntity player = (PlayerEntity) event.getEntityLiving(); CompoundNBT data = player.getPersistentData(); - if(!data.contains(PlayerEntity.PERSISTED_NBT_TAG)) + if (!data.contains(PlayerEntity.PERSISTED_NBT_TAG)) { data.put(PlayerEntity.PERSISTED_NBT_TAG, new CompoundNBT()); + } CompoundNBT persist = data.getCompound(PlayerEntity.PERSISTED_NBT_TAG); - if(player.ticksExisted > 3 && !persist.getBoolean(TAG_MADE_ISLAND)) { + if (player.ticksExisted > 3 && !persist.getBoolean(TAG_MADE_ISLAND)) { World overworld = ServerLifecycleHooks.getCurrentServer().getWorld(DimensionType.OVERWORLD); World world = player.world; - if(WorldTypeSkyblock.isWorldSkyblock(world)) { + if (WorldTypeSkyblock.isWorldSkyblock(world)) { BlockPos coords = world.getSpawnPoint(); - if(coords.getY() <= 0) { + if (coords.getY() <= 0) { coords = new BlockPos(coords.getX(), 64, coords.getZ()); world.setSpawnPoint(coords); } - if(world.getBlockState(coords.down(4)).getBlock() != Blocks.BEDROCK && world == overworld) + if (world.getBlockState(coords.down(4)).getBlock() != Blocks.BEDROCK && world == overworld) { spawnPlayer(player, coords, false); + } } - persist.putBoolean(TAG_MADE_ISLAND, true); } } @@ -83,37 +82,40 @@ public final class SkyblockWorldEvents { @SubscribeEvent public static void onPlayerInteract(PlayerInteractEvent.RightClickBlock event) { - if(Botania.gardenOfGlassLoaded) { + if (Botania.gardenOfGlassLoaded) { ItemStack equipped = event.getItemStack(); PlayerEntity player = event.getPlayer(); - if(equipped.isEmpty() && player.isSneaking()) { + if (equipped.isEmpty() && player.isSneaking()) { BlockState state = event.getWorld().getBlockState(event.getPos()); Block block = state.getBlock(); - if(ModTags.Blocks.PEBBLE_SOURCES.contains(block)) { + if (ModTags.Blocks.PEBBLE_SOURCES.contains(block)) { SoundType st = state.getSoundType(event.getWorld(), event.getPos(), player); player.playSound(st.getBreakSound(), st.getVolume() * 0.4F, st.getPitch() + (float) (Math.random() * 0.2 - 0.1)); - if(event.getWorld().isRemote) + if (event.getWorld().isRemote) { player.swingArm(event.getHand()); - else if(Math.random() < 0.8) + } else if (Math.random() < 0.8) { player.dropItem(new ItemStack(ModItems.pebble), false); + } event.setCanceled(true); event.setCancellationResult(ActionResultType.SUCCESS); } - } else if(!equipped.isEmpty() && equipped.getItem() == Items.BOWL) { + } else if (!equipped.isEmpty() && equipped.getItem() == Items.BOWL) { BlockRayTraceResult rtr = ToolCommons.raytraceFromEntity(player, 4.5F, true); - if(rtr.getType() == RayTraceResult.Type.BLOCK) { + if (rtr.getType() == RayTraceResult.Type.BLOCK) { BlockPos pos = rtr.getPos(); - if(event.getWorld().getBlockState(pos).getMaterial() == Material.WATER) { - if(!event.getWorld().isRemote) { + if (event.getWorld().getBlockState(pos).getMaterial() == Material.WATER) { + if (!event.getWorld().isRemote) { equipped.shrink(1); - if(equipped.isEmpty()) + if (equipped.isEmpty()) { player.setHeldItem(event.getHand(), new ItemStack(ModItems.waterBowl)); - else ItemHandlerHelper.giveItemToPlayer(player, new ItemStack(ModItems.waterBowl)); + } else { + ItemHandlerHelper.giveItemToPlayer(player, new ItemStack(ModItems.waterBowl)); + } } event.setCanceled(true); @@ -125,7 +127,7 @@ public final class SkyblockWorldEvents { } private static final ResourceLocation TARGET_LOOT_TABLE = new ResourceLocation("blocks/grass"); - + @SubscribeEvent public static void loadLoot(LootTableLoadEvent event) { if (Botania.gardenOfGlassLoaded && event.getName().equals(TARGET_LOOT_TABLE)) { @@ -135,16 +137,17 @@ public final class SkyblockWorldEvents { public static void spawnPlayer(PlayerEntity player, BlockPos pos, boolean fabricated) { CompoundNBT data = player.getPersistentData(); - if(!data.contains(PlayerEntity.PERSISTED_NBT_TAG)) + if (!data.contains(PlayerEntity.PERSISTED_NBT_TAG)) { data.put(PlayerEntity.PERSISTED_NBT_TAG, new CompoundNBT()); + } CompoundNBT persist = data.getCompound(PlayerEntity.PERSISTED_NBT_TAG); final boolean test = false; - if(test || !persist.getBoolean(TAG_HAS_OWN_ISLAND)) { + if (test || !persist.getBoolean(TAG_HAS_OWN_ISLAND)) { createSkyblock(player.world, pos); - if(player instanceof ServerPlayerEntity) { + if (player instanceof ServerPlayerEntity) { ServerPlayerEntity pmp = (ServerPlayerEntity) player; pmp.setPositionAndUpdate(pos.getX() + 0.5, pos.getY() + 1.6, pos.getZ() + 0.5); pmp.setSpawnPoint(pos, true, false, player.world.getDimension().getType()); @@ -153,7 +156,7 @@ public final class SkyblockWorldEvents { } } - if(fabricated) { + if (fabricated) { persist.putBoolean(TAG_HAS_OWN_ISLAND, true); persist.putDouble(TAG_ISLAND_X, player.getX()); persist.putDouble(TAG_ISLAND_Y, player.getY()); @@ -164,7 +167,7 @@ public final class SkyblockWorldEvents { double posY = persist.getDouble(TAG_ISLAND_Y); double posZ = persist.getDouble(TAG_ISLAND_Z); - if(player instanceof ServerPlayerEntity) { + if (player instanceof ServerPlayerEntity) { ServerPlayerEntity pmp = (ServerPlayerEntity) player; pmp.setPositionAndUpdate(posX, posY, posZ); } @@ -172,10 +175,13 @@ public final class SkyblockWorldEvents { } public static void createSkyblock(World world, BlockPos pos) { - for(int i = 0; i < 3; i++) - for(int j = 0; j < 4; j++) - for(int k = 0; k < 3; k++) + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 4; j++) { + for (int k = 0; k < 3; k++) { world.setBlockState(pos.add(-1 + i, -1 - j, -1 + k), j == 0 ? Blocks.GRASS_BLOCK.getDefaultState() : Blocks.DIRT.getDefaultState()); + } + } + } world.setBlockState(pos.add(-1, -2, 0), Blocks.WATER.getDefaultState()); world.setBlockState(pos.add(1, 2, 1), ModBlocks.manaFlame.getDefaultState()); int r = 70 + world.rand.nextInt(185); @@ -185,20 +191,21 @@ public final class SkyblockWorldEvents { ((TileManaFlame) world.getTileEntity(pos.add(1, 2, 1))).setColor(color); int[][] rootPositions = new int[][] { - { -1, -3, -1 }, - { -2, -4, -1 }, - { -2, -4, -2 }, - { +1, -4, -1 }, - { +1, -5, -1 }, - { +2, -5, -1 }, - { +2, -6, +0 }, - { +0, -4, +2 }, - { +0, -5, +2 }, - { +0, -5, +3 }, - { +0, -6, +3 }, + { -1, -3, -1 }, + { -2, -4, -1 }, + { -2, -4, -2 }, + { +1, -4, -1 }, + { +1, -5, -1 }, + { +2, -5, -1 }, + { +2, -6, +0 }, + { +0, -4, +2 }, + { +0, -5, +2 }, + { +0, -5, +3 }, + { +0, -6, +3 }, }; - for(int[] root : rootPositions) + for (int[] root : rootPositions) { world.setBlockState(pos.add(root[0], root[1], root[2]), ModBlocks.root.getDefaultState()); + } world.setBlockState(pos.down(4), Blocks.BEDROCK.getDefaultState()); } diff --git a/src/main/java/vazkii/botania/common/world/WorldTypeSkyblock.java b/src/main/java/vazkii/botania/common/world/WorldTypeSkyblock.java index 7911283f3..453eb3987 100644 --- a/src/main/java/vazkii/botania/common/world/WorldTypeSkyblock.java +++ b/src/main/java/vazkii/botania/common/world/WorldTypeSkyblock.java @@ -1,27 +1,19 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [Jul 7, 2015, 2:06:01 AM (GMT)] */ package vazkii.botania.common.world; -import net.minecraft.block.Blocks; import net.minecraft.world.World; import net.minecraft.world.WorldType; -import net.minecraft.world.biome.Biomes; -import net.minecraft.world.biome.provider.BiomeProvider; import net.minecraft.world.biome.provider.BiomeProviderType; import net.minecraft.world.biome.provider.OverworldBiomeProviderSettings; import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.gen.ChunkGenerator; -import net.minecraft.world.gen.ChunkGeneratorType; -import net.minecraft.world.gen.FlatGenerationSettings; -import net.minecraft.world.gen.FlatLayerInfo; import net.minecraft.world.gen.OverworldGenSettings; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -32,7 +24,7 @@ public class WorldTypeSkyblock extends WorldType { public WorldTypeSkyblock() { super("botania-skyblock"); - + } public static boolean isWorldSkyblock(World world) { @@ -63,8 +55,7 @@ public class WorldTypeSkyblock extends WorldType { /* In skyblock worlds, do not darken the sky until player hits y=0 */ @Override - public double getHorizon(World world) - { + public double getHorizon(World world) { return 0.0D; } diff --git a/src/main/java/vazkii/botania/data/BlockLootProvider.java b/src/main/java/vazkii/botania/data/BlockLootProvider.java index 9412573ce..771a60051 100644 --- a/src/main/java/vazkii/botania/data/BlockLootProvider.java +++ b/src/main/java/vazkii/botania/data/BlockLootProvider.java @@ -1,8 +1,17 @@ +/* + * This class is 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 + */ package vazkii.botania.data; import com.google.common.base.Stopwatch; import com.google.gson.Gson; import com.google.gson.GsonBuilder; + import net.minecraft.advancements.criterion.EnchantmentPredicate; import net.minecraft.advancements.criterion.ItemPredicate; import net.minecraft.advancements.criterion.MinMaxBounds; @@ -20,10 +29,8 @@ import net.minecraft.state.properties.SlabType; import net.minecraft.util.ResourceLocation; import net.minecraft.world.storage.loot.AlternativesLootEntry; import net.minecraft.world.storage.loot.ConstantRange; -import net.minecraft.world.storage.loot.DynamicLootEntry; import net.minecraft.world.storage.loot.ItemLootEntry; import net.minecraft.world.storage.loot.LootEntry; -import net.minecraft.world.storage.loot.LootFunction; import net.minecraft.world.storage.loot.LootParameterSets; import net.minecraft.world.storage.loot.LootPool; import net.minecraft.world.storage.loot.LootTable; @@ -38,10 +45,10 @@ import net.minecraft.world.storage.loot.functions.CopyNbt; import net.minecraft.world.storage.loot.functions.ExplosionDecay; import net.minecraft.world.storage.loot.functions.SetCount; import net.minecraftforge.registries.ForgeRegistries; + import vazkii.botania.api.subtile.TileEntityGeneratingFlower; import vazkii.botania.common.Botania; import vazkii.botania.common.block.BlockAltGrass; -import vazkii.botania.common.block.BlockCacophonium; import vazkii.botania.common.block.BlockModDoubleFlower; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.ModSubtiles; @@ -55,6 +62,7 @@ import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; + import java.io.IOException; import java.nio.file.Path; import java.util.HashMap; @@ -63,176 +71,180 @@ import java.util.concurrent.TimeUnit; import java.util.function.Function; public class BlockLootProvider implements IDataProvider { - private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); - private final DataGenerator generator; - private final Map> functionTable = new HashMap<>(); + private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); + private final DataGenerator generator; + private final Map> functionTable = new HashMap<>(); - public BlockLootProvider(DataGenerator generator) { - this.generator = generator; + public BlockLootProvider(DataGenerator generator) { + this.generator = generator; - Stopwatch s = Stopwatch.createStarted(); - for (Block b : ForgeRegistries.BLOCKS) { - if (!LibMisc.MOD_ID.equals(b.getRegistryName().getNamespace())) - continue; - if (b instanceof SlabBlock) - functionTable.put(b, BlockLootProvider::genSlab); - else if (b instanceof BlockModDoubleFlower) - functionTable.put(b, BlockLootProvider::genDoubleFlower); - else if (b instanceof BlockAltGrass) - functionTable.put(b, BlockLootProvider::genAltGrass); - else if (b.getRegistryName().getPath().matches(LibBlockNames.METAMORPHIC_PREFIX + "\\w+" + "_stone")) - functionTable.put(b, BlockLootProvider::genMetamorphicStone); - } + Stopwatch s = Stopwatch.createStarted(); + for (Block b : ForgeRegistries.BLOCKS) { + if (!LibMisc.MOD_ID.equals(b.getRegistryName().getNamespace())) { + continue; + } + if (b instanceof SlabBlock) { + functionTable.put(b, BlockLootProvider::genSlab); + } else if (b instanceof BlockModDoubleFlower) { + functionTable.put(b, BlockLootProvider::genDoubleFlower); + } else if (b instanceof BlockAltGrass) { + functionTable.put(b, BlockLootProvider::genAltGrass); + } else if (b.getRegistryName().getPath().matches(LibBlockNames.METAMORPHIC_PREFIX + "\\w+" + "_stone")) { + functionTable.put(b, BlockLootProvider::genMetamorphicStone); + } + } - // Empty - functionTable.put(ModBlocks.bifrost, BlockLootProvider::empty); - functionTable.put(ModBlocks.cocoon, BlockLootProvider::empty); - functionTable.put(ModBlocks.fakeAir, BlockLootProvider::empty); - functionTable.put(ModBlocks.manaFlame, BlockLootProvider::empty); - functionTable.put(ModBlocks.pistonRelay, BlockLootProvider::empty); + // Empty + functionTable.put(ModBlocks.bifrost, BlockLootProvider::empty); + functionTable.put(ModBlocks.cocoon, BlockLootProvider::empty); + functionTable.put(ModBlocks.fakeAir, BlockLootProvider::empty); + functionTable.put(ModBlocks.manaFlame, BlockLootProvider::empty); + functionTable.put(ModBlocks.pistonRelay, BlockLootProvider::empty); - // Redirects - functionTable.put(ModBlocks.cacophonium, b -> genRegular(Blocks.NOTE_BLOCK)); - functionTable.put(ModBlocks.enchantedSoil, b -> genRegular(Blocks.DIRT)); - functionTable.put(ModBlocks.enchanter, b -> genRegular(Blocks.LAPIS_BLOCK)); - functionTable.put(ModBlocks.mossyAltar, b -> genRegular(ModBlocks.defaultAltar)); + // Redirects + functionTable.put(ModBlocks.cacophonium, b -> genRegular(Blocks.NOTE_BLOCK)); + functionTable.put(ModBlocks.enchantedSoil, b -> genRegular(Blocks.DIRT)); + functionTable.put(ModBlocks.enchanter, b -> genRegular(Blocks.LAPIS_BLOCK)); + functionTable.put(ModBlocks.mossyAltar, b -> genRegular(ModBlocks.defaultAltar)); - // Special - functionTable.put(ModBlocks.cellBlock, BlockLootProvider::genCellBlock); - functionTable.put(ModBlocks.root, BlockLootProvider::genRoot); - functionTable.put(ModBlocks.solidVines, BlockLootProvider::genSolidVine); - functionTable.put(ModBlocks.tinyPotato, BlockLootProvider::genTinyPotato); + // Special + functionTable.put(ModBlocks.cellBlock, BlockLootProvider::genCellBlock); + functionTable.put(ModBlocks.root, BlockLootProvider::genRoot); + functionTable.put(ModBlocks.solidVines, BlockLootProvider::genSolidVine); + functionTable.put(ModBlocks.tinyPotato, BlockLootProvider::genTinyPotato); - // Flower NBT saving - functionTable.put(ModSubtiles.gourmaryllis, b -> genCopyNbt(b, SubTileGourmaryllis.TAG_LAST_FOOD, SubTileGourmaryllis.TAG_LAST_FOOD_COUNT)); - functionTable.put(ModSubtiles.gourmaryllisFloating, b -> genCopyNbt(b, SubTileGourmaryllis.TAG_LAST_FOOD, SubTileGourmaryllis.TAG_LAST_FOOD_COUNT)); - functionTable.put(ModSubtiles.hydroangeas, b -> genCopyNbt(b, SubTileHydroangeas.TAG_COOLDOWN, TileEntityGeneratingFlower.TAG_PASSIVE_DECAY_TICKS)); - functionTable.put(ModSubtiles.hydroangeasFloating, b -> genCopyNbt(b, SubTileHydroangeas.TAG_COOLDOWN, TileEntityGeneratingFlower.TAG_PASSIVE_DECAY_TICKS)); - functionTable.put(ModSubtiles.munchdew, b -> genCopyNbt(b, SubTileMunchdew.TAG_COOLDOWN)); - functionTable.put(ModSubtiles.munchdewFloating, b -> genCopyNbt(b, SubTileMunchdew.TAG_COOLDOWN)); - functionTable.put(ModSubtiles.rafflowsia, b -> genCopyNbt(b, SubTileRafflowsia.TAG_LAST_FLOWER, SubTileRafflowsia.TAG_LAST_FLOWER_TIMES)); - functionTable.put(ModSubtiles.rafflowsiaFloating, b -> genCopyNbt(b, SubTileRafflowsia.TAG_LAST_FLOWER, SubTileRafflowsia.TAG_LAST_FLOWER_TIMES)); - functionTable.put(ModSubtiles.spectrolus, b -> genCopyNbt(b, SubTileSpectrolus.TAG_NEXT_COLOR)); - functionTable.put(ModSubtiles.spectrolusFloating, b -> genCopyNbt(b, SubTileSpectrolus.TAG_NEXT_COLOR)); - functionTable.put(ModSubtiles.thermalily, b -> genCopyNbt(b, SubTileHydroangeas.TAG_COOLDOWN)); - functionTable.put(ModSubtiles.thermalilyFloating, b -> genCopyNbt(b, SubTileHydroangeas.TAG_COOLDOWN)); - Botania.LOGGER.info("BLP constructed in {}", s.elapsed(TimeUnit.MILLISECONDS)); - } + // Flower NBT saving + functionTable.put(ModSubtiles.gourmaryllis, b -> genCopyNbt(b, SubTileGourmaryllis.TAG_LAST_FOOD, SubTileGourmaryllis.TAG_LAST_FOOD_COUNT)); + functionTable.put(ModSubtiles.gourmaryllisFloating, b -> genCopyNbt(b, SubTileGourmaryllis.TAG_LAST_FOOD, SubTileGourmaryllis.TAG_LAST_FOOD_COUNT)); + functionTable.put(ModSubtiles.hydroangeas, b -> genCopyNbt(b, SubTileHydroangeas.TAG_COOLDOWN, TileEntityGeneratingFlower.TAG_PASSIVE_DECAY_TICKS)); + functionTable.put(ModSubtiles.hydroangeasFloating, b -> genCopyNbt(b, SubTileHydroangeas.TAG_COOLDOWN, TileEntityGeneratingFlower.TAG_PASSIVE_DECAY_TICKS)); + functionTable.put(ModSubtiles.munchdew, b -> genCopyNbt(b, SubTileMunchdew.TAG_COOLDOWN)); + functionTable.put(ModSubtiles.munchdewFloating, b -> genCopyNbt(b, SubTileMunchdew.TAG_COOLDOWN)); + functionTable.put(ModSubtiles.rafflowsia, b -> genCopyNbt(b, SubTileRafflowsia.TAG_LAST_FLOWER, SubTileRafflowsia.TAG_LAST_FLOWER_TIMES)); + functionTable.put(ModSubtiles.rafflowsiaFloating, b -> genCopyNbt(b, SubTileRafflowsia.TAG_LAST_FLOWER, SubTileRafflowsia.TAG_LAST_FLOWER_TIMES)); + functionTable.put(ModSubtiles.spectrolus, b -> genCopyNbt(b, SubTileSpectrolus.TAG_NEXT_COLOR)); + functionTable.put(ModSubtiles.spectrolusFloating, b -> genCopyNbt(b, SubTileSpectrolus.TAG_NEXT_COLOR)); + functionTable.put(ModSubtiles.thermalily, b -> genCopyNbt(b, SubTileHydroangeas.TAG_COOLDOWN)); + functionTable.put(ModSubtiles.thermalilyFloating, b -> genCopyNbt(b, SubTileHydroangeas.TAG_COOLDOWN)); + Botania.LOGGER.info("BLP constructed in {}", s.elapsed(TimeUnit.MILLISECONDS)); + } - @Override - public void act(DirectoryCache cache) throws IOException { - Stopwatch s = Stopwatch.createStarted(); - Map tables = new HashMap<>(); + @Override + public void act(DirectoryCache cache) throws IOException { + Stopwatch s = Stopwatch.createStarted(); + Map tables = new HashMap<>(); - for (Block b : ForgeRegistries.BLOCKS) { - if(!LibMisc.MOD_ID.equals(b.getRegistryName().getNamespace())) - continue; - Function func = functionTable.getOrDefault(b, BlockLootProvider::genRegular); - tables.put(b.getRegistryName(), func.apply(b)); - } - Botania.LOGGER.info("BLP run in {}", s.elapsed(TimeUnit.MILLISECONDS)); + for (Block b : ForgeRegistries.BLOCKS) { + if (!LibMisc.MOD_ID.equals(b.getRegistryName().getNamespace())) { + continue; + } + Function func = functionTable.getOrDefault(b, BlockLootProvider::genRegular); + tables.put(b.getRegistryName(), func.apply(b)); + } + Botania.LOGGER.info("BLP run in {}", s.elapsed(TimeUnit.MILLISECONDS)); - for (Map.Entry e : tables.entrySet()) { - Path path = getPath(generator.getOutputFolder(), e.getKey()); - IDataProvider.save(GSON, cache, LootTableManager.toJson(e.getValue().setParameterSet(LootParameterSets.BLOCK).build()), path); - } - Botania.LOGGER.info("BLP written in {}", s.elapsed(TimeUnit.MILLISECONDS)); - } + for (Map.Entry e : tables.entrySet()) { + Path path = getPath(generator.getOutputFolder(), e.getKey()); + IDataProvider.save(GSON, cache, LootTableManager.toJson(e.getValue().setParameterSet(LootParameterSets.BLOCK).build()), path); + } + Botania.LOGGER.info("BLP written in {}", s.elapsed(TimeUnit.MILLISECONDS)); + } - private static Path getPath(Path root, ResourceLocation id) { - return root.resolve("data/" + id.getNamespace() + "/loot_tables/blocks/" + id.getPath() + ".json"); - } + private static Path getPath(Path root, ResourceLocation id) { + return root.resolve("data/" + id.getNamespace() + "/loot_tables/blocks/" + id.getPath() + ".json"); + } - private static LootTable.Builder empty(Block b) { - return LootTable.builder(); - } + private static LootTable.Builder empty(Block b) { + return LootTable.builder(); + } - private static LootTable.Builder genCopyNbt(Block b, String... tags) { - LootEntry.Builder entry = ItemLootEntry.builder(b); - CopyNbt.Builder func = CopyNbt.func_215881_a(CopyNbt.Source.BLOCK_ENTITY); - for (String tag : tags) { - func = func.func_216056_a(tag, "BlockEntityTag." + tag); - } - LootPool.Builder pool = LootPool.builder().name("main").rolls(ConstantRange.of(1)).addEntry(entry) - .acceptCondition(SurvivesExplosion.builder()) - .acceptFunction(func); - return LootTable.builder().addLootPool(pool); - } + private static LootTable.Builder genCopyNbt(Block b, String... tags) { + LootEntry.Builder entry = ItemLootEntry.builder(b); + CopyNbt.Builder func = CopyNbt.func_215881_a(CopyNbt.Source.BLOCK_ENTITY); + for (String tag : tags) { + func = func.func_216056_a(tag, "BlockEntityTag." + tag); + } + LootPool.Builder pool = LootPool.builder().name("main").rolls(ConstantRange.of(1)).addEntry(entry) + .acceptCondition(SurvivesExplosion.builder()) + .acceptFunction(func); + return LootTable.builder().addLootPool(pool); + } - private static LootTable.Builder genCellBlock(Block b) { - ItemPredicate.Builder silkPred = ItemPredicate.Builder.create() - .enchantment(new EnchantmentPredicate(Enchantments.SILK_TOUCH, MinMaxBounds.IntBound.atLeast(1))); - LootEntry.Builder silk = ItemLootEntry.builder(b) - .acceptCondition(MatchTool.builder(silkPred)); - return LootTable.builder().addLootPool(LootPool.builder().name("main").rolls(ConstantRange.of(1)).addEntry(silk)); - } + private static LootTable.Builder genCellBlock(Block b) { + ItemPredicate.Builder silkPred = ItemPredicate.Builder.create() + .enchantment(new EnchantmentPredicate(Enchantments.SILK_TOUCH, MinMaxBounds.IntBound.atLeast(1))); + LootEntry.Builder silk = ItemLootEntry.builder(b) + .acceptCondition(MatchTool.builder(silkPred)); + return LootTable.builder().addLootPool(LootPool.builder().name("main").rolls(ConstantRange.of(1)).addEntry(silk)); + } - private static LootTable.Builder genTinyPotato(Block b) { - LootEntry.Builder entry = ItemLootEntry.builder(b) - .acceptFunction(CopyName.builder(CopyName.Source.BLOCK_ENTITY)); - LootPool.Builder pool = LootPool.builder().name("main").rolls(ConstantRange.of(1)).addEntry(entry) - .acceptCondition(SurvivesExplosion.builder()); - return LootTable.builder().addLootPool(pool); - } + private static LootTable.Builder genTinyPotato(Block b) { + LootEntry.Builder entry = ItemLootEntry.builder(b) + .acceptFunction(CopyName.builder(CopyName.Source.BLOCK_ENTITY)); + LootPool.Builder pool = LootPool.builder().name("main").rolls(ConstantRange.of(1)).addEntry(entry) + .acceptCondition(SurvivesExplosion.builder()); + return LootTable.builder().addLootPool(pool); + } - private static LootTable.Builder genMetamorphicStone(Block b) { - String cobbleName = b.getRegistryName().getPath().replaceAll("_stone", "_cobblestone"); - Block cobble = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(LibMisc.MOD_ID, cobbleName)); - if (cobble == Blocks.AIR) - throw new RuntimeException("Couldn't find metamorphic cobble!"); - return genRegular(cobble); - } + private static LootTable.Builder genMetamorphicStone(Block b) { + String cobbleName = b.getRegistryName().getPath().replaceAll("_stone", "_cobblestone"); + Block cobble = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(LibMisc.MOD_ID, cobbleName)); + if (cobble == Blocks.AIR) { + throw new RuntimeException("Couldn't find metamorphic cobble!"); + } + return genRegular(cobble); + } - private static LootTable.Builder genSolidVine(Block b) { - LootEntry.Builder entry = TableLootEntry.builder(new ResourceLocation("blocks/vine")); - return LootTable.builder().addLootPool(LootPool.builder().name("main").rolls(ConstantRange.of(1)).addEntry(entry)); - } + private static LootTable.Builder genSolidVine(Block b) { + LootEntry.Builder entry = TableLootEntry.builder(new ResourceLocation("blocks/vine")); + return LootTable.builder().addLootPool(LootPool.builder().name("main").rolls(ConstantRange.of(1)).addEntry(entry)); + } - private static LootTable.Builder genRoot(Block b) { - LootEntry.Builder entry = ItemLootEntry.builder(ModItems.livingroot) - .acceptFunction(SetCount.builder(RandomValueRange.of(2, 4))) - .acceptFunction(ExplosionDecay.builder()); - return LootTable.builder().addLootPool(LootPool.builder().name("main").rolls(ConstantRange.of(1)).addEntry(entry)); - } + private static LootTable.Builder genRoot(Block b) { + LootEntry.Builder entry = ItemLootEntry.builder(ModItems.livingroot) + .acceptFunction(SetCount.builder(RandomValueRange.of(2, 4))) + .acceptFunction(ExplosionDecay.builder()); + return LootTable.builder().addLootPool(LootPool.builder().name("main").rolls(ConstantRange.of(1)).addEntry(entry)); + } - private static LootTable.Builder genSlab(Block b) { - LootEntry.Builder entry = ItemLootEntry.builder(b) - .acceptFunction(SetCount.builder(ConstantRange.of(2)) - .acceptCondition(BlockStateProperty.builder(b).func_227567_a_(StatePropertiesPredicate.Builder.create().exactMatch(SlabBlock.TYPE, SlabType.DOUBLE)))) - .acceptFunction(ExplosionDecay.builder()); - return LootTable.builder().addLootPool(LootPool.builder().name("main").rolls(ConstantRange.of(1)).addEntry(entry)); - } + private static LootTable.Builder genSlab(Block b) { + LootEntry.Builder entry = ItemLootEntry.builder(b) + .acceptFunction(SetCount.builder(ConstantRange.of(2)) + .acceptCondition(BlockStateProperty.builder(b).func_227567_a_(StatePropertiesPredicate.Builder.create().exactMatch(SlabBlock.TYPE, SlabType.DOUBLE)))) + .acceptFunction(ExplosionDecay.builder()); + return LootTable.builder().addLootPool(LootPool.builder().name("main").rolls(ConstantRange.of(1)).addEntry(entry)); + } - private static LootTable.Builder genDoubleFlower(Block b) { - LootEntry.Builder entry = ItemLootEntry.builder(b) - .acceptCondition(BlockStateProperty.builder(b).func_227567_a_(StatePropertiesPredicate.Builder.create().exactMatch(DoublePlantBlock.HALF, DoubleBlockHalf.LOWER))); - LootPool.Builder pool = LootPool.builder().name("main").rolls(ConstantRange.of(1)).addEntry(entry) - .acceptCondition(SurvivesExplosion.builder()); - return LootTable.builder().addLootPool(pool); - } + private static LootTable.Builder genDoubleFlower(Block b) { + LootEntry.Builder entry = ItemLootEntry.builder(b) + .acceptCondition(BlockStateProperty.builder(b).func_227567_a_(StatePropertiesPredicate.Builder.create().exactMatch(DoublePlantBlock.HALF, DoubleBlockHalf.LOWER))); + LootPool.Builder pool = LootPool.builder().name("main").rolls(ConstantRange.of(1)).addEntry(entry) + .acceptCondition(SurvivesExplosion.builder()); + return LootTable.builder().addLootPool(pool); + } - private static LootTable.Builder genAltGrass(Block b) { - ItemPredicate.Builder silkPred = ItemPredicate.Builder.create() - .enchantment(new EnchantmentPredicate(Enchantments.SILK_TOUCH, MinMaxBounds.IntBound.atLeast(1))); - LootEntry.Builder silk = ItemLootEntry.builder(b) - .acceptCondition(MatchTool.builder(silkPred)); - LootEntry.Builder dirt = ItemLootEntry.builder(Blocks.DIRT) - .acceptCondition(SurvivesExplosion.builder()); - LootEntry.Builder entry = AlternativesLootEntry.builder(silk, dirt); - LootPool.Builder pool = LootPool.builder().name("main").rolls(ConstantRange.of(1)).addEntry(entry); - return LootTable.builder().addLootPool(pool); - } + private static LootTable.Builder genAltGrass(Block b) { + ItemPredicate.Builder silkPred = ItemPredicate.Builder.create() + .enchantment(new EnchantmentPredicate(Enchantments.SILK_TOUCH, MinMaxBounds.IntBound.atLeast(1))); + LootEntry.Builder silk = ItemLootEntry.builder(b) + .acceptCondition(MatchTool.builder(silkPred)); + LootEntry.Builder dirt = ItemLootEntry.builder(Blocks.DIRT) + .acceptCondition(SurvivesExplosion.builder()); + LootEntry.Builder entry = AlternativesLootEntry.builder(silk, dirt); + LootPool.Builder pool = LootPool.builder().name("main").rolls(ConstantRange.of(1)).addEntry(entry); + return LootTable.builder().addLootPool(pool); + } - private static LootTable.Builder genRegular(Block b) { - LootEntry.Builder entry = ItemLootEntry.builder(b); - LootPool.Builder pool = LootPool.builder().name("main").rolls(ConstantRange.of(1)).addEntry(entry) - .acceptCondition(SurvivesExplosion.builder()); - return LootTable.builder().addLootPool(pool); - } + private static LootTable.Builder genRegular(Block b) { + LootEntry.Builder entry = ItemLootEntry.builder(b); + LootPool.Builder pool = LootPool.builder().name("main").rolls(ConstantRange.of(1)).addEntry(entry) + .acceptCondition(SurvivesExplosion.builder()); + return LootTable.builder().addLootPool(pool); + } - @Nonnull - @Override - public String getName() { - return "Botania block loot tables"; - } + @Nonnull + @Override + public String getName() { + return "Botania block loot tables"; + } } diff --git a/src/main/java/vazkii/botania/data/BlockTagProvider.java b/src/main/java/vazkii/botania/data/BlockTagProvider.java index ed172e80c..bfc0ffe1b 100644 --- a/src/main/java/vazkii/botania/data/BlockTagProvider.java +++ b/src/main/java/vazkii/botania/data/BlockTagProvider.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.data; import net.minecraft.block.Block; @@ -9,80 +17,82 @@ import net.minecraft.data.BlockTagsProvider; import net.minecraft.data.DataGenerator; import net.minecraft.item.DyeColor; import net.minecraft.tags.BlockTags; + import vazkii.botania.common.block.BlockFloatingSpecialFlower; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.lib.LibMisc; import vazkii.botania.common.lib.ModTags; import javax.annotation.Nonnull; + import java.util.Arrays; import java.util.Comparator; import java.util.function.Predicate; public class BlockTagProvider extends BlockTagsProvider { - public BlockTagProvider(DataGenerator generator) { - super(generator); - } + public BlockTagProvider(DataGenerator generator) { + super(generator); + } - @Override - protected void registerTags() { - Predicate botania = b -> LibMisc.MOD_ID.equals(b.getRegistryName().getNamespace()); + @Override + protected void registerTags() { + Predicate botania = b -> LibMisc.MOD_ID.equals(b.getRegistryName().getNamespace()); - getBuilder(BlockTags.RAILS).add(ModBlocks.ghostRail); + getBuilder(BlockTags.RAILS).add(ModBlocks.ghostRail); - getBuilder(BlockTags.SLABS).add(registry.stream().filter(botania) - .filter(b -> b instanceof SlabBlock) - .sorted(Comparator.comparing(Block::getRegistryName)) - .toArray(Block[]::new)); + getBuilder(BlockTags.SLABS).add(registry.stream().filter(botania) + .filter(b -> b instanceof SlabBlock) + .sorted(Comparator.comparing(Block::getRegistryName)) + .toArray(Block[]::new)); - getBuilder(BlockTags.STAIRS).add(registry.stream().filter(botania) - .filter(b -> b instanceof StairsBlock) - .sorted(Comparator.comparing(Block::getRegistryName)) - .toArray(Block[]::new)); + getBuilder(BlockTags.STAIRS).add(registry.stream().filter(botania) + .filter(b -> b instanceof StairsBlock) + .sorted(Comparator.comparing(Block::getRegistryName)) + .toArray(Block[]::new)); - getBuilder(BlockTags.WALLS).add(registry.stream().filter(botania) - .filter(b -> b instanceof WallBlock) - .sorted(Comparator.comparing(Block::getRegistryName)) - .toArray(Block[]::new)); + getBuilder(BlockTags.WALLS).add(registry.stream().filter(botania) + .filter(b -> b instanceof WallBlock) + .sorted(Comparator.comparing(Block::getRegistryName)) + .toArray(Block[]::new)); - getBuilder(BlockTags.FENCES).add(registry.stream().filter(botania) - .filter(b -> b instanceof FenceBlock) - .sorted(Comparator.comparing(Block::getRegistryName)) - .toArray(Block[]::new)); + getBuilder(BlockTags.FENCES).add(registry.stream().filter(botania) + .filter(b -> b instanceof FenceBlock) + .sorted(Comparator.comparing(Block::getRegistryName)) + .toArray(Block[]::new)); - getBuilder(ModTags.Blocks.MUNDANE_FLOATING_FLOWERS).add( - Arrays.stream(DyeColor.values()) - .map(ModBlocks::getFloatingFlower) - .sorted(Comparator.comparing(Block::getRegistryName)) - .toArray(Block[]::new) - ); + getBuilder(ModTags.Blocks.MUNDANE_FLOATING_FLOWERS).add( + Arrays.stream(DyeColor.values()) + .map(ModBlocks::getFloatingFlower) + .sorted(Comparator.comparing(Block::getRegistryName)) + .toArray(Block[]::new) + ); - getBuilder(ModTags.Blocks.SPECIAL_FLOATING_FLOWERS).add(registry.stream().filter(botania) - .filter(b -> b instanceof BlockFloatingSpecialFlower) - .sorted(Comparator.comparing(Block::getRegistryName)) - .toArray(Block[]::new) - ); + getBuilder(ModTags.Blocks.SPECIAL_FLOATING_FLOWERS).add(registry.stream().filter(botania) + .filter(b -> b instanceof BlockFloatingSpecialFlower) + .sorted(Comparator.comparing(Block::getRegistryName)) + .toArray(Block[]::new) + ); - getBuilder(ModTags.Blocks.FLOATING_FLOWERS).add(ModTags.Blocks.MUNDANE_FLOATING_FLOWERS, ModTags.Blocks.SPECIAL_FLOATING_FLOWERS); + getBuilder(ModTags.Blocks.FLOATING_FLOWERS).add(ModTags.Blocks.MUNDANE_FLOATING_FLOWERS, ModTags.Blocks.SPECIAL_FLOATING_FLOWERS); - getBuilder(ModTags.Blocks.MYSTICAL_FLOWERS).add( - Arrays.stream(DyeColor.values()) - .map(ModBlocks::getFlower) - .sorted(Comparator.comparing(Block::getRegistryName)) - .toArray(Block[]::new) - ); + getBuilder(ModTags.Blocks.MYSTICAL_FLOWERS).add( + Arrays.stream(DyeColor.values()) + .map(ModBlocks::getFlower) + .sorted(Comparator.comparing(Block::getRegistryName)) + .toArray(Block[]::new) + ); - getBuilder(ModTags.Blocks.DOUBLE_MYSTICAL_FLOWERS).add( - Arrays.stream(DyeColor.values()) - .map(ModBlocks::getDoubleFlower) - .sorted(Comparator.comparing(Block::getRegistryName)) - .toArray(Block[]::new) - ); - } + getBuilder(ModTags.Blocks.DOUBLE_MYSTICAL_FLOWERS).add( + Arrays.stream(DyeColor.values()) + .map(ModBlocks::getDoubleFlower) + .sorted(Comparator.comparing(Block::getRegistryName)) + .toArray(Block[]::new) + ); + } - @Nonnull - @Override - public String getName() { - return "Botania block tags"; - } + @Nonnull + @Override + public String getName() { + return "Botania block tags"; + } } diff --git a/src/main/java/vazkii/botania/data/BlockstateProvider.java b/src/main/java/vazkii/botania/data/BlockstateProvider.java index 95a19fb08..ec99c7b30 100644 --- a/src/main/java/vazkii/botania/data/BlockstateProvider.java +++ b/src/main/java/vazkii/botania/data/BlockstateProvider.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.data; import net.minecraft.block.Block; @@ -20,6 +28,7 @@ import net.minecraftforge.client.model.generators.BlockStateProvider; import net.minecraftforge.client.model.generators.ConfiguredModel; import net.minecraftforge.client.model.generators.ExistingFileHelper; import net.minecraftforge.client.model.generators.ModelFile; + import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.common.block.BlockAltGrass; import vazkii.botania.common.block.ModBlocks; @@ -35,114 +44,115 @@ import java.util.stream.IntStream; import static vazkii.botania.common.lib.ResourceLocationHelper.prefix; public class BlockstateProvider extends BlockStateProvider { - public BlockstateProvider(DataGenerator gen, ExistingFileHelper exFileHelper) { - super(gen, LibMisc.MOD_ID, exFileHelper); - } + public BlockstateProvider(DataGenerator gen, ExistingFileHelper exFileHelper) { + super(gen, LibMisc.MOD_ID, exFileHelper); + } - @Nonnull - @Override - public String getName() { - return "Botania Blockstates"; - } + @Nonnull + @Override + public String getName() { + return "Botania Blockstates"; + } - @Override - protected void registerStatesAndModels() { - Registry.BLOCK.stream().filter(b -> LibMisc.MOD_ID.equals(b.getRegistryName().getNamespace())) - .forEach(b -> { - if (b == ModBlocks.craftCrate || b == ModBlocks.ghostRail - || b == ModBlocks.solidVines) - return; + @Override + protected void registerStatesAndModels() { + Registry.BLOCK.stream().filter(b -> LibMisc.MOD_ID.equals(b.getRegistryName().getNamespace())) + .forEach(b -> { + if (b == ModBlocks.craftCrate || b == ModBlocks.ghostRail + || b == ModBlocks.solidVines) { + return; + } - String name = b.getRegistryName().getPath(); - if (name.contains("quartz") && b instanceof RotatedPillarBlock) { - ModelFile file = models().getExistingFile(prefix("block/" + name)); - getVariantBuilder(b) - .partialState().with(RotatedPillarBlock.AXIS, Direction.Axis.X).setModels(new ConfiguredModel(file, 90, 90, false)) - .partialState().with(RotatedPillarBlock.AXIS, Direction.Axis.Y).setModels(new ConfiguredModel(file)) - .partialState().with(RotatedPillarBlock.AXIS, Direction.Axis.Z).setModels(new ConfiguredModel(file, 90, 0, false)); - } else if (b instanceof SlabBlock) { - ModelFile file = models().getExistingFile(prefix("block/" + name)); - ModelFile fullFile = models().getExistingFile(prefix("block/" + name.substring(0, name.length() - LibBlockNames.SLAB_SUFFIX.length()))); - getVariantBuilder(b) - .partialState().with(SlabBlock.TYPE, SlabType.BOTTOM).setModels(new ConfiguredModel(file)) - .partialState().with(SlabBlock.TYPE, SlabType.TOP).setModels(new ConfiguredModel(file, 180, 0, true)) - .partialState().with(SlabBlock.TYPE, SlabType.DOUBLE).setModels(new ConfiguredModel(fullFile)); - } else if (b instanceof StairsBlock) { - ModelFile stair = models().getExistingFile(prefix("block/" + name)); - ModelFile inner = models().getExistingFile(prefix("block/" + name + "_inner")); - ModelFile outer = models().getExistingFile(prefix("block/" + name + "_outer")); - stairsBlock((StairsBlock) b, stair, inner, outer); - } else if (b instanceof WallBlock) { - ModelFile post = models().getExistingFile(prefix("block/" + name + "_post")); - ModelFile side = models().getExistingFile(prefix("block/" + name + "_side")); - wallBlock((WallBlock) b, post, side); - } else if (b instanceof FenceBlock) { - ModelFile post = models().getExistingFile(prefix("block/" + name + "_post")); - ModelFile side = models().getExistingFile(prefix("block/" + name + "_side")); - fourWayBlock((FenceBlock) b, post, side); - } else if (b instanceof FenceGateBlock) { - ModelFile gate = models().getExistingFile(prefix("block/" + name)); - ModelFile gateOpen = models().getExistingFile(prefix("block/" + name + "_open")); - ModelFile wall = models().getExistingFile(prefix("block/" + name + "_wall")); - ModelFile wallOpen = models().getExistingFile(prefix("block/" + name + "_wall_open")); - fenceGateBlock((FenceGateBlock) b, gate, gateOpen, wall, wallOpen); - } else if (b instanceof PaneBlock) { - ModelFile post = models().getExistingFile(prefix("block/" + name + "_post")); - ModelFile side = models().getExistingFile(prefix("block/" + name + "_side")); - ModelFile sideAlt = models().getExistingFile(prefix("block/" + name + "_side_alt")); - ModelFile noSide = models().getExistingFile(prefix("block/" + name + "_noside")); - ModelFile noSideAlt = models().getExistingFile(prefix("block/" + name + "_noside_alt")); - paneBlock((PaneBlock) b, post, side, sideAlt, noSide, noSideAlt); - } else if (b instanceof TallFlowerBlock) { - ModelFile bottom = models().getExistingFile(prefix("block/" + name)); - ModelFile top = models().getExistingFile(prefix("block/" + name + "_top")); - getVariantBuilder(b) - .partialState().with(TallFlowerBlock.HALF, DoubleBlockHalf.LOWER).setModels(new ConfiguredModel(bottom)) - .partialState().with(TallFlowerBlock.HALF, DoubleBlockHalf.UPPER).setModels(new ConfiguredModel(top)); - } else if (b instanceof BlockAltGrass) { - ModelFile model = models().getExistingFile(prefix("block/" + name)); - getVariantBuilder(b).partialState().setModels(new ConfiguredModel(model), - new ConfiguredModel(model, 0, 90, false), - new ConfiguredModel(model, 0, 180, false), - new ConfiguredModel(model, 0, 270, false)); - } else if (b == ModBlocks.gaiaHead || b == ModBlocks.gaiaHeadWall) { - ModelFile file = models().getExistingFile(new ResourceLocation("block/soul_sand")); - getVariantBuilder(b).partialState().setModels(new ConfiguredModel(file)); - } else if (b instanceof BlockPetalBlock) { - ModelFile file = models().getExistingFile(prefix("block/petal_block")); - getVariantBuilder(b).partialState().setModels(new ConfiguredModel(file)); - } else if (b instanceof BlockRedString) { - redStringBlock(b); - } else if (b == ModBlocks.elfGlass) { - ConfiguredModel[] files = IntStream.rangeClosed(0, 3) - .mapToObj(i -> models().getExistingFile(prefix("block/" + name + "_" + i))) - .map(ConfiguredModel::new).toArray(ConfiguredModel[]::new); - getVariantBuilder(b).partialState().setModels(files); - } else if (b == ModBlocks.enderEye || b == ModBlocks.manaDetector) { - ModelFile offFile = models().getExistingFile(prefix("block/" + name)); - ModelFile onFile = models().getExistingFile(prefix("block/" + name + "_powered")); - getVariantBuilder(b).partialState().with(BotaniaStateProps.POWERED, false).setModels(new ConfiguredModel(offFile)); - getVariantBuilder(b).partialState().with(BotaniaStateProps.POWERED, true).setModels(new ConfiguredModel(onFile)); - } else if (b == ModBlocks.tinyPotato || b == ModBlocks.felPumpkin || b == ModBlocks.pump) { - ModelFile file = models().getExistingFile(prefix("block/" + name)); - horizontalBlock(b, file); - } else if (b == ModBlocks.incensePlate) { - ModelFile file = models().getExistingFile(prefix("block/" + name)); - horizontalBlock(b, file, 0); - } else { - simpleBlock(b, models().getExistingFile(prefix("block/" + name))); - } - }); - } + String name = b.getRegistryName().getPath(); + if (name.contains("quartz") && b instanceof RotatedPillarBlock) { + ModelFile file = models().getExistingFile(prefix("block/" + name)); + getVariantBuilder(b) + .partialState().with(RotatedPillarBlock.AXIS, Direction.Axis.X).setModels(new ConfiguredModel(file, 90, 90, false)) + .partialState().with(RotatedPillarBlock.AXIS, Direction.Axis.Y).setModels(new ConfiguredModel(file)) + .partialState().with(RotatedPillarBlock.AXIS, Direction.Axis.Z).setModels(new ConfiguredModel(file, 90, 0, false)); + } else if (b instanceof SlabBlock) { + ModelFile file = models().getExistingFile(prefix("block/" + name)); + ModelFile fullFile = models().getExistingFile(prefix("block/" + name.substring(0, name.length() - LibBlockNames.SLAB_SUFFIX.length()))); + getVariantBuilder(b) + .partialState().with(SlabBlock.TYPE, SlabType.BOTTOM).setModels(new ConfiguredModel(file)) + .partialState().with(SlabBlock.TYPE, SlabType.TOP).setModels(new ConfiguredModel(file, 180, 0, true)) + .partialState().with(SlabBlock.TYPE, SlabType.DOUBLE).setModels(new ConfiguredModel(fullFile)); + } else if (b instanceof StairsBlock) { + ModelFile stair = models().getExistingFile(prefix("block/" + name)); + ModelFile inner = models().getExistingFile(prefix("block/" + name + "_inner")); + ModelFile outer = models().getExistingFile(prefix("block/" + name + "_outer")); + stairsBlock((StairsBlock) b, stair, inner, outer); + } else if (b instanceof WallBlock) { + ModelFile post = models().getExistingFile(prefix("block/" + name + "_post")); + ModelFile side = models().getExistingFile(prefix("block/" + name + "_side")); + wallBlock((WallBlock) b, post, side); + } else if (b instanceof FenceBlock) { + ModelFile post = models().getExistingFile(prefix("block/" + name + "_post")); + ModelFile side = models().getExistingFile(prefix("block/" + name + "_side")); + fourWayBlock((FenceBlock) b, post, side); + } else if (b instanceof FenceGateBlock) { + ModelFile gate = models().getExistingFile(prefix("block/" + name)); + ModelFile gateOpen = models().getExistingFile(prefix("block/" + name + "_open")); + ModelFile wall = models().getExistingFile(prefix("block/" + name + "_wall")); + ModelFile wallOpen = models().getExistingFile(prefix("block/" + name + "_wall_open")); + fenceGateBlock((FenceGateBlock) b, gate, gateOpen, wall, wallOpen); + } else if (b instanceof PaneBlock) { + ModelFile post = models().getExistingFile(prefix("block/" + name + "_post")); + ModelFile side = models().getExistingFile(prefix("block/" + name + "_side")); + ModelFile sideAlt = models().getExistingFile(prefix("block/" + name + "_side_alt")); + ModelFile noSide = models().getExistingFile(prefix("block/" + name + "_noside")); + ModelFile noSideAlt = models().getExistingFile(prefix("block/" + name + "_noside_alt")); + paneBlock((PaneBlock) b, post, side, sideAlt, noSide, noSideAlt); + } else if (b instanceof TallFlowerBlock) { + ModelFile bottom = models().getExistingFile(prefix("block/" + name)); + ModelFile top = models().getExistingFile(prefix("block/" + name + "_top")); + getVariantBuilder(b) + .partialState().with(TallFlowerBlock.HALF, DoubleBlockHalf.LOWER).setModels(new ConfiguredModel(bottom)) + .partialState().with(TallFlowerBlock.HALF, DoubleBlockHalf.UPPER).setModels(new ConfiguredModel(top)); + } else if (b instanceof BlockAltGrass) { + ModelFile model = models().getExistingFile(prefix("block/" + name)); + getVariantBuilder(b).partialState().setModels(new ConfiguredModel(model), + new ConfiguredModel(model, 0, 90, false), + new ConfiguredModel(model, 0, 180, false), + new ConfiguredModel(model, 0, 270, false)); + } else if (b == ModBlocks.gaiaHead || b == ModBlocks.gaiaHeadWall) { + ModelFile file = models().getExistingFile(new ResourceLocation("block/soul_sand")); + getVariantBuilder(b).partialState().setModels(new ConfiguredModel(file)); + } else if (b instanceof BlockPetalBlock) { + ModelFile file = models().getExistingFile(prefix("block/petal_block")); + getVariantBuilder(b).partialState().setModels(new ConfiguredModel(file)); + } else if (b instanceof BlockRedString) { + redStringBlock(b); + } else if (b == ModBlocks.elfGlass) { + ConfiguredModel[] files = IntStream.rangeClosed(0, 3) + .mapToObj(i -> models().getExistingFile(prefix("block/" + name + "_" + i))) + .map(ConfiguredModel::new).toArray(ConfiguredModel[]::new); + getVariantBuilder(b).partialState().setModels(files); + } else if (b == ModBlocks.enderEye || b == ModBlocks.manaDetector) { + ModelFile offFile = models().getExistingFile(prefix("block/" + name)); + ModelFile onFile = models().getExistingFile(prefix("block/" + name + "_powered")); + getVariantBuilder(b).partialState().with(BotaniaStateProps.POWERED, false).setModels(new ConfiguredModel(offFile)); + getVariantBuilder(b).partialState().with(BotaniaStateProps.POWERED, true).setModels(new ConfiguredModel(onFile)); + } else if (b == ModBlocks.tinyPotato || b == ModBlocks.felPumpkin || b == ModBlocks.pump) { + ModelFile file = models().getExistingFile(prefix("block/" + name)); + horizontalBlock(b, file); + } else if (b == ModBlocks.incensePlate) { + ModelFile file = models().getExistingFile(prefix("block/" + name)); + horizontalBlock(b, file, 0); + } else { + simpleBlock(b, models().getExistingFile(prefix("block/" + name))); + } + }); + } - private void redStringBlock(Block b) { - ModelFile file = models().getExistingFile(prefix("block/" + b.getRegistryName().getPath())); - getVariantBuilder(b) - .partialState().with(BlockStateProperties.FACING, Direction.NORTH).setModels(new ConfiguredModel(file)) - .partialState().with(BlockStateProperties.FACING, Direction.SOUTH).setModels(new ConfiguredModel(file, 0, 180, false)) - .partialState().with(BlockStateProperties.FACING, Direction.WEST).setModels(new ConfiguredModel(file, 0, 270, false)) - .partialState().with(BlockStateProperties.FACING, Direction.EAST).setModels(new ConfiguredModel(file, 0, 90, false)) - .partialState().with(BlockStateProperties.FACING, Direction.DOWN).setModels(new ConfiguredModel(file, 90, 0, false)) - .partialState().with(BlockStateProperties.FACING, Direction.UP).setModels(new ConfiguredModel(file, 270, 0, false)); - } + private void redStringBlock(Block b) { + ModelFile file = models().getExistingFile(prefix("block/" + b.getRegistryName().getPath())); + getVariantBuilder(b) + .partialState().with(BlockStateProperties.FACING, Direction.NORTH).setModels(new ConfiguredModel(file)) + .partialState().with(BlockStateProperties.FACING, Direction.SOUTH).setModels(new ConfiguredModel(file, 0, 180, false)) + .partialState().with(BlockStateProperties.FACING, Direction.WEST).setModels(new ConfiguredModel(file, 0, 270, false)) + .partialState().with(BlockStateProperties.FACING, Direction.EAST).setModels(new ConfiguredModel(file, 0, 90, false)) + .partialState().with(BlockStateProperties.FACING, Direction.DOWN).setModels(new ConfiguredModel(file, 90, 0, false)) + .partialState().with(BlockStateProperties.FACING, Direction.UP).setModels(new ConfiguredModel(file, 270, 0, false)); + } } diff --git a/src/main/java/vazkii/botania/data/DataGenerators.java b/src/main/java/vazkii/botania/data/DataGenerators.java index 8614eb33a..1199e5f5d 100644 --- a/src/main/java/vazkii/botania/data/DataGenerators.java +++ b/src/main/java/vazkii/botania/data/DataGenerators.java @@ -1,8 +1,17 @@ +/* + * This class is 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 + */ package vazkii.botania.data; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.GatherDataEvent; + import vazkii.botania.common.lib.LibMisc; @Mod.EventBusSubscriber(modid = LibMisc.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) diff --git a/src/main/java/vazkii/botania/data/FloatingFlowerModelBuilder.java b/src/main/java/vazkii/botania/data/FloatingFlowerModelBuilder.java index eaf55785a..00ebb7494 100644 --- a/src/main/java/vazkii/botania/data/FloatingFlowerModelBuilder.java +++ b/src/main/java/vazkii/botania/data/FloatingFlowerModelBuilder.java @@ -1,10 +1,20 @@ +/* + * This class is 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 + */ package vazkii.botania.data; import com.google.gson.JsonObject; + import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.generators.ExistingFileHelper; import net.minecraftforge.client.model.generators.ModelBuilder; import net.minecraftforge.client.model.generators.ModelFile; + import vazkii.botania.client.model.FloatingFlowerModel; public class FloatingFlowerModelBuilder extends ModelBuilder { diff --git a/src/main/java/vazkii/botania/data/FloatingFlowerModelProvider.java b/src/main/java/vazkii/botania/data/FloatingFlowerModelProvider.java index cb3438c89..05bbc87b4 100644 --- a/src/main/java/vazkii/botania/data/FloatingFlowerModelProvider.java +++ b/src/main/java/vazkii/botania/data/FloatingFlowerModelProvider.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.data; import net.minecraft.block.Block; @@ -6,6 +14,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.registry.Registry; import net.minecraftforge.client.model.generators.ExistingFileHelper; import net.minecraftforge.client.model.generators.ModelProvider; + import vazkii.botania.common.block.decor.BlockFloatingFlower; import vazkii.botania.common.lib.LibMisc; diff --git a/src/main/java/vazkii/botania/data/ItemModelProvider.java b/src/main/java/vazkii/botania/data/ItemModelProvider.java index 7007f3e1e..ab411e7f6 100644 --- a/src/main/java/vazkii/botania/data/ItemModelProvider.java +++ b/src/main/java/vazkii/botania/data/ItemModelProvider.java @@ -1,9 +1,18 @@ +/* + * This class is 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 + */ package vazkii.botania.data; import net.minecraft.data.DataGenerator; import net.minecraft.item.BlockItem; import net.minecraft.util.registry.Registry; import net.minecraftforge.client.model.generators.ExistingFileHelper; + import vazkii.botania.common.block.decor.BlockFloatingFlower; import vazkii.botania.common.lib.LibMisc; diff --git a/src/main/java/vazkii/botania/data/ItemTagProvider.java b/src/main/java/vazkii/botania/data/ItemTagProvider.java index 10a999be7..583ad1ea3 100644 --- a/src/main/java/vazkii/botania/data/ItemTagProvider.java +++ b/src/main/java/vazkii/botania/data/ItemTagProvider.java @@ -1,3 +1,11 @@ +/* + * This class is 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 + */ package vazkii.botania.data; import net.minecraft.data.DataGenerator; @@ -7,39 +15,41 @@ import net.minecraft.item.Item; import net.minecraft.tags.BlockTags; import net.minecraft.tags.ItemTags; import net.minecraft.tags.Tag; + import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.ModTags; import javax.annotation.Nonnull; + import java.util.Arrays; import java.util.Comparator; public class ItemTagProvider extends ItemTagsProvider { - public ItemTagProvider(DataGenerator generatorIn) { - super(generatorIn); - } + public ItemTagProvider(DataGenerator generatorIn) { + super(generatorIn); + } - @Override - protected void registerTags() { - this.copy(BlockTags.RAILS, ItemTags.RAILS); - this.copy(BlockTags.SLABS, ItemTags.SLABS); - this.copy(BlockTags.STAIRS, ItemTags.STAIRS); - this.copy(BlockTags.WALLS, ItemTags.WALLS); - this.copy(BlockTags.FENCES, ItemTags.FENCES); + @Override + protected void registerTags() { + this.copy(BlockTags.RAILS, ItemTags.RAILS); + this.copy(BlockTags.SLABS, ItemTags.SLABS); + this.copy(BlockTags.STAIRS, ItemTags.STAIRS); + this.copy(BlockTags.WALLS, ItemTags.WALLS); + this.copy(BlockTags.FENCES, ItemTags.FENCES); - this.copy(ModTags.Blocks.MUNDANE_FLOATING_FLOWERS, ModTags.Items.MUNDANE_FLOATING_FLOWERS); - this.copy(ModTags.Blocks.SPECIAL_FLOATING_FLOWERS, ModTags.Items.SPECIAL_FLOATING_FLOWERS); - this.copy(ModTags.Blocks.FLOATING_FLOWERS, ModTags.Items.FLOATING_FLOWERS); - this.copy(ModTags.Blocks.DOUBLE_MYSTICAL_FLOWERS, ModTags.Items.DOUBLE_MYSTICAL_FLOWERS); - this.copy(ModTags.Blocks.MYSTICAL_FLOWERS, ModTags.Items.MYSTICAL_FLOWERS); + this.copy(ModTags.Blocks.MUNDANE_FLOATING_FLOWERS, ModTags.Items.MUNDANE_FLOATING_FLOWERS); + this.copy(ModTags.Blocks.SPECIAL_FLOATING_FLOWERS, ModTags.Items.SPECIAL_FLOATING_FLOWERS); + this.copy(ModTags.Blocks.FLOATING_FLOWERS, ModTags.Items.FLOATING_FLOWERS); + this.copy(ModTags.Blocks.DOUBLE_MYSTICAL_FLOWERS, ModTags.Items.DOUBLE_MYSTICAL_FLOWERS); + this.copy(ModTags.Blocks.MYSTICAL_FLOWERS, ModTags.Items.MYSTICAL_FLOWERS); - Tag.Builder builder = getBuilder(ModTags.Items.DYES); - Arrays.stream(DyeColor.values()).map(ModItems::getDye).sorted(Comparator.comparing(Item::getRegistryName)).forEach(builder::add); - } + Tag.Builder builder = getBuilder(ModTags.Items.DYES); + Arrays.stream(DyeColor.values()).map(ModItems::getDye).sorted(Comparator.comparing(Item::getRegistryName)).forEach(builder::add); + } - @Nonnull - @Override - public String getName() { - return "Botania item tags"; - } + @Nonnull + @Override + public String getName() { + return "Botania item tags"; + } } diff --git a/src/main/java/vazkii/botania/data/RecipeProvider.java b/src/main/java/vazkii/botania/data/RecipeProvider.java index b7606a143..64fd14573 100644 --- a/src/main/java/vazkii/botania/data/RecipeProvider.java +++ b/src/main/java/vazkii/botania/data/RecipeProvider.java @@ -1,16 +1,15 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [2020-02-11, 21:45 (UTC+2)] */ package vazkii.botania.data; import com.google.gson.JsonArray; + import net.minecraft.advancements.Advancement; import net.minecraft.advancements.AdvancementRewards; import net.minecraft.advancements.ICriterionInstance; @@ -42,6 +41,7 @@ import net.minecraftforge.common.crafting.NBTIngredient; import net.minecraftforge.common.crafting.conditions.TagEmptyCondition; import net.minecraftforge.common.crafting.conditions.TrueCondition; import net.minecraftforge.registries.ForgeRegistries; + import vazkii.botania.api.state.enums.CratePattern; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.ModFluffBlocks; @@ -55,6 +55,7 @@ import vazkii.botania.common.lib.ModTags; import vazkii.botania.common.lib.ResourceLocationHelper; import javax.annotation.Nullable; + import java.util.Arrays; import java.util.EnumMap; import java.util.List; @@ -376,10 +377,10 @@ public class RecipeProvider extends net.minecraft.data.RecipeProvider { .addCriterion("has_item", hasItem(Tags.Items.STORAGE_BLOCKS_REDSTONE)) .addCriterion("has_alt_item", hasItem(ModTags.Items.INGOTS_MANASTEEL)) .build(WrapperResult.transformJson(consumer, json -> { - JsonArray array = new JsonArray(); - array.add(FluxfieldCondition.SERIALIZER.getJson(new FluxfieldCondition(true))); - json.add("conditions", array); - } + JsonArray array = new JsonArray(); + array.add(FluxfieldCondition.SERIALIZER.getJson(new FluxfieldCondition(true))); + json.add("conditions", array); + } )); ShapedRecipeBuilder.shapedRecipe(ModBlocks.brewery) .key('A', ModTags.Items.RUNES_MANA) @@ -993,13 +994,12 @@ public class RecipeProvider extends net.minecraft.data.RecipeProvider { .build(consumer); ResourceLocation cacophoniumId = ModItems.cacophonium.getRegistryName(); - Supplier cacophoniumBase = () -> - ShapedRecipeBuilder.shapedRecipe(ModItems.cacophonium) - .key('N', Items.NOTE_BLOCK) - .patternLine(" G ") - .patternLine("GNG") - .patternLine("GG ") - .addCriterion("has_item", hasItem(Items.NOTE_BLOCK)); + Supplier cacophoniumBase = () -> ShapedRecipeBuilder.shapedRecipe(ModItems.cacophonium) + .key('N', Items.NOTE_BLOCK) + .patternLine(" G ") + .patternLine("GNG") + .patternLine("GG ") + .addCriterion("has_item", hasItem(Items.NOTE_BLOCK)); ConditionalRecipe.builder() .addCondition(new TagEmptyCondition("forge", "ingots/brass")) .addRecipe(cacophoniumBase.get().key('G', Tags.Items.INGOTS_GOLD)::build) @@ -1010,15 +1010,15 @@ public class RecipeProvider extends net.minecraft.data.RecipeProvider { new Ingredient.TagList(new ItemTags.Wrapper(new ResourceLocation("forge", "ingots/brass")))) ))::build ).setAdvancement(prefix("recipes/botania/cacophonium"), - ConditionalAdvancement.builder() - .addCondition(TrueCondition.INSTANCE) - .addAdvancement(Advancement.Builder.builder() - .withParentId(new ResourceLocation("recipes/root")) - .withRewards(AdvancementRewards.Builder.recipe(cacophoniumId)) - .withCriterion("has_item", hasItem(Items.NOTE_BLOCK)) - .withCriterion("has_the_recipe", new RecipeUnlockedTrigger.Instance(cacophoniumId)) - .withRequirementsStrategy(IRequirementsStrategy.OR)) - ).build(consumer, cacophoniumId); + ConditionalAdvancement.builder() + .addCondition(TrueCondition.INSTANCE) + .addAdvancement(Advancement.Builder.builder() + .withParentId(new ResourceLocation("recipes/root")) + .withRewards(AdvancementRewards.Builder.recipe(cacophoniumId)) + .withCriterion("has_item", hasItem(Items.NOTE_BLOCK)) + .withCriterion("has_the_recipe", new RecipeUnlockedTrigger.Instance(cacophoniumId)) + .withRequirementsStrategy(IRequirementsStrategy.OR)) + ).build(consumer, cacophoniumId); ShapedRecipeBuilder.shapedRecipe(ModItems.grassHorn) .key('S', ModItems.grassSeeds) @@ -1075,7 +1075,6 @@ public class RecipeProvider extends net.minecraft.data.RecipeProvider { .addCriterion("has_item", hasItem(ModTags.Items.RUNES_AIR)) .build(consumer); - registerSimpleArmorSet(consumer, Ingredient.fromTag(ModTags.Items.INGOTS_MANASTEEL), "manasteel", hasItem(ModTags.Items.INGOTS_MANASTEEL)); registerSimpleArmorSet(consumer, Ingredient.fromTag(ModTags.Items.INGOTS_ELEMENTIUM), "elementium", hasItem(ModTags.Items.INGOTS_ELEMENTIUM)); registerSimpleArmorSet(consumer, Ingredient.fromItems(ModItems.manaweaveCloth), "manaweave", hasItem(ModItems.manaweaveCloth)); @@ -1197,7 +1196,9 @@ public class RecipeProvider extends net.minecraft.data.RecipeProvider { .build(consumer); for (CratePattern pattern : CratePattern.values()) { - if (pattern == CratePattern.NONE) continue; + if (pattern == CratePattern.NONE) { + continue; + } Item item = ForgeRegistries.ITEMS.getValue(prefix(LibItemNames.CRAFT_PATTERN_PREFIX + pattern.getName().split("_", 2)[1])); String s = pattern.openSlots.stream().map(bool -> bool ? "R" : "P").collect(Collectors.joining()); ShapedRecipeBuilder.shapedRecipe(item) @@ -1378,12 +1379,10 @@ public class RecipeProvider extends net.minecraft.data.RecipeProvider { .addIngredient(nbtIngredient(stack)) .setGroup("botania:laputa_shard_upgrade") .addCriterion("has_item", hasItem(ModItems.laputaShard)) - .build(WrapperResult.transformJson(consumer, json -> - json.getAsJsonObject("result").addProperty("nbt", "{level:" + outputLevel + "}") + .build(WrapperResult.transformJson(consumer, json -> json.getAsJsonObject("result").addProperty("nbt", "{level:" + outputLevel + "}") ), "botania:laputa_shard_" + i); } - ShapedRecipeBuilder.shapedRecipe(ModItems.craftingHalo) .key('P', ModItems.manaPearl) .key('C', Items.CRAFTING_TABLE) @@ -1622,10 +1621,10 @@ public class RecipeProvider extends net.minecraft.data.RecipeProvider { .patternLine("FEF") .addCriterion("has_item", hasItem(ModItems.lifeEssence)) .build(consumer, "botania:flighttiara_0"); - + // Normal quartz and not Tags.Items.QUARTZ because the recipes conflict. - Item[] items = {Items.QUARTZ, ModItems.darkQuartz, ModItems.manaQuartz, ModItems.blazeQuartz, - ModItems.lavenderQuartz, ModItems.redQuartz, ModItems.elfQuartz, ModItems.sunnyQuartz}; + Item[] items = { Items.QUARTZ, ModItems.darkQuartz, ModItems.manaQuartz, ModItems.blazeQuartz, + ModItems.lavenderQuartz, ModItems.redQuartz, ModItems.elfQuartz, ModItems.sunnyQuartz }; for (int i = 0; i < items.length; i++) { int tiaraType = i + 1; ShapelessRecipeBuilder.shapelessRecipe(ModItems.flightTiara) @@ -1633,8 +1632,7 @@ public class RecipeProvider extends net.minecraft.data.RecipeProvider { .addIngredient(items[i]) .setGroup("botania:flight_tiara_wings") .addCriterion("has_item", hasItem(ModItems.flightTiara)) - .build(WrapperResult.transformJson(consumer, json -> - json.getAsJsonObject("result").addProperty("nbt", "{variant:" + tiaraType + "}") + .build(WrapperResult.transformJson(consumer, json -> json.getAsJsonObject("result").addProperty("nbt", "{variant:" + tiaraType + "}") ), "botania:flighttiara_" + tiaraType); } ShapedRecipeBuilder.shapedRecipe(ModItems.pixieRing) @@ -2054,7 +2052,7 @@ public class RecipeProvider extends net.minecraft.data.RecipeProvider { } private void registerFloatingFlowers(Consumer consumer) { - for (Block block : new Block[]{ + for (Block block : new Block[] { ModSubtiles.pureDaisy, ModSubtiles.manastar, ModSubtiles.hydroangeas, ModSubtiles.endoflame, ModSubtiles.thermalily, ModSubtiles.rosaArcana, ModSubtiles.munchdew, ModSubtiles.entropinnyum, ModSubtiles.kekimurus, ModSubtiles.gourmaryllis, ModSubtiles.narslimmus, ModSubtiles.spectrolus, @@ -2067,7 +2065,7 @@ public class RecipeProvider extends net.minecraft.data.RecipeProvider { ModSubtiles.clayconiaChibi, ModSubtiles.loonium, ModSubtiles.daffomill, ModSubtiles.vinculotus, ModSubtiles.spectranthemum, ModSubtiles.medumone, ModSubtiles.marimorphosis, ModSubtiles.marimorphosisChibi, ModSubtiles.bubbell, ModSubtiles.bubbellChibi, ModSubtiles.solegnolia, ModSubtiles.solegnoliaChibi, - ModSubtiles.orechidIgnem}) { + ModSubtiles.orechidIgnem }) { createFloatingFlowerRecipe(consumer, block); } } @@ -2086,7 +2084,6 @@ public class RecipeProvider extends net.minecraft.data.RecipeProvider { compression(ModBlocks.dragonstoneBlock, ModTags.Items.GEMS_DRAGONSTONE).build(consumer); compression(ModBlocks.blazeBlock, Tags.Items.RODS_BLAZE).build(consumer); - deconstructPetalBlock(consumer, ModItems.whitePetal, ModBlocks.petalBlockWhite); deconstructPetalBlock(consumer, ModItems.orangePetal, ModBlocks.petalBlockOrange); deconstructPetalBlock(consumer, ModItems.magentaPetal, ModBlocks.petalBlockMagenta); @@ -2255,7 +2252,7 @@ public class RecipeProvider extends net.minecraft.data.RecipeProvider { registerForMetamorphic(consumer, variant); } - Item[] pavementIngredients = {Items.AIR, Items.COAL, Items.LAPIS_LAZULI, Items.REDSTONE, Items.WHEAT, Items.SLIME_BALL}; + Item[] pavementIngredients = { Items.AIR, Items.COAL, Items.LAPIS_LAZULI, Items.REDSTONE, Items.WHEAT, Items.SLIME_BALL }; for (int i = 0; i < pavementIngredients.length; i++) { registerForPavement(consumer, LibBlockNames.PAVEMENT_VARIANTS[i], pavementIngredients[i]); } @@ -2276,7 +2273,9 @@ public class RecipeProvider extends net.minecraft.data.RecipeProvider { for (int i = 0; i < allAzulejos.size(); i++) { int resultIndex = i + 1 == allAzulejos.size() ? 0 : i + 1; String recipeName = "azulejo_" + resultIndex; - if (resultIndex == 0) recipeName += "_alt"; + if (resultIndex == 0) { + recipeName += "_alt"; + } ShapelessRecipeBuilder.shapelessRecipe(allAzulejos.get(resultIndex)) .addIngredient(allAzulejos.get(i)) .addCriterion("has_azulejo", hasItem(ModBlocks.azulejo0)) @@ -2320,7 +2319,7 @@ public class RecipeProvider extends net.minecraft.data.RecipeProvider { } private void registerSimpleArmorSet(Consumer consumer, Ingredient item, String variant, - ICriterionInstance criterion) { + ICriterionInstance criterion) { Item helmet = ForgeRegistries.ITEMS.getValue(prefix(variant + "_helmet")); Item chestplate = ForgeRegistries.ITEMS.getValue(prefix(variant + "_chestplate")); Item leggings = ForgeRegistries.ITEMS.getValue(prefix(variant + "_leggings")); @@ -2354,8 +2353,8 @@ public class RecipeProvider extends net.minecraft.data.RecipeProvider { } private void registerToolSetRecipes(Consumer consumer, Ingredient item, Ingredient stick, - ICriterionInstance criterion, IItemProvider sword, IItemProvider pickaxe, - IItemProvider axe, IItemProvider shovel, IItemProvider shears) { + ICriterionInstance criterion, IItemProvider sword, IItemProvider pickaxe, + IItemProvider axe, IItemProvider shovel, IItemProvider shears) { ShapedRecipeBuilder.shapedRecipe(pickaxe) .key('S', item) .key('T', stick) @@ -2398,7 +2397,7 @@ public class RecipeProvider extends net.minecraft.data.RecipeProvider { } private void registerTerrasteelUpgradeRecipe(Consumer consumer, IItemProvider output, - IItemProvider upgradedInput, Tag runeInput) { + IItemProvider upgradedInput, Tag runeInput) { ShapedRecipeBuilder.shapedRecipe(output) .key('T', ModItems.livingwoodTwig) .key('S', ModTags.Items.INGOTS_TERRASTEEL) @@ -2514,8 +2513,9 @@ public class RecipeProvider extends net.minecraft.data.RecipeProvider { .addIngredient(Items.GRAVEL) .setGroup("botania:pavement") .addCriterion("has_item", hasItem(ModTags.Items.LIVINGROCK)); - if (mainInput != Items.AIR) + if (mainInput != Items.AIR) { builder.addIngredient(mainInput); + } builder.build(consumer); slabShape(slab, base).setGroup("botania:pavement_slab").build(consumer); @@ -2663,7 +2663,7 @@ public class RecipeProvider extends net.minecraft.data.RecipeProvider { private static NBTIngredient nbtIngredient(ItemStack stack) { return new NBTIngredient(stack) {}; } - + @Override public String getName() { return "Botania crafting recipes"; diff --git a/src/main/java/vazkii/botania/data/SmeltingProvider.java b/src/main/java/vazkii/botania/data/SmeltingProvider.java index 59e0dee3c..feb3642fa 100644 --- a/src/main/java/vazkii/botania/data/SmeltingProvider.java +++ b/src/main/java/vazkii/botania/data/SmeltingProvider.java @@ -1,12 +1,10 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [2020-02-12, 00:02 (UTC+2)] */ package vazkii.botania.data; @@ -15,6 +13,7 @@ import net.minecraft.data.DataGenerator; import net.minecraft.data.IFinishedRecipe; import net.minecraft.data.RecipeProvider; import net.minecraft.item.crafting.Ingredient; + import vazkii.botania.common.block.ModFluffBlocks; import java.util.function.Consumer; diff --git a/src/main/java/vazkii/botania/data/StonecuttingProvider.java b/src/main/java/vazkii/botania/data/StonecuttingProvider.java index a35616225..0b55cd980 100644 --- a/src/main/java/vazkii/botania/data/StonecuttingProvider.java +++ b/src/main/java/vazkii/botania/data/StonecuttingProvider.java @@ -1,6 +1,15 @@ +/* + * This class is 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 + */ package vazkii.botania.data; import com.google.gson.JsonObject; + import net.minecraft.block.Block; import net.minecraft.data.DataGenerator; import net.minecraft.data.IFinishedRecipe; @@ -12,6 +21,7 @@ import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.IItemProvider; import net.minecraft.util.ResourceLocation; import net.minecraftforge.registries.ForgeRegistries; + import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.ModFluffBlocks; import vazkii.botania.common.lib.LibBlockNames; @@ -19,6 +29,7 @@ import vazkii.botania.common.lib.ResourceLocationHelper; import javax.annotation.Nonnull; import javax.annotation.Nullable; + import java.util.List; import java.util.function.Consumer; import java.util.stream.Collectors; @@ -27,133 +38,133 @@ import java.util.stream.IntStream; import static vazkii.botania.common.lib.ResourceLocationHelper.prefix; public class StonecuttingProvider extends RecipeProvider { - public StonecuttingProvider(DataGenerator generator) { - super(generator); - } + public StonecuttingProvider(DataGenerator generator) { + super(generator); + } - @Override - protected void registerRecipes(Consumer consumer) { - for(String variant : LibBlockNames.METAMORPHIC_VARIANTS) { - registerForMetamorphic(variant, consumer); - } + @Override + protected void registerRecipes(Consumer consumer) { + for (String variant : LibBlockNames.METAMORPHIC_VARIANTS) { + registerForMetamorphic(variant, consumer); + } - for(String color : LibBlockNames.PAVEMENT_VARIANTS) { - registerForPavement(color, consumer); - } + for (String color : LibBlockNames.PAVEMENT_VARIANTS) { + registerForPavement(color, consumer); + } - for(String variant : LibBlockNames.QUARTZ_VARIANTS) { - registerForQuartz(variant, consumer); - } + for (String variant : LibBlockNames.QUARTZ_VARIANTS) { + registerForQuartz(variant, consumer); + } - consumer.accept(stonecutting(ModBlocks.shimmerrock, ModFluffBlocks.shimmerrockSlab, 2)); - consumer.accept(stonecutting(ModBlocks.shimmerrock, ModFluffBlocks.shimmerrockStairs)); - consumer.accept(stonecutting(ModBlocks.livingrock, ModFluffBlocks.livingrockSlab, 2)); - consumer.accept(stonecutting(ModBlocks.livingrock, ModFluffBlocks.livingrockStairs)); - consumer.accept(stonecutting(ModBlocks.livingrock, ModFluffBlocks.livingrockWall)); - consumer.accept(stonecutting(ModBlocks.livingrock, ModBlocks.livingrockBrick)); - consumer.accept(stonecutting(ModBlocks.livingrock, ModFluffBlocks.livingrockBrickSlab, 2)); - consumer.accept(stonecutting(ModBlocks.livingrock, ModFluffBlocks.livingrockBrickStairs)); - consumer.accept(stonecutting(ModBlocks.livingrock, ModBlocks.livingrockBrickChiseled)); - consumer.accept(stonecutting(ModBlocks.livingrockBrick, ModFluffBlocks.livingrockBrickSlab, 2)); - consumer.accept(stonecutting(ModBlocks.livingrockBrick, ModFluffBlocks.livingrockBrickStairs)); - consumer.accept(stonecutting(ModBlocks.livingrockBrick, ModBlocks.livingrockBrickChiseled)); - - List allAzulejos = IntStream.range(0, 16).mapToObj(i -> "azulejo_" + i) - .map(ResourceLocationHelper::prefix) - .map(ForgeRegistries.ITEMS::getValue).collect(Collectors.toList()); + consumer.accept(stonecutting(ModBlocks.shimmerrock, ModFluffBlocks.shimmerrockSlab, 2)); + consumer.accept(stonecutting(ModBlocks.shimmerrock, ModFluffBlocks.shimmerrockStairs)); + consumer.accept(stonecutting(ModBlocks.livingrock, ModFluffBlocks.livingrockSlab, 2)); + consumer.accept(stonecutting(ModBlocks.livingrock, ModFluffBlocks.livingrockStairs)); + consumer.accept(stonecutting(ModBlocks.livingrock, ModFluffBlocks.livingrockWall)); + consumer.accept(stonecutting(ModBlocks.livingrock, ModBlocks.livingrockBrick)); + consumer.accept(stonecutting(ModBlocks.livingrock, ModFluffBlocks.livingrockBrickSlab, 2)); + consumer.accept(stonecutting(ModBlocks.livingrock, ModFluffBlocks.livingrockBrickStairs)); + consumer.accept(stonecutting(ModBlocks.livingrock, ModBlocks.livingrockBrickChiseled)); + consumer.accept(stonecutting(ModBlocks.livingrockBrick, ModFluffBlocks.livingrockBrickSlab, 2)); + consumer.accept(stonecutting(ModBlocks.livingrockBrick, ModFluffBlocks.livingrockBrickStairs)); + consumer.accept(stonecutting(ModBlocks.livingrockBrick, ModBlocks.livingrockBrickChiseled)); + + List allAzulejos = IntStream.range(0, 16).mapToObj(i -> "azulejo_" + i) + .map(ResourceLocationHelper::prefix) + .map(ForgeRegistries.ITEMS::getValue).collect(Collectors.toList()); for (Item azulejo : allAzulejos) { consumer.accept(azulejoStonecutting(allAzulejos, azulejo)); } - } + } - private static void registerForQuartz(String variant, Consumer consumer) { - Block base = ForgeRegistries.BLOCKS.getValue(prefix(variant)); - Block slab = ForgeRegistries.BLOCKS.getValue(prefix(variant + LibBlockNames.SLAB_SUFFIX)); - Block stairs = ForgeRegistries.BLOCKS.getValue(prefix(variant + LibBlockNames.STAIR_SUFFIX)); - Block chiseled = ForgeRegistries.BLOCKS.getValue(prefix("chiseled_" + variant)); - Block pillar = ForgeRegistries.BLOCKS.getValue(prefix(variant + "_pillar")); - consumer.accept(stonecutting(base, slab, 2)); - consumer.accept(stonecutting(base, stairs)); - consumer.accept(stonecutting(base, chiseled)); - consumer.accept(stonecutting(base, pillar)); - } + private static void registerForQuartz(String variant, Consumer consumer) { + Block base = ForgeRegistries.BLOCKS.getValue(prefix(variant)); + Block slab = ForgeRegistries.BLOCKS.getValue(prefix(variant + LibBlockNames.SLAB_SUFFIX)); + Block stairs = ForgeRegistries.BLOCKS.getValue(prefix(variant + LibBlockNames.STAIR_SUFFIX)); + Block chiseled = ForgeRegistries.BLOCKS.getValue(prefix("chiseled_" + variant)); + Block pillar = ForgeRegistries.BLOCKS.getValue(prefix(variant + "_pillar")); + consumer.accept(stonecutting(base, slab, 2)); + consumer.accept(stonecutting(base, stairs)); + consumer.accept(stonecutting(base, chiseled)); + consumer.accept(stonecutting(base, pillar)); + } - private static void registerForPavement(String color, Consumer consumer) { - Block base = ForgeRegistries.BLOCKS.getValue(prefix(color + LibBlockNames.PAVEMENT_SUFFIX)); - Block slab = ForgeRegistries.BLOCKS.getValue(prefix(color + LibBlockNames.PAVEMENT_SUFFIX + LibBlockNames.SLAB_SUFFIX)); - Block stair = ForgeRegistries.BLOCKS.getValue(prefix(color + LibBlockNames.PAVEMENT_SUFFIX + LibBlockNames.STAIR_SUFFIX)); - consumer.accept(stonecutting(base, slab, 2)); - consumer.accept(stonecutting(base, stair)); - } + private static void registerForPavement(String color, Consumer consumer) { + Block base = ForgeRegistries.BLOCKS.getValue(prefix(color + LibBlockNames.PAVEMENT_SUFFIX)); + Block slab = ForgeRegistries.BLOCKS.getValue(prefix(color + LibBlockNames.PAVEMENT_SUFFIX + LibBlockNames.SLAB_SUFFIX)); + Block stair = ForgeRegistries.BLOCKS.getValue(prefix(color + LibBlockNames.PAVEMENT_SUFFIX + LibBlockNames.STAIR_SUFFIX)); + consumer.accept(stonecutting(base, slab, 2)); + consumer.accept(stonecutting(base, stair)); + } - private static void registerForMetamorphic(String variant, Consumer consumer) { - Block base = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_stone")); - Block slab = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_stone" + LibBlockNames.SLAB_SUFFIX)); - Block stair = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_stone" + LibBlockNames.STAIR_SUFFIX)); - Block brick = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_bricks")); - Block brickSlab = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_bricks" + LibBlockNames.SLAB_SUFFIX)); - Block brickStair = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_bricks" + LibBlockNames.STAIR_SUFFIX)); - Block chiseledBrick = ForgeRegistries.BLOCKS.getValue(prefix("chiseled_" + LibBlockNames.METAMORPHIC_PREFIX + variant + "_bricks")); - Block cobble = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_cobblestone")); - Block cobbleSlab = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_cobblestone" + LibBlockNames.SLAB_SUFFIX)); - Block cobbleStair = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_cobblestone" + LibBlockNames.STAIR_SUFFIX)); - Block cobbleWall = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_cobblestone" + LibBlockNames.WALL_SUFFIX)); + private static void registerForMetamorphic(String variant, Consumer consumer) { + Block base = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_stone")); + Block slab = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_stone" + LibBlockNames.SLAB_SUFFIX)); + Block stair = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_stone" + LibBlockNames.STAIR_SUFFIX)); + Block brick = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_bricks")); + Block brickSlab = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_bricks" + LibBlockNames.SLAB_SUFFIX)); + Block brickStair = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_bricks" + LibBlockNames.STAIR_SUFFIX)); + Block chiseledBrick = ForgeRegistries.BLOCKS.getValue(prefix("chiseled_" + LibBlockNames.METAMORPHIC_PREFIX + variant + "_bricks")); + Block cobble = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_cobblestone")); + Block cobbleSlab = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_cobblestone" + LibBlockNames.SLAB_SUFFIX)); + Block cobbleStair = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_cobblestone" + LibBlockNames.STAIR_SUFFIX)); + Block cobbleWall = ForgeRegistries.BLOCKS.getValue(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_cobblestone" + LibBlockNames.WALL_SUFFIX)); - consumer.accept(stonecutting(base, slab, 2)); - consumer.accept(stonecutting(base, stair)); - consumer.accept(stonecutting(base, brick)); - consumer.accept(stonecutting(base, brickSlab, 2)); - consumer.accept(stonecutting(base, brickStair)); - consumer.accept(stonecutting(base, chiseledBrick)); + consumer.accept(stonecutting(base, slab, 2)); + consumer.accept(stonecutting(base, stair)); + consumer.accept(stonecutting(base, brick)); + consumer.accept(stonecutting(base, brickSlab, 2)); + consumer.accept(stonecutting(base, brickStair)); + consumer.accept(stonecutting(base, chiseledBrick)); - consumer.accept(stonecutting(brick, brickSlab, 2)); - consumer.accept(stonecutting(brick, brickStair)); - consumer.accept(stonecutting(brick, chiseledBrick)); + consumer.accept(stonecutting(brick, brickSlab, 2)); + consumer.accept(stonecutting(brick, brickStair)); + consumer.accept(stonecutting(brick, chiseledBrick)); - consumer.accept(stonecutting(cobble, cobbleSlab, 2)); - consumer.accept(stonecutting(cobble, cobbleStair)); - consumer.accept(stonecutting(cobble, cobbleWall)); - } + consumer.accept(stonecutting(cobble, cobbleSlab, 2)); + consumer.accept(stonecutting(cobble, cobbleStair)); + consumer.accept(stonecutting(cobble, cobbleWall)); + } - @Nonnull - @Override - public String getName() { - return "Botania stonecutting recipes"; - } + @Nonnull + @Override + public String getName() { + return "Botania stonecutting recipes"; + } - private static ResourceLocation idFor(IItemProvider a, IItemProvider b) { - return prefix("stonecutting/" + a.asItem().getRegistryName().getPath() + "_to_" + b.asItem().getRegistryName().getPath()); - } + private static ResourceLocation idFor(IItemProvider a, IItemProvider b) { + return prefix("stonecutting/" + a.asItem().getRegistryName().getPath() + "_to_" + b.asItem().getRegistryName().getPath()); + } - private static IFinishedRecipe stonecutting(IItemProvider input, IItemProvider output) { - return stonecutting(input, output, 1); - } + private static IFinishedRecipe stonecutting(IItemProvider input, IItemProvider output) { + return stonecutting(input, output, 1); + } - private static IFinishedRecipe stonecutting(IItemProvider input, IItemProvider output, int count) { - return new Result(idFor(input, output), IRecipeSerializer.STONECUTTING, Ingredient.fromItems(input), output.asItem(), count); - } + private static IFinishedRecipe stonecutting(IItemProvider input, IItemProvider output, int count) { + return new Result(idFor(input, output), IRecipeSerializer.STONECUTTING, Ingredient.fromItems(input), output.asItem(), count); + } - private static IFinishedRecipe azulejoStonecutting(List inputs, IItemProvider output) { + private static IFinishedRecipe azulejoStonecutting(List inputs, IItemProvider output) { Ingredient input = Ingredient.fromItems(inputs.stream().filter(obj -> output != obj).toArray(IItemProvider[]::new)); return new Result(prefix("stonecutting/" + output.asItem().getRegistryName().getPath()), IRecipeSerializer.STONECUTTING, input, output.asItem(), 1); - } + } - // Wrapper without advancements - public static class Result extends SingleItemRecipeBuilder.Result { - public Result(ResourceLocation id, IRecipeSerializer serializer, Ingredient input, Item result, int count) { - super(id, serializer, "", input, result, count, null, null); - } + // Wrapper without advancements + public static class Result extends SingleItemRecipeBuilder.Result { + public Result(ResourceLocation id, IRecipeSerializer serializer, Ingredient input, Item result, int count) { + super(id, serializer, "", input, result, count, null, null); + } - @Nullable - @Override - public JsonObject getAdvancementJson() { - return null; - } + @Nullable + @Override + public JsonObject getAdvancementJson() { + return null; + } - @Nullable - @Override - public ResourceLocation getAdvancementID() { - return null; - } - } + @Nullable + @Override + public ResourceLocation getAdvancementID() { + return null; + } + } } diff --git a/src/main/java/vazkii/botania/data/WrapperResult.java b/src/main/java/vazkii/botania/data/WrapperResult.java index 3093f13bc..140b6fc02 100644 --- a/src/main/java/vazkii/botania/data/WrapperResult.java +++ b/src/main/java/vazkii/botania/data/WrapperResult.java @@ -1,29 +1,27 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: +/* + * This class is 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 @ [2020-02-12, 19:29 (UTC+2)] */ package vazkii.botania.data; import com.google.gson.JsonObject; + import net.minecraft.data.IFinishedRecipe; import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.util.ResourceLocation; import javax.annotation.Nullable; + import java.util.function.Consumer; public class WrapperResult implements IFinishedRecipe { private final IFinishedRecipe delegate; - @Nullable - private final IRecipeSerializer type; - @Nullable - private final Consumer transform; + @Nullable private final IRecipeSerializer type; + @Nullable private final Consumer transform; /** * Wraps recipe consumer with one that swaps the recipe type to a different one. @@ -38,7 +36,7 @@ public class WrapperResult implements IFinishedRecipe { public static Consumer transformJson(Consumer parent, Consumer transform) { return recipe -> parent.accept(new WrapperResult(recipe, null, transform)); } - + private WrapperResult(IFinishedRecipe delegate, @Nullable IRecipeSerializer type, @Nullable Consumer transform) { this.delegate = delegate; this.type = type; @@ -48,14 +46,16 @@ public class WrapperResult implements IFinishedRecipe { @Override public void serialize(JsonObject json) { delegate.serialize(json); - if(transform != null) + if (transform != null) { transform.accept(json); + } } @Override public JsonObject getRecipeJson() { - if(type == null) + if (type == null) { return IFinishedRecipe.super.getRecipeJson(); + } JsonObject jsonobject = new JsonObject(); jsonobject.addProperty("type", this.type.getRegistryName().toString()); this.serialize(jsonobject);