Compare commits

...

8 commits

Author SHA1 Message Date
Flanks255
a6b359e1a7 Merge remote-tracking branch 'origin/1.16' into 1.16 2021-11-13 13:30:11 -06:00
Flanks255
97e6b9c0db Datagenned paxels / equipment.
added Netherite paxel.
2021-11-13 13:29:59 -06:00
Michael Hillcox
d922cbdc9e feat: hmm, more porting 2021-11-13 19:09:55 +00:00
Michael Hillcox
05d64c1539 Merge remote-tracking branch 'origin/1.16' into 1.16 2021-11-13 18:31:28 +00:00
Michael Hillcox
f19fa61229 fix: finished util classes and removed booklet 2021-11-13 18:30:58 +00:00
Flanks255
7089cda9af More cleanup.... 2021-11-13 11:16:25 -06:00
Flanks255
9b93760445 More cleanup... 2021-11-13 11:02:42 -06:00
Flanks255
a0b8a83194 Some more recipe work, crushing recipe might be done? 2021-11-13 10:30:53 -06:00
86 changed files with 4570 additions and 4481 deletions

View file

@ -134,7 +134,7 @@ public final class ActuallyAdditionsAPI {
* @param outputTwoChance The chance of the second output (0 won't occur at all, 100 will all the time)
*/
public static void addCrusherRecipe(ItemStack input, ItemStack outputOne, ItemStack outputTwo, int outputTwoChance) {
CRUSHER_RECIPES.add(new CrushingRecipe(Ingredient.of(input), outputOne, outputTwo.isEmpty()
CRUSHER_RECIPES.add(new CrushingRecipe(Ingredient.of(input), outputOne, 1.0f, outputTwo.isEmpty()
? ItemStack.EMPTY
: outputTwo, outputTwoChance));
}
@ -148,7 +148,7 @@ public final class ActuallyAdditionsAPI {
* @param outputTwoChance The chance of the second output (0 won't occur at all, 100 will all the time)
*/
public static void addCrusherRecipe(Ingredient input, ItemStack outputOne, ItemStack outputTwo, int outputTwoChance) {
CRUSHER_RECIPES.add(new CrushingRecipe(input, outputOne, outputTwo.isEmpty()
CRUSHER_RECIPES.add(new CrushingRecipe(input, outputOne, 1.0f, outputTwo.isEmpty()
? ItemStack.EMPTY
: outputTwo, outputTwoChance));
}

View file

@ -168,7 +168,7 @@ public class BlockRecipeGenerator extends RecipeProvider {
.save(consumer);
// Item Interface
Recipe.shaped(ActuallyBlocks.ITEM_VIEWER.getItem())
Recipe.shaped(ActuallyBlocks.ITEM_INTERFACE.getItem())
.pattern("OBO", "RCR", "OBO")
.define('B', Tags.Items.DUSTS_REDSTONE)
.define('O', ActuallyItems.COIL.get())
@ -177,7 +177,7 @@ public class BlockRecipeGenerator extends RecipeProvider {
.save(consumer);
// Hopping Item Interface
Recipe.shapeless(ActuallyBlocks.ITEM_VIEWER_HOPPING.get()).ingredients(ActuallyBlocks.ITEM_VIEWER.get()).save(consumer);
Recipe.shapeless(ActuallyBlocks.ITEM_INTERFACE_HOPPING.get()).ingredients(ActuallyBlocks.ITEM_INTERFACE.get()).save(consumer);
}

View file

@ -1,11 +1,17 @@
package de.ellpeck.actuallyadditions.data;
import com.google.gson.JsonObject;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.crafting.CrushingRecipe;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.DirectoryCache;
import net.minecraft.data.IFinishedRecipe;
import net.minecraft.data.RecipeProvider;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.ResourceLocation;
import javax.annotation.Nonnull;
import java.nio.file.Path;
import java.util.function.Consumer;
@ -15,11 +21,12 @@ public class CrushingRecipeGenerator extends RecipeProvider {
}
@Override
protected void saveAdvancement(DirectoryCache p_208310_1_, JsonObject p_208310_2_, Path p_208310_3_) {
protected void saveAdvancement(@Nonnull DirectoryCache p_208310_1_, @Nonnull JsonObject p_208310_2_, @Nonnull Path p_208310_3_) {
}
@Override
protected void buildShapelessRecipes(Consumer<IFinishedRecipe> p_200404_1_) {
protected void buildShapelessRecipes(Consumer<IFinishedRecipe> consumer) {
consumer.accept(new CrushingRecipe.FinishedRecipe(new ResourceLocation(ActuallyAdditions.MODID, "bone_crusher"),
Ingredient.of(Items.BONE), Items.BONE_MEAL, 6, 1.0f , Items.AIR, 0, 0.0f));
}
}

View file

@ -19,7 +19,6 @@ import net.minecraft.tags.ItemTags;
import net.minecraft.util.IItemProvider;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.Tags;
import sun.plugin.dom.exception.InvalidStateException;
import java.nio.file.Path;
import java.util.ArrayList;
@ -38,86 +37,86 @@ public class EmpoweringRecipeGenerator extends RecipeProvider {
@Override
protected void buildShapelessRecipes(Consumer<IFinishedRecipe> consumer) {
EmpoweringBuilder.builder(ActuallyItems.EMPOWERED_RESTONIA_CRYSTAL.get(), ActuallyItems.RESTONIA_CRYSTAL.get(), 5000, 50, Crystals.REDSTONE.conversionColorParticles)
.addModifier(Tags.Items.DYES_RED)
.addModifier(Items.NETHER_BRICK)
.addModifier(Tags.Items.DUSTS_REDSTONE)
.addModifier(Items.BRICK).save(consumer, "restonia");
.addModifier(Tags.Items.DYES_RED)
.addModifier(Items.NETHER_BRICK)
.addModifier(Tags.Items.DUSTS_REDSTONE)
.addModifier(Items.BRICK).save(consumer, "restonia");
EmpoweringBuilder.builder(ActuallyBlocks.EMPOWERED_RESTONIA_CRYSTAL.get(), ActuallyBlocks.RESTONIA_CRYSTAL.get(), 50000, 500, Crystals.REDSTONE.conversionColorParticles)
.addModifier(Tags.Items.DYES_RED)
.addModifier(Items.NETHER_BRICK)
.addModifier(Tags.Items.DUSTS_REDSTONE)
.addModifier(Items.BRICK).save(consumer, "restonia_block");
.addModifier(Tags.Items.DYES_RED)
.addModifier(Items.NETHER_BRICK)
.addModifier(Tags.Items.DUSTS_REDSTONE)
.addModifier(Items.BRICK).save(consumer, "restonia_block");
EmpoweringBuilder.builder(ActuallyItems.EMPOWERED_PALIS_CRYSTAL.get(), ActuallyItems.PALIS_CRYSTAL.get(), 5000, 50, Crystals.LAPIS.conversionColorParticles)
.addModifier(Tags.Items.DYES_CYAN)
.addModifier(Items.PRISMARINE_SHARD)
.addModifier(Items.PRISMARINE_SHARD)
.addModifier(Items.PRISMARINE_SHARD).save(consumer, "palis");
.addModifier(Tags.Items.DYES_CYAN)
.addModifier(Items.PRISMARINE_SHARD)
.addModifier(Items.PRISMARINE_SHARD)
.addModifier(Items.PRISMARINE_SHARD).save(consumer, "palis");
EmpoweringBuilder.builder(ActuallyBlocks.EMPOWERED_PALIS_CRYSTAL.get(), ActuallyBlocks.PALIS_CRYSTAL.get(), 50000, 500, Crystals.LAPIS.conversionColorParticles)
.addModifier(Tags.Items.DYES_CYAN)
.addModifier(Items.PRISMARINE_SHARD)
.addModifier(Items.PRISMARINE_SHARD)
.addModifier(Items.PRISMARINE_SHARD).save(consumer, "palis_block");
.addModifier(Tags.Items.DYES_CYAN)
.addModifier(Items.PRISMARINE_SHARD)
.addModifier(Items.PRISMARINE_SHARD)
.addModifier(Items.PRISMARINE_SHARD).save(consumer, "palis_block");
EmpoweringBuilder.builder(ActuallyItems.EMPOWERED_DIAMATINE_CRYSTAL.get(), ActuallyItems.DIAMATINE_CRYSTAL.get(), 5000, 50, Crystals.DIAMOND.conversionColorParticles)
.addModifier(Tags.Items.DYES_LIGHT_BLUE)
.addModifier(Items.CLAY_BALL)
.addModifier(Items.CLAY_BALL)
.addModifier(Items.CLAY).save(consumer, "diamatine");
.addModifier(Tags.Items.DYES_LIGHT_BLUE)
.addModifier(Items.CLAY_BALL)
.addModifier(Items.CLAY_BALL)
.addModifier(Items.CLAY).save(consumer, "diamatine");
EmpoweringBuilder.builder(ActuallyBlocks.EMPOWERED_DIAMATINE_CRYSTAL.get(), ActuallyBlocks.DIAMATINE_CRYSTAL.get(), 50000, 500, Crystals.DIAMOND.conversionColorParticles)
.addModifier(Tags.Items.DYES_LIGHT_BLUE)
.addModifier(Items.CLAY_BALL)
.addModifier(Items.CLAY_BALL)
.addModifier(Items.CLAY).save(consumer, "diamatine_block");
.addModifier(Tags.Items.DYES_LIGHT_BLUE)
.addModifier(Items.CLAY_BALL)
.addModifier(Items.CLAY_BALL)
.addModifier(Items.CLAY).save(consumer, "diamatine_block");
EmpoweringBuilder.builder(ActuallyItems.EMPOWERED_ENORI_CRYSTAL.get(), ActuallyItems.ENORI_CRYSTAL.get(), 5000, 50, Crystals.IRON.conversionColorParticles)
.addModifier(Tags.Items.DYES_GRAY)
.addModifier(Items.SNOWBALL)
.addModifier(Items.STONE_BUTTON)
.addModifier(Tags.Items.COBBLESTONE).save(consumer, "enori");
.addModifier(Tags.Items.DYES_GRAY)
.addModifier(Items.SNOWBALL)
.addModifier(Items.STONE_BUTTON)
.addModifier(Tags.Items.COBBLESTONE).save(consumer, "enori");
EmpoweringBuilder.builder(ActuallyBlocks.EMPOWERED_ENORI_CRYSTAL.get(), ActuallyBlocks.ENORI_CRYSTAL.get(), 50000, 500, Crystals.IRON.conversionColorParticles)
.addModifier(Tags.Items.DYES_GRAY)
.addModifier(Items.SNOWBALL)
.addModifier(Items.STONE_BUTTON)
.addModifier(Tags.Items.COBBLESTONE).save(consumer, "enori_block");
.addModifier(Tags.Items.DYES_GRAY)
.addModifier(Items.SNOWBALL)
.addModifier(Items.STONE_BUTTON)
.addModifier(Tags.Items.COBBLESTONE).save(consumer, "enori_block");
EmpoweringBuilder.builder(ActuallyItems.EMPOWERED_VOID_CRYSTAL.get(), ActuallyItems.VOID_CRYSTAL.get(), 5000, 50, Crystals.COAL.conversionColorParticles)
.addModifier(Tags.Items.DYES_BLACK)
.addModifier(ItemTags.COALS)
.addModifier(Items.FLINT)
.addModifier(Tags.Items.STONE).save(consumer, "void");
.addModifier(Tags.Items.DYES_BLACK)
.addModifier(ItemTags.COALS)
.addModifier(Items.FLINT)
.addModifier(Tags.Items.STONE).save(consumer, "void");
EmpoweringBuilder.builder(ActuallyBlocks.EMPOWERED_VOID_CRYSTAL.get(), ActuallyBlocks.VOID_CRYSTAL.get(), 50000, 500, Crystals.COAL.conversionColorParticles)
.addModifier(Tags.Items.DYES_BLACK)
.addModifier(ItemTags.COALS)
.addModifier(Items.FLINT)
.addModifier(Tags.Items.STONE).save(consumer, "void_block");
.addModifier(Tags.Items.DYES_BLACK)
.addModifier(ItemTags.COALS)
.addModifier(Items.FLINT)
.addModifier(Tags.Items.STONE).save(consumer, "void_block");
EmpoweringBuilder.builder(ActuallyItems.EMPOWERED_EMERADIC_CRYSTAL.get(), ActuallyItems.EMERADIC_CRYSTAL.get(), 5000, 50, Crystals.EMERALD.conversionColorParticles)
.addModifier(Tags.Items.DYES_LIME)
.addModifier(Items.TALL_GRASS)
.addModifier(ItemTags.SAPLINGS)
.addModifier(Tags.Items.SLIMEBALLS).save(consumer, "emeradic");
.addModifier(Tags.Items.DYES_LIME)
.addModifier(Items.TALL_GRASS)
.addModifier(ItemTags.SAPLINGS)
.addModifier(Tags.Items.SLIMEBALLS).save(consumer, "emeradic");
EmpoweringBuilder.builder(ActuallyBlocks.EMPOWERED_EMERADIC_CRYSTAL.get(), ActuallyBlocks.EMERADIC_CRYSTAL.get(), 50000, 500, Crystals.EMERALD.conversionColorParticles)
.addModifier(Tags.Items.DYES_LIME)
.addModifier(Items.TALL_GRASS)
.addModifier(ItemTags.SAPLINGS)
.addModifier(Tags.Items.SLIMEBALLS).save(consumer, "emeradic_block");
.addModifier(Tags.Items.DYES_LIME)
.addModifier(Items.TALL_GRASS)
.addModifier(ItemTags.SAPLINGS)
.addModifier(Tags.Items.SLIMEBALLS).save(consumer, "emeradic_block");
EmpoweringBuilder.builder(ActuallyItems.EMPOWERED_CANOLA_SEED.get(), ActuallyItems.CRYSTALLIZED_CANOLA_SEED.get(), 1000, 30, 0x015b4c)
.addModifier(ActuallyItems.CANOLA_SEED.get())
.addModifier(ActuallyItems.CANOLA_SEED.get())
.addModifier(ActuallyItems.CANOLA_SEED.get())
.addModifier(ActuallyItems.CANOLA_SEED.get()).save(consumer, "empowered_canola");
.addModifier(ActuallyItems.CANOLA_SEED.get())
.addModifier(ActuallyItems.CANOLA_SEED.get())
.addModifier(ActuallyItems.CANOLA_SEED.get())
.addModifier(ActuallyItems.CANOLA_SEED.get()).save(consumer, "empowered_canola");
}
public static class EmpoweringBuilder {
private final Item result;
private final Ingredient base;
private List<Ingredient> modifiers = new ArrayList<>();
private final int energy;
private final int time;
private final int color;
private final List<Ingredient> modifiers = new ArrayList<>();
public EmpoweringBuilder(IItemProvider resultIn, Ingredient baseIn, int energyIn, int timeIn, int colorIn) {
result = resultIn.asItem();
@ -137,12 +136,14 @@ public class EmpoweringRecipeGenerator extends RecipeProvider {
modifiers.add(Ingredient.of(input));
return this;
}
public EmpoweringBuilder addModifier(ItemStack input) {
if (modifiers.size() >= 4)
throw new InvalidStateException("too many modifiers for empowering recipe, input: " + input.getItem().getRegistryName());
modifiers.add(Ingredient.of(input));
return this;
}
public EmpoweringBuilder addModifier(ITag<Item> input) {
if (modifiers.size() >= 4)
throw new InvalidStateException("too many modifiers for empowering recipe, input: " + input.toString());
@ -155,10 +156,11 @@ public class EmpoweringRecipeGenerator extends RecipeProvider {
throw new InvalidStateException("invalid modifier count: " + modifiers.size() + ", recipe: " + name.toString());
consumer.accept(new EmpowererRecipe.FinishedRecipe(name, result, base, modifiers.get(0), modifiers.get(1), modifiers.get(2), modifiers.get(3), energy, time, color));
}
public void save(Consumer<IFinishedRecipe> consumer, String name) {
ResourceLocation res = new ResourceLocation(ActuallyAdditions.MODID, "empowering/" + name);
if (modifiers.size() != 4)
throw new InvalidStateException("invalid modifier count: " + modifiers.size() + ", recipe: " + res.toString());
throw new InvalidStateException("invalid modifier count: " + modifiers.size() + ", recipe: " + res);
consumer.accept(new EmpowererRecipe.FinishedRecipe(res, result, base, modifiers.get(0), modifiers.get(1), modifiers.get(2), modifiers.get(3), energy, time, color));
}
}

View file

@ -9,6 +9,7 @@ import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods;
import net.minecraft.data.*;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.tags.ItemTags;
@ -16,6 +17,7 @@ import net.minecraft.util.IItemProvider;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.Tags;
import net.minecraftforge.common.crafting.NBTIngredient;
import net.minecraftforge.fml.RegistryObject;
import java.nio.file.Path;
import java.util.Arrays;
@ -29,6 +31,9 @@ public class ItemRecipeGenerator extends RecipeProvider {
@Override
protected void buildShapelessRecipes(Consumer<IFinishedRecipe> consumer) {
generateEquipment(consumer);
generatePaxels(consumer);
//Goggles
Recipe.shaped(ActuallyItems.ENGINEER_GOGGLES.get())
.pattern(" R ")
@ -383,6 +388,8 @@ public class ItemRecipeGenerator extends RecipeProvider {
.define('C', ActuallyItems.COIL_ADVANCED.get())
.save(WrappedRecipe.Inject(consumer, ActuallyRecipes.KEEP_DATA_SHAPED_RECIPE.get()));
//
// //Magnet Ring
// RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemMagnetRing), "RIB", "IOI", "BIR", 'R', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), 'I', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), 'B', new ItemStack(Items.DYE, 1, 4), 'O', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.RING.ordinal()));
@ -458,11 +465,120 @@ public class ItemRecipeGenerator extends RecipeProvider {
// GameRegistry.addSmelting(new ItemStack(InitItems.itemDust, 1, TheDusts.COAL.ordinal()), new ItemStack(Items.COAL), 1F);
}
protected void generateEquipment(Consumer<IFinishedRecipe> consumer) {
addToolAndArmorRecipes(consumer, ActuallyItems.BLACK_QUARTZ, ActuallyItems.PICKAXE_QUARTZ, ActuallyItems.SWORD_QUARTZ, ActuallyItems.AXE_QUARTZ, ActuallyItems.SHOVEL_QUARTZ, ActuallyItems.HOE_QUARTZ, ActuallyItems.HELM_QUARTZ, ActuallyItems.CHEST_QUARTZ, ActuallyItems.PANTS_QUARTZ, ActuallyItems.BOOTS_QUARTZ);
addToolAndArmorRecipes(consumer, ActuallyItems.RESTONIA_CRYSTAL, ActuallyItems.PICKAXE_CRYSTAL_RESTONIA, ActuallyItems.SWORD_CRYSTAL_RESTONIA, ActuallyItems.AXE_CRYSTAL_RESTONIA, ActuallyItems.SHOVEL_CRYSTAL_RESTONIA, ActuallyItems.HOE_CRYSTAL_RESTONIA, ActuallyItems.HELM_CRYSTAL_RESTONIA, ActuallyItems.CHEST_CRYSTAL_RESTONIA, ActuallyItems.PANTS_CRYSTAL_RESTONIA, ActuallyItems.BOOTS_CRYSTAL_RESTONIA);
addToolAndArmorRecipes(consumer, ActuallyItems.EMERADIC_CRYSTAL, ActuallyItems.PICKAXE_CRYSTAL_EMERADIC, ActuallyItems.SWORD_CRYSTAL_EMERADIC, ActuallyItems.AXE_CRYSTAL_EMERADIC, ActuallyItems.SHOVEL_CRYSTAL_EMERADIC, ActuallyItems.HOE_CRYSTAL_EMERADIC, ActuallyItems.HELM_CRYSTAL_EMERADIC, ActuallyItems.CHEST_CRYSTAL_EMERADIC, ActuallyItems.PANTS_CRYSTAL_EMERADIC, ActuallyItems.BOOTS_CRYSTAL_EMERADIC);
addToolAndArmorRecipes(consumer, ActuallyItems.ENORI_CRYSTAL, ActuallyItems.PICKAXE_CRYSTAL_ENORI, ActuallyItems.SWORD_CRYSTAL_ENORI, ActuallyItems.AXE_CRYSTAL_ENORI, ActuallyItems.SHOVEL_CRYSTAL_ENORI, ActuallyItems.HOE_CRYSTAL_ENORI, ActuallyItems.HELM_CRYSTAL_ENORI, ActuallyItems.CHEST_CRYSTAL_ENORI, ActuallyItems.PANTS_CRYSTAL_ENORI, ActuallyItems.BOOTS_CRYSTAL_ENORI);
addToolAndArmorRecipes(consumer, ActuallyItems.DIAMATINE_CRYSTAL, ActuallyItems.PICKAXE_CRYSTAL_DIAMATINE, ActuallyItems.SWORD_CRYSTAL_DIAMATINE, ActuallyItems.AXE_CRYSTAL_DIAMATINE, ActuallyItems.SHOVEL_CRYSTAL_DIAMATINE, ActuallyItems.HOE_CRYSTAL_DIAMATINE, ActuallyItems.HELM_CRYSTAL_DIAMATINE, ActuallyItems.CHEST_CRYSTAL_DIAMATINE, ActuallyItems.PANTS_CRYSTAL_DIAMATINE, ActuallyItems.BOOTS_CRYSTAL_DIAMATINE);
addToolAndArmorRecipes(consumer, ActuallyItems.PALIS_CRYSTAL, ActuallyItems.PICKAXE_CRYSTAL_PALIS, ActuallyItems.SWORD_CRYSTAL_PALIS, ActuallyItems.AXE_CRYSTAL_PALIS, ActuallyItems.SHOVEL_CRYSTAL_PALIS, ActuallyItems.HOE_CRYSTAL_PALIS, ActuallyItems.HELM_CRYSTAL_PALIS, ActuallyItems.CHEST_CRYSTAL_PALIS, ActuallyItems.PANTS_CRYSTAL_PALIS, ActuallyItems.BOOTS_CRYSTAL_PALIS);
addToolAndArmorRecipes(consumer, ActuallyItems.VOID_CRYSTAL, ActuallyItems.PICKAXE_CRYSTAL_VOID, ActuallyItems.SWORD_CRYSTAL_VOID, ActuallyItems.AXE_CRYSTAL_VOID, ActuallyItems.SHOVEL_CRYSTAL_VOID, ActuallyItems.HOE_CRYSTAL_VOID, ActuallyItems.HELM_CRYSTAL_VOID, ActuallyItems.CHEST_CRYSTAL_VOID, ActuallyItems.PANTS_CRYSTAL_VOID, ActuallyItems.BOOTS_CRYSTAL_VOID);
}
protected void generatePaxels(Consumer<IFinishedRecipe> consumer) {
addPaxel(consumer, ActuallyItems.WOODEN_PAXEL, Items.WOODEN_AXE, Items.WOODEN_PICKAXE, Items.WOODEN_SWORD, Items.WOODEN_SHOVEL, Items.WOODEN_HOE);
addPaxel(consumer, ActuallyItems.STONE_PAXEL, Items.STONE_AXE, Items.STONE_PICKAXE, Items.STONE_SWORD, Items.STONE_SHOVEL, Items.STONE_HOE);
addPaxel(consumer, ActuallyItems.IRON_PAXEL, Items.IRON_AXE, Items.IRON_PICKAXE, Items.IRON_SWORD, Items.IRON_SHOVEL, Items.IRON_HOE);
addPaxel(consumer, ActuallyItems.GOLD_PAXEL, Items.GOLDEN_AXE, Items.GOLDEN_PICKAXE, Items.GOLDEN_SWORD, Items.GOLDEN_SHOVEL, Items.GOLDEN_HOE);
addPaxel(consumer, ActuallyItems.DIAMOND_PAXEL, Items.DIAMOND_AXE, Items.DIAMOND_PICKAXE, Items.DIAMOND_SWORD, Items.DIAMOND_SHOVEL, Items.DIAMOND_HOE);
addPaxel(consumer, ActuallyItems.NETHERITE_PAXEL, Items.NETHERITE_AXE, Items.NETHERITE_PICKAXE, Items.NETHERITE_SWORD, Items.NETHERITE_SHOVEL, Items.NETHERITE_HOE);
addPaxel(consumer, ActuallyItems.QUARTZ_PAXEL, ActuallyItems.AXE_QUARTZ, ActuallyItems.PICKAXE_QUARTZ, ActuallyItems.SWORD_QUARTZ, ActuallyItems.SHOVEL_QUARTZ, ActuallyItems.HOE_QUARTZ);
addPaxel(consumer, ActuallyItems.PAXEL_CRYSTAL_RESTONIA, ActuallyItems.AXE_CRYSTAL_RESTONIA, ActuallyItems.PICKAXE_CRYSTAL_RESTONIA, ActuallyItems.SWORD_CRYSTAL_RESTONIA, ActuallyItems.SHOVEL_CRYSTAL_RESTONIA, ActuallyItems.HOE_CRYSTAL_RESTONIA);
addPaxel(consumer, ActuallyItems.PAXEL_CRYSTAL_EMERADIC, ActuallyItems.AXE_CRYSTAL_EMERADIC, ActuallyItems.PICKAXE_CRYSTAL_EMERADIC, ActuallyItems.SWORD_CRYSTAL_EMERADIC, ActuallyItems.SHOVEL_CRYSTAL_EMERADIC, ActuallyItems.HOE_CRYSTAL_EMERADIC);
addPaxel(consumer, ActuallyItems.PAXEL_CRYSTAL_PALIS, ActuallyItems.AXE_CRYSTAL_PALIS, ActuallyItems.PICKAXE_CRYSTAL_PALIS, ActuallyItems.SWORD_CRYSTAL_PALIS, ActuallyItems.SHOVEL_CRYSTAL_PALIS, ActuallyItems.HOE_CRYSTAL_PALIS);
addPaxel(consumer, ActuallyItems.PAXEL_CRYSTAL_DIAMATINE, ActuallyItems.AXE_CRYSTAL_DIAMATINE, ActuallyItems.PICKAXE_CRYSTAL_DIAMATINE, ActuallyItems.SWORD_CRYSTAL_DIAMATINE, ActuallyItems.SHOVEL_CRYSTAL_DIAMATINE, ActuallyItems.HOE_CRYSTAL_DIAMATINE);
addPaxel(consumer, ActuallyItems.PAXEL_CRYSTAL_VOID, ActuallyItems.AXE_CRYSTAL_VOID, ActuallyItems.PICKAXE_CRYSTAL_VOID, ActuallyItems.SWORD_CRYSTAL_VOID, ActuallyItems.SHOVEL_CRYSTAL_VOID, ActuallyItems.HOE_CRYSTAL_VOID);
addPaxel(consumer, ActuallyItems.PAXEL_CRYSTAL_ENORI, ActuallyItems.AXE_CRYSTAL_ENORI, ActuallyItems.PICKAXE_CRYSTAL_ENORI, ActuallyItems.SWORD_CRYSTAL_ENORI, ActuallyItems.SHOVEL_CRYSTAL_ENORI, ActuallyItems.HOE_CRYSTAL_ENORI);
}
public static void addPaxel(Consumer<IFinishedRecipe> consumer, RegistryObject<Item> output, Item axe, Item pickaxe, Item sword, Item shovel, Item hoe) {
Recipe.shapeless(output.get())
.requires(axe)
.requires(pickaxe)
.requires(sword)
.requires(shovel)
.requires(hoe)
.save(consumer);
}
public static void addPaxel(Consumer<IFinishedRecipe> consumer, RegistryObject<Item> output, RegistryObject<Item> axe, RegistryObject<Item> pickaxe, RegistryObject<Item> sword, RegistryObject<Item> shovel, RegistryObject<Item> hoe) {
Recipe.shapeless(output.get())
.requires(axe.get())
.requires(pickaxe.get())
.requires(sword.get())
.requires(shovel.get())
.requires(hoe.get())
.save(consumer);
}
@Override
protected void saveAdvancement(DirectoryCache cache, JsonObject cache2, Path advancementJson) {
//Nope...
}
public static void addToolAndArmorRecipes(Consumer<IFinishedRecipe> consumer, RegistryObject<Item> base, RegistryObject<Item> pickaxe, RegistryObject<Item> sword, RegistryObject<Item> axe, RegistryObject<Item> shovel, RegistryObject<Item> hoe, RegistryObject<Item> helm, RegistryObject<Item> chest, RegistryObject<Item> pants, RegistryObject<Item> boots) {
//Pickaxe
Recipe.shaped(pickaxe.get())
.pattern("EEE", " S ", " S ")
.define('E', base.get())
.define('S', Tags.Items.RODS_WOODEN)
.save(consumer);
//Sword
Recipe.shaped(sword.get())
.pattern("E", "E", "S")
.define('E', base.get())
.define('S', Tags.Items.RODS_WOODEN)
.save(consumer);
//Axe
Recipe.shaped(axe.get())
.pattern("EE", "ES", " S")
.define('E', base.get())
.define('S', Tags.Items.RODS_WOODEN)
.save(consumer);
//Shovel
Recipe.shaped(shovel.get())
.pattern("E", "S", "S")
.define('E', base.get())
.define('S', Tags.Items.RODS_WOODEN)
.save(consumer);
//Hoe
Recipe.shaped(hoe.get())
.pattern("EE", " S", " S")
.define('E', base.get())
.define('S', Tags.Items.RODS_WOODEN)
.save(consumer);
//Helm
Recipe.shaped(helm.get())
.pattern("OOO", "O O")
.define('O', base.get())
.save(consumer);
//Chest
Recipe.shaped(chest.get())
.pattern("O O", "OOO", "OOO")
.define('O', base.get())
.save(consumer);
//Legs
Recipe.shaped(pants.get())
.pattern("OOO", "O O", "O O")
.define('O', base.get())
.save(consumer);
//Boots
Recipe.shaped(boots.get())
.pattern("O O", "O O")
.define('O', base.get())
.save(consumer);
}
public static class Recipe {
public static ItemRecipeGenerator.Recipe.Shapeless shapeless(IItemProvider result) {
return new ItemRecipeGenerator.Recipe.Shapeless(result);

View file

@ -12,11 +12,11 @@ package de.ellpeck.actuallyadditions.mod;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.booklet.InitBooklet;
import de.ellpeck.actuallyadditions.mod.crafting.ActuallyRecipes;
import de.ellpeck.actuallyadditions.mod.crafting.CrusherCrafting;
import de.ellpeck.actuallyadditions.mod.crafting.TargetNBTIngredient;
import de.ellpeck.actuallyadditions.mod.data.WorldData;
import de.ellpeck.actuallyadditions.mod.entity.EntityWorm;
import de.ellpeck.actuallyadditions.mod.entity.InitEntities;
import de.ellpeck.actuallyadditions.mod.event.CommonEvents;
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
@ -34,18 +34,23 @@ import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
import de.ellpeck.actuallyadditions.mod.recipe.HairyBallHandler;
import de.ellpeck.actuallyadditions.mod.update.UpdateChecker;
import de.ellpeck.actuallyadditions.mod.util.ResourceReloader;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.crafting.CraftingHelper;
import net.minecraftforge.event.AddReloadListenerEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.server.FMLServerStartedEvent;
import net.minecraftforge.fml.event.server.FMLServerStoppedEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -71,6 +76,10 @@ public class ActuallyAdditions {
}
};
public static final Logger LOGGER = LogManager.getLogger(NAME);
public static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITIES, "entities");
public static final RegistryObject<EntityType<EntityWorm>> ENTITY_WORM = ENTITIES.register("worm", () -> EntityType.Builder.of(EntityWorm::new, EntityClassification.CREATURE).build(MODID + ":worm"));
@Deprecated
public static ActuallyAdditions INSTANCE;
@ -87,6 +96,7 @@ public class ActuallyAdditions {
ActuallyBlocks.TILES.register(eventBus);
ActuallyRecipes.init(eventBus);
ActuallyContainers.CONTAINERS.register(eventBus);
ENTITIES.register(eventBus);
MinecraftForge.EVENT_BUS.addListener(this::serverStarted);
MinecraftForge.EVENT_BUS.addListener(this::serverStopped);
@ -99,6 +109,10 @@ public class ActuallyAdditions {
eventBus.addListener(this::clientSetup);
}
private static void reloadEvent(AddReloadListenerEvent event) {
event.addListener(new ResourceReloader(event.getDataPackRegistries()));
}
private void setup(FMLCommonSetupEvent event) {
PacketHandler.init();
@ -119,11 +133,6 @@ public class ActuallyAdditions {
HairyBallHandler.init();
LensRecipeHandler.init();
LensMining.init();
InitBooklet.init();
}
private static void reloadEvent(AddReloadListenerEvent event){
event.addListener(new ResourceReloader(event.getDataPackRegistries()));
}
private void clientSetup(FMLClientSetupEvent event) {

View file

@ -21,7 +21,6 @@ import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntityType;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
@ -156,9 +155,9 @@ public final class ActuallyBlocks {
// Interface Blocks
public static final AABlockReg<BlockPlayerInterface, AABlockItem, TileEntityPlayerInterface> PLAYER_INTERFACE = new AABlockReg<>("player_interface", BlockPlayerInterface::new,
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityPlayerInterface::new);
public static final AABlockReg<BlockItemInterface, AABlockItem, TileEntityItemInterface> ITEM_VIEWER = new AABlockReg<>("item_viewer", BlockItemInterface::new,
public static final AABlockReg<BlockItemInterface, AABlockItem, TileEntityItemInterface> ITEM_INTERFACE = new AABlockReg<>("item_viewer", BlockItemInterface::new,
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityItemInterface::new);
public static final AABlockReg<BlockItemInterfaceHopping, AABlockItem, TileEntityItemInterfaceHopping> ITEM_VIEWER_HOPPING = new AABlockReg<>("item_viewer_hopping", BlockItemInterfaceHopping::new,
public static final AABlockReg<BlockItemInterfaceHopping, AABlockItem, TileEntityItemInterfaceHopping> ITEM_INTERFACE_HOPPING = new AABlockReg<>("item_viewer_hopping", BlockItemInterfaceHopping::new,
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityItemInterfaceHopping::new);
// Phantom stuff

View file

@ -16,7 +16,6 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
@ -27,9 +26,6 @@ import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.fml.network.NetworkHooks;
import net.minecraft.block.AbstractBlock.Properties;
public class BlockFermentingBarrel extends BlockContainerBase {
@ -47,9 +43,11 @@ public class BlockFermentingBarrel extends BlockContainerBase {
if (!world.isClientSide) {
TileEntityFermentingBarrel press = (TileEntityFermentingBarrel) world.getBlockEntity(pos);
if (press != null) {
if (!this.tryUseItemOnTank(player, hand, press.canolaTank) && !this.tryUseItemOnTank(player, hand, press.oilTank)) {
/* if (!this.tryUseItemOnTank(player, hand, press.tanks.canolaTank) && !this.tryUseItemOnTank(player, hand, press.tanks.oilTank)) {
NetworkHooks.openGui((ServerPlayerEntity) player, press, pos);
}
*/
}
return ActionResultType.PASS;
}

View file

@ -41,12 +41,12 @@ public class BlockVerticalDigger extends DirectionalBlock.Container implements I
@Override
public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
return this.openGui(worldIn, player, pos, TileEntityMiner.class);
return this.openGui(worldIn, player, pos, TileEntityVerticalDigger.class);
}
@Override
public TileEntity newBlockEntity(IBlockReader world) {
return new TileEntityMiner();
return new TileEntityVerticalDigger();
}
@Override
@ -56,13 +56,13 @@ public class BlockVerticalDigger extends DirectionalBlock.Container implements I
return;
}
TileEntity tile = minecraft.level.getBlockEntity(((BlockRayTraceResult) rayCast).getBlockPos());
if (tile instanceof TileEntityMiner) {
TileEntityMiner miner = (TileEntityMiner) tile;
if (tile instanceof TileEntityVerticalDigger) {
TileEntityVerticalDigger miner = (TileEntityVerticalDigger) tile;
String info = miner.checkY == 0
? "Done Mining!"
: miner.checkY == -1
? "Calculating positions..."
: "Mining at " + (miner.getBlockPos().getX() + miner.checkX) + ", " + miner.checkY + ", " + (miner.getBlockPos().getZ() + miner.checkZ) + ".";
? "Calculating positions..."
: "Mining at " + (miner.getBlockPos().getX() + miner.checkX) + ", " + miner.checkY + ", " + (miner.getBlockPos().getZ() + miner.checkZ) + ".";
minecraft.font.drawShadow(matrices, info, resolution.getGuiScaledWidth() / 2f + 5, resolution.getGuiScaledHeight() / 2f - 20, StringUtil.DECIMAL_COLOR_WHITE);
}
}

View file

@ -8,8 +8,6 @@ import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.Direction;
import net.minecraft.block.AbstractBlock.Properties;
/**
* Wrapper for Fully Direction block states extending from our base blocks. It's not super nice but it'll do.
*/
@ -28,7 +26,7 @@ public abstract class FullyDirectionalBlock extends BlockBase {
}
public BlockState getBaseConstructorState() {
return this.stateContainer.getBaseState().with(FACING, Direction.NORTH);
return this.stateDefinition.getOwner().defaultBlockState().setValue(FACING, Direction.NORTH);
}
@Override

View file

@ -1,300 +1,300 @@
/*
* This file ("InitBooklet.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors;
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
import de.ellpeck.actuallyadditions.mod.booklet.chapter.BookletChapter;
import de.ellpeck.actuallyadditions.mod.booklet.chapter.BookletChapterCoffee;
import de.ellpeck.actuallyadditions.mod.booklet.chapter.BookletChapterCrusher;
import de.ellpeck.actuallyadditions.mod.booklet.chapter.BookletChapterTrials;
import de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntry;
import de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntryAllItems;
import de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntryTrials;
import de.ellpeck.actuallyadditions.mod.booklet.page.*;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
import de.ellpeck.actuallyadditions.mod.crafting.*;
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
import de.ellpeck.actuallyadditions.mod.items.ItemWingsOfTheBats;
import de.ellpeck.actuallyadditions.mod.items.lens.LensDisenchanting;
import de.ellpeck.actuallyadditions.mod.items.lens.LensRecipeHandler;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods;
import de.ellpeck.actuallyadditions.mod.tile.*;
import de.ellpeck.actuallyadditions.mod.update.UpdateChecker;
import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.block.Blocks;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public final class InitBooklet {
public static BookletChapter[] chaptersIntroduction = new BookletChapter[11];
public static void init() {
ActuallyAdditionsAPI.entryAllAndSearch = new BookletEntryAllItems("allAndSearch").setImportant();
ActuallyAdditionsAPI.entryTrials = new BookletEntryTrials("trials");
ActuallyAdditionsAPI.entryGettingStarted = new BookletEntry("gettingStarted").setImportant();
ActuallyAdditionsAPI.entryReconstruction = new BookletEntry("reconstruction");
ActuallyAdditionsAPI.entryLaserRelays = new BookletEntry("laserRelays").setSpecial();
ActuallyAdditionsAPI.entryFunctionalNonRF = new BookletEntry("functionalNoRF");
ActuallyAdditionsAPI.entryFunctionalRF = new BookletEntry("functionalRF");
ActuallyAdditionsAPI.entryGeneratingRF = new BookletEntry("generatingRF");
ActuallyAdditionsAPI.entryItemsNonRF = new BookletEntry("itemsNoRF");
ActuallyAdditionsAPI.entryItemsRF = new BookletEntry("itemsRF");
ActuallyAdditionsAPI.entryMisc = new BookletEntry("misc");
ActuallyAdditionsAPI.entryUpdatesAndInfos = new BookletEntry("updatesAndInfos").setSpecial();
initChapters();
int chapCount = 0;
int pageCount = 0;
int infoCount = 0;
for (IBookletEntry entry : ActuallyAdditionsAPI.BOOKLET_ENTRIES) {
for (IBookletChapter chapter : entry.getAllChapters()) {
if (!ActuallyAdditionsAPI.ALL_CHAPTERS.contains(chapter)) {
ActuallyAdditionsAPI.ALL_CHAPTERS.add(chapter);
chapCount++;
for (IBookletPage page : chapter.getAllPages()) {
pageCount++;
List<ItemStack> items = new ArrayList<>();
page.getItemStacksForPage(items);
List<FluidStack> fluids = new ArrayList<>();
page.getFluidStacksForPage(fluids);
if (items != null && !items.isEmpty() || fluids != null && !fluids.isEmpty()) {
if (!ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA.contains(page)) {
ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA.add(page);
infoCount++;
}
}
}
}
}
}
Collections.sort(ActuallyAdditionsAPI.BOOKLET_ENTRIES, (entry1, entry2) -> {
Integer prio1 = entry1.getSortingPriority();
Integer prio2 = entry2.getSortingPriority();
return prio2.compareTo(prio1);
});
Collections.sort(ActuallyAdditionsAPI.ALL_CHAPTERS, (chapter1, chapter2) -> {
Integer prio1 = chapter1.getSortingPriority();
Integer prio2 = chapter2.getSortingPriority();
return prio2.compareTo(prio1);
});
Collections.sort(ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA, (page1, page2) -> {
Integer prio1 = page1.getSortingPriority();
Integer prio2 = page2.getSortingPriority();
return prio2.compareTo(prio1);
});
ActuallyAdditions.LOGGER.info("Registered a total of " + chapCount + " booklet chapters, where " + infoCount + " out of " + pageCount + " booklet pages contain information about items or fluids!");
}
private static void initChapters() {
/*
//Getting Started
chaptersIntroduction[0] = new BookletChapter("bookTutorial", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(ActuallyItems.ITEM_BOOKLET.get()), new PageTextOnly(1), new PageTextOnly(2), new PageTextOnly(3), new PageCrafting(4, ItemCrafting.recipeBook).setNoText());
// chaptersIntroduction[1] = new BookletChapter("videoGuide", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitItems.itemMisc.get(), 1, TheMiscItems.YOUTUBE_ICON.ordinal()), new PageLinkButton(1, "https://www.youtube.com/watch?v=fhjz0Ew56pM"), new PageLinkButton(2, "https://www.youtube.com/playlist?list=PLJeFZ64pT89MrTRZYzD_rtHFajPVlt6cF")).setImportant();
new BookletChapter("intro", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(ActuallyItems.ITEM_BOOKLET.get()), new PageTextOnly(1), new PageTextOnly(2), new PageTextOnly(3));
ArrayList<BookletPage> crystalPages = new ArrayList<>();
crystalPages.addAll(Arrays.asList(new PageTextOnly(1).addTextReplacement("<rf>", TileEntityAtomicReconstructor.ENERGY_USE), new PageTextOnly(2), new PageTextOnly(3), new PagePicture(4, "page_atomic_reconstructor", 0).setNoText(), new PageTextOnly(5), new PageCrafting(6, BlockCrafting.recipeAtomicReconstructor).setWildcard()));
for (int i = 0; i < LensRecipeHandler.MAIN_PAGE_RECIPES.size(); i++) {
crystalPages.add(new PageReconstructor(7 + i, LensRecipeHandler.MAIN_PAGE_RECIPES.get(i)).setNoText());
}
crystalPages.add(new PageCrafting(crystalPages.size() + 1, MiscCrafting.RECIPES_CRYSTALS).setNoText());
crystalPages.add(new PageCrafting(crystalPages.size() + 1, MiscCrafting.RECIPES_CRYSTAL_BLOCKS).setNoText());
chaptersIntroduction[2] = new BookletChapter("engineerHouse", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(Items.EMERALD), new PageTextOnly(1), new PagePicture(2, "page_engineer_house", 145));
chaptersIntroduction[6] = new BookletChapter("crystals", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(ActuallyBlocks.ATOMIC_RECONSTRUCTOR.get()), crystalPages.toArray(new BookletPage[crystalPages.size()])).setSpecial();
chaptersIntroduction[5] = new BookletChapter("coalGen", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(ActuallyBlocks.COAL_GENERATOR.get()), new PageTextOnly(1).addTextReplacement("<rf>", ConfigIntValues.COAL_GENERATOR_CF_PRODUCTION.getValue()), new PageCrafting(2, BlockCrafting.recipeCoalGen).setWildcard().setNoText());
ArrayList<BookletPage> empowererPages = new ArrayList<>();
empowererPages.addAll(Arrays.asList(new PageTextOnly(1), new PagePicture(2, "page_empowerer", 137), new PageCrafting(3, BlockCrafting.recipeEmpowerer), new PageCrafting(4, BlockCrafting.recipeDisplayStand)));
for (int i = 0; i < EmpowererHandler.MAIN_PAGE_RECIPES.size(); i++) {
empowererPages.add(new PageEmpowerer(7 + i, EmpowererHandler.MAIN_PAGE_RECIPES.get(i)).setNoText());
}
empowererPages.add(new PageCrafting(empowererPages.size() + 1, MiscCrafting.RECIPES_EMPOWERED_CRYSTALS).setNoText());
empowererPages.add(new PageCrafting(empowererPages.size() + 1, MiscCrafting.RECIPES_EMPOWERED_CRYSTAL_BLOCKS).setNoText());
new BookletChapter("empowerer", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(ActuallyBlocks.EMPOWERER.get()), empowererPages.toArray(new BookletPage[empowererPages.size()])).setSpecial();
new BookletChapter("craftingIngs", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(ActuallyItems.COIL.get()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeCoil).setNoText(), new PageCrafting(3, ItemCrafting.recipeCoilAdvanced).setNoText(), new PageCrafting(4, BlockCrafting.recipeCase).setNoText(), new PageCrafting(5, BlockCrafting.recipeEnderPearlBlock).setNoText(), new PageCrafting(6, BlockCrafting.recipeEnderCase).setNoText(), new PageCrafting(7, ItemCrafting.recipeRing).setNoText(), new PageCrafting(8, ItemCrafting.recipeKnifeHandle).setNoText(), new PageCrafting(9, ItemCrafting.recipeKnifeBlade).setNoText(), new PageCrafting(10, ItemCrafting.recipeKnife).setNoText(), new PageCrafting(11, ItemCrafting.recipeDough).setNoText(), new PageCrafting(12, ItemCrafting.recipeRiceDough).setNoText(), new PageCrafting(13, BlockCrafting.recipeIronCase).setNoText(), new PageCrafting(14, ItemCrafting.recipeLens).setNoText());
chaptersIntroduction[4] = new BookletChapter("rf", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(Items.REDSTONE), new PageTextOnly(1), new PageTextOnly(2)).setImportant();
//Miscellaneous
new BookletChapter("worms", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyItems.WORM.get()), new PageTextOnly(1).addItemsToPage(new ItemStack(ActuallyItems.WORM.get())), new PagePicture(2, "page_worms", 145)).setImportant();
new BookletChapter("lushCaves", ActuallyAdditionsAPI.entryMisc, new ItemStack(Blocks.STONE), new PageTextOnly(1), new PagePicture(2, "page_lush_caves", 0).setNoText());
new BookletChapter("crystalClusters", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyBlocks.EMERADIC_CRYSTAL_CLUSTER.get()), new PageTextOnly(1).addItemsToPage(WorldGenLushCaves.CRYSTAL_CLUSTERS), new PageCrafting(2, MiscCrafting.RECIPES_CRYSTAL_SHARDS).setNoText(), new PageCrafting(3, MiscCrafting.RECIPES_CRYSTAL_SHARDS_BACK).setNoText()).setSpecial();
new BookletChapter("banners", ActuallyAdditionsAPI.entryMisc, new ItemStack(Items.BLUE_BANNER, 1), new PageTextOnly(1));
new BookletChapter("miscDecorStuffsAndThings", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyBlocks.ETHETIC_GREEN_BLOCK.get()), new PageTextOnly(1), new PageReconstructor(2, LensRecipeHandler.recipeWhiteWall).setNoText(), new PageReconstructor(3, LensRecipeHandler.recipeGreenWall).setNoText());
chaptersIntroduction[3] = new BookletChapter("quartz", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyItems.BLACK_QUARTZ.get()), new PageTextOnly(1).addItemsToPage(new ItemStack(ActuallyBlocks.blockMisc, 1, TheMiscBlocks.ORE_QUARTZ.ordinal())).addTextReplacement("<lowest>", AAWorldGen.QUARTZ_MIN).addTextReplacement("<highest>", AAWorldGen.QUARTZ_MAX), new PageTextOnly(2).addItemsToPage(new ItemStack(ActuallyItems.itemBlackQuartz.get())), new PageCrafting(3, BlockCrafting.recipeQuartzBlock).setNoText(), new PageCrafting(4, BlockCrafting.recipeQuartzPillar).setNoText(), new PageCrafting(5, BlockCrafting.recipeQuartzChiseled).setNoText());
// new BookletChapter("cloud", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyBlocks.blockSmileyCloud), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeSmileyCloud).setWildcard()).setSpecial();
new BookletChapter("coalStuff", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyItems.TINY_COAL.get()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeTinyCoal).setNoText(), new PageCrafting(3, ItemCrafting.recipeTinyChar).setNoText(), new PageCrafting(4, BlockCrafting.recipeBlockChar).setNoText());
ArrayList<BookletPage> lampPages = new ArrayList<>();
lampPages.add(new PageTextOnly(lampPages.size() + 1));
lampPages.add(new PageTextOnly(lampPages.size() + 1));
lampPages.add(new PageCrafting(lampPages.size() + 1, BlockCrafting.recipePowerer).setWildcard().setNoText());
for (IRecipe recipe : BlockCrafting.RECIPES_LAMPS) {
lampPages.add(new PageCrafting(lampPages.size() + 1, recipe).setNoText());
}
new BookletChapter("lamps", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyBlocks.blockColoredLampOn.get(), 1, TheColoredLampColors.GREEN.ordinal()), lampPages.toArray(new BookletPage[lampPages.size()]));
new BookletChapter("enderStar", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyItems.ENDER_STAR.get()), new PageCrafting(1, ItemCrafting.recipeEnderStar));
new BookletChapter("spawnerShard", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyItems.SPAWNER_SHARD.get()), new PageTextOnly(1).addItemsToPage(new ItemStack(ActuallyItems.SPAWNER_SHARD.get())));
// new BookletChapter("treasureChest", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitBlocks.blockTreasureChest.get()), new PagePicture(1, "page_treasure_chest", 150).addItemsToPage(new ItemStack(InitBlocks.blockTreasureChest.get())), new PageTextOnly(2)).setSpecial();
new BookletChapter("hairBalls", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyItems.HAIRY_BALL.get()), new PagePicture(1, "page_fur_balls", 110).addItemsToPage(new ItemStack(ActuallyItems.HAIRY_BALL.get())), new PageTextOnly(2)).setSpecial();
// new BookletChapter("blackLotus", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitBlocks.blockBlackLotus.get()), new PageTextOnly(1).addItemsToPage(new ItemStack(InitBlocks.blockBlackLotus.get())), new PageCrafting(2, ItemCrafting.recipeBlackDye));
new BookletChapter("waterBowl", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyItems.WATER_BOWL.get()), new PageTextOnly(1).addItemsToPage(new ItemStack(ActuallyItems.WATER_BOWL.get())));
new BookletChapter("tinyTorch", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyBlocks.TINY_TORCH.get()), new PageCrafting(1, BlockCrafting.recipesTinyTorch).setWildcard()).setSpecial();
//Reconstruction
chaptersIntroduction[7] = new BookletChapter("reconstructorLenses", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(ActuallyItems.LENS.get()), new PageTextOnly(1)).setImportant();
new BookletChapter("additionalRecipes", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(Items.LEATHER), new PageReconstructor(1, LensRecipeHandler.recipeSoulSand).setNoText(), new PageReconstructor(2, LensRecipeHandler.recipeLeather).setNoText(), new PageReconstructor(3, LensRecipeHandler.recipeNetherWart).setNoText(), new PageReconstructor(4, LensRecipeHandler.recipePrismarine).setNoText()).setSpecial();
new BookletChapter("bookSplitting", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(Items.ENCHANTED_BOOK), new PageTextOnly(1), new PageReconstructor(2, new LensConversionRecipe(Ingredient.fromItem(Items.ENCHANTED_BOOK), new ItemStack(Items.ENCHANTED_BOOK), 0, ActuallyAdditionsAPI.lensDefaultConversion)).setNoText());
new BookletChapter("lensColor", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(ActuallyItems.COLOR_LENS.get()), new PageTextOnly(1), new PageReconstructor(2, LensRecipeHandler.recipeColorLens).setNoText());
new BookletChapter("lensDeath", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(ActuallyItems.DAMAGE_LENS.get()), new PageTextOnly(1), new PageReconstructor(2, LensRecipeHandler.recipeDamageLens).setNoText());
new BookletChapter("lensMoreDeath", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(ActuallyItems.MORE_DAMAGE_LENS.get()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeLensMoreDeath).setNoText());
new BookletChapter("lensDetonation", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(ActuallyItems.EXPLOSION_LENS.get()), new PageTextOnly(1), new PageReconstructor(2, LensRecipeHandler.recipeExplosionLens).setNoText());
new BookletChapter("lensDisenchanting", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(ActuallyItems.DISENCHANTING_LENS.get()), new PageTextOnly(1).addTextReplacement("<energy>", LensDisenchanting.ENERGY_USE), new PageCrafting(2, ItemCrafting.recipeDisenchantingLens).setNoText()).setSpecial();
new BookletChapter("lensMining", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(ActuallyItems.MINING_LENS.get()), new PageTextOnly(1).addTextReplacement("<energy>", ConfigIntValues.MINING_LENS_USE.getValue()), new PageCrafting(2, ItemCrafting.recipeMiningLens).setNoText()).setImportant();
//Laser Relays
chaptersIntroduction[8] = new BookletChapter("laserIntro", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(ActuallyItems.LASER_WRENCH.get()), new PageTextOnly(1), new PageTextOnly(2).addTextReplacement("<range>", TileEntityLaserRelay.MAX_DISTANCE), new PageCrafting(3, ItemCrafting.recipeLaserWrench)).setImportant();
new BookletChapter("laserRelays", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(ActuallyBlocks.LASER_RELAY.get()), new PageTextOnly(1), new PageTextOnly(2).addTextReplacement("<cap1>", TileEntityLaserRelayEnergy.CAP).addTextReplacement("<cap2>", TileEntityLaserRelayEnergyAdvanced.CAP).addTextReplacement("<cap3>", TileEntityLaserRelayEnergyExtreme.CAP), new PagePicture(3, "page_laser_relay", 0).setNoText(), new PageCrafting(4, BlockCrafting.recipeLaserRelay).setWildcard().setNoText(), new PageCrafting(5, BlockCrafting.recipeLaserRelayAdvanced).setWildcard().setNoText(), new PageCrafting(6, BlockCrafting.recipeLaserRelayExtreme).setWildcard().setNoText());
new BookletChapter("fluidLaser", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(ActuallyBlocks.LASER_RELAY_FLUIDS.get()), new PageTextOnly(1), new PageReconstructor(2, LensRecipeHandler.recipeFluidLaser).setWildcard().setNoText());
new BookletChapter("itemRelays", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(ActuallyBlocks.LASER_RELAY_ITEM.get()), new PageTextOnly(1), new PageReconstructor(2, LensRecipeHandler.recipeItemLaser).setWildcard().setNoText()).setSpecial();
new BookletChapter("itemInterfaces", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(ActuallyBlocks.ITEM_VIEWER.get()), new PageTextOnly(1), new PageTextOnly(2), new PageCrafting(3, BlockCrafting.recipeItemInterface).setNoText());
new BookletChapter("itemRelaysAdvanced", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(ActuallyBlocks.LASER_RELAY_ITEM_ADVANCED.get()), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeLaserRelayItemWhitelist).setWildcard());
new BookletChapter("itemInterfacesHopping", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(ActuallyBlocks.ITEM_VIEWER_HOPPING.get()), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeItemInterfaceHopping).setWildcard().setNoText());
new BookletChapter("laserUpgradeInvisibility", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(ActuallyItems.LASER_UPGRADE_INVISIBILITY.get()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeLaserUpgradeInvisibility).setNoText()).setImportant();
new BookletChapter("laserUpgradeRange", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(ActuallyItems.LASER_UPGRADE_RANGE.get()), new PageTextOnly(1).addTextReplacement("<def>", TileEntityLaserRelay.MAX_DISTANCE).addTextReplacement("<upgraded>", TileEntityLaserRelay.MAX_DISTANCE_RANGED), new PageCrafting(2, ItemCrafting.recipeLaserUpgradeRange).setNoText()).setImportant();
//No RF Using Blocks
new BookletChapter("breaker", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(ActuallyBlocks.BREAKER.get()), new PageCrafting(1, BlockCrafting.recipeBreaker).setWildcard(), new PageCrafting(2, BlockCrafting.recipePlacer).setWildcard(), new PageCrafting(3, BlockCrafting.recipeLiquidPlacer).setWildcard(), new PageCrafting(4, BlockCrafting.recipeLiquidCollector).setWildcard());
new BookletChapter("dropper", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(ActuallyBlocks.DROPPER.get()), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeDropper).setNoText());
new BookletChapter("phantomfaces", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(ActuallyBlocks.PHANTOM_LIQUIFACE.get()), new PageTextOnly(1).addTextReplacement("<range>", TileEntityPhantomFace.RANGE), new PageTextOnly(2), new PageCrafting(3, BlockCrafting.recipePhantomface), new PageCrafting(4, BlockCrafting.recipeLiquiface), new PageCrafting(5, BlockCrafting.recipeEnergyface), new PageCrafting(6, ItemCrafting.recipePhantomConnector).setNoText(), new PageCrafting(7, BlockCrafting.recipePhantomBooster)).setImportant();
new BookletChapter("phantomRedstoneface", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(ActuallyBlocks.PHANTOM_REDSTONEFACE.get()), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipePhantomRedstoneface).setNoText());
new BookletChapter("phantomBreaker", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(ActuallyBlocks.PHANTOM_BREAKER.get()), new PageTextOnly(1).addTextReplacement("<range>", TileEntityPhantomPlacer.RANGE), new PageCrafting(2, BlockCrafting.recipePhantomPlacer).setNoText(), new PageCrafting(3, BlockCrafting.recipePhantomBreaker).setNoText());
new BookletChapter("esd", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(ActuallyBlocks.INPUTTER_ADVANCED.get()), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeESD).setNoText(), new PageCrafting(3, BlockCrafting.recipeAdvancedESD).setNoText()).setSpecial();
new BookletChapter("xpSolidifier", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(ActuallyBlocks.XP_SOLIDIFIER.get()), new PageTextOnly(1).addItemsToPage(new ItemStack(ActuallyItems.SOLIDIFIED_EXPERIENCE.get())), new PageCrafting(2, BlockCrafting.recipeSolidifier).setNoText()).setImportant();
new BookletChapter("greenhouseGlass", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(ActuallyBlocks.GREENHOUSE_GLASS.get()), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeGlass));
new BookletChapter("feeder", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(ActuallyBlocks.FEEDER.get()), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeFeeder).setNoText());
new BookletChapter("crate", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(ActuallyBlocks.blockGiantChest.get()), new PageCrafting(1, BlockCrafting.recipeCrate), new PageCrafting(2, BlockCrafting.recipeCrateMedium).setNoText(), new PageCrafting(3, BlockCrafting.recipeCrateLarge).setNoText(), new PageCrafting(4, ItemCrafting.recipeCrateKeeper), new PageCrafting(5, ItemCrafting.recipeChestToCrateUpgrade), new PageCrafting(6, ItemCrafting.recipeSmallToMediumCrateUpgrade), new PageCrafting(7, ItemCrafting.recipeMediumToLargeCrateUpgrade));
new BookletChapter("rangedCollector", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(ActuallyBlocks.RANGED_COLLECTOR.get()), new PageTextOnly(1).addTextReplacement("<range>", TileEntityRangedCollector.RANGE), new PageCrafting(2, BlockCrafting.recipeRangedCollector).setNoText());
//RF Using Blocks
new BookletChapter("fireworkBox", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(ActuallyBlocks.FIREWORK_BOX.get()), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityFireworkBox.USE_PER_SHOT), new PageCrafting(2, BlockCrafting.recipeFireworkBox)).setSpecial();
new BookletChapter("batteryBox", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(ActuallyBlocks.BATTERY_BOX.get()), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeBatteryBox).setNoText()).setSpecial();
new BookletChapter("farmer", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(ActuallyBlocks.FARMER.get()), new PageTextOnly(1), new PagePicture(2, "page_farmer_crops", 95).addItemsToPage(new ItemStack(Items.WHEAT_SEEDS)).addItemsToPage(new ItemStack(ActuallyItems.CANOLA_SEED.get())), new PagePicture(3, "page_farmer_cactus", 105).addItemsToPage(new ItemStack(Blocks.CACTUS)), new PagePicture(4, "page_farmer_wart", 95).addItemsToPage(new ItemStack(Items.NETHER_WART)), new PagePicture(5, "page_farmer_reeds", 105).addItemsToPage(new ItemStack(Items.REEDS)), new PagePicture(6, "page_farmer_melons", 105).addItemsToPage(new ItemStack(Items.MELON), new ItemStack(Blocks.PUMPKIN), new ItemStack(Blocks.MELON_BLOCK)), new PagePicture(7, "page_farmer_enderlilly", 105), new PagePicture(8, "page_farmer_redorchid", 105), new PageCrafting(4, BlockCrafting.recipeFarmer).setWildcard().setNoText()).setImportant();
new BookletChapter("miner", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(ActuallyBlocks.VERTICAL_DIGGER.get()), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityVerticalDigger.ENERGY_USE_PER_BLOCK).addTextReplacement("<range>", TileEntityVerticalDigger.DEFAULT_RANGE), new PageCrafting(2, BlockCrafting.recipeMiner)).setSpecial();
new BookletChapterCoffee("coffeeMachine", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(ActuallyBlocks.COFFEE_MACHINE.get()), new PageTextOnly(1).addItemsToPage(new ItemStack(ActuallyItems.COFFEE_BEANS.get())).addTextReplacement("<rf>", TileEntityCoffeeMachine.ENERGY_USED).addTextReplacement("<coffee>", TileEntityCoffeeMachine.CACHE_USE).addTextReplacement("<water>", TileEntityCoffeeMachine.WATER_USE), new PageTextOnly(2).addItemsToPage(new ItemStack(ActuallyItems.COFFEE.get())), new PagePicture(3, "page_coffee_machine", 115), new PageCrafting(4, BlockCrafting.recipeCoffeeMachine).setWildcard().setNoText(), new PageCrafting(5, ItemCrafting.recipeCup).setNoText()).setImportant();
List<IBookletPage> list = new ArrayList<>();
list.add(new PageTextOnly(1).addTextReplacement("<rf>", TileEntityCrusher.ENERGY_USE));
list.add(new PageCrafting(2, BlockCrafting.recipeCrusher).setWildcard().setNoText());
list.add(new PageCrafting(3, BlockCrafting.recipeDoubleCrusher).setWildcard().setNoText());
if (CrusherCrafting.recipeIronHorseArmor != null) {
list.add(new PageCrusherRecipe(4, CrusherCrafting.recipeIronHorseArmor).setNoText());
}
if (CrusherCrafting.recipeGoldHorseArmor != null) {
list.add(new PageCrusherRecipe(5, CrusherCrafting.recipeGoldHorseArmor).setNoText());
}
if (CrusherCrafting.recipeDiamondHorseArmor != null) {
list.add(new PageCrusherRecipe(6, CrusherCrafting.recipeDiamondHorseArmor).setNoText());
}
new BookletChapterCrusher("crusher", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(ActuallyBlocks.CRUSHER_DOUBLE.get()), list.toArray(new IBookletPage[0]));
new BookletChapter("furnaceDouble", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(ActuallyBlocks.POWERED_FURNACE.get()), new PageCrafting(1, BlockCrafting.recipeFurnace).setWildcard().addTextReplacement("<rf>", TileEntityPoweredFurnace.ENERGY_USE));
new BookletChapter("lavaFactory", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(ActuallyBlocks.LAVA_FACTORY_CONTROLLER.get()), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityLavaFactoryController.ENERGY_USE), new PagePicture(2, "page_lava_factory", 0).setNoText(), new PageCrafting(3, BlockCrafting.recipeLavaFactory).setNoText(), new PageCrafting(4, BlockCrafting.recipeCasing).setNoText());
new BookletChapter("energizer", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(ActuallyBlocks.ENERGIZER.get()), new PageCrafting(1, BlockCrafting.recipeEnergizer), new PageCrafting(2, BlockCrafting.recipeEnervator));
// new BookletChapter("repairer", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockItemRepairer.get()), new PageCrafting(1, BlockCrafting.recipeRepairer).addTextReplacement("<rf>", TileEntityItemRepairer.ENERGY_USE));
new BookletChapter("longRangeBreaker", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(ActuallyBlocks.LONG_RANGE_BREAKER.get()), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityLongRangeBreaker.ENERGY_USE).addTextReplacement("<range>", TileEntityLongRangeBreaker.RANGE), new PageCrafting(2, BlockCrafting.recipeDirectionalBreaker).setWildcard());
new BookletChapter("playerInterface", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(ActuallyBlocks.PLAYER_INTERFACE.get()), new PageTextOnly(1).addTextReplacement("<range>", TileEntityPlayerInterface.DEFAULT_RANGE), new PageCrafting(2, BlockCrafting.recipePlayerInterface).setNoText()).setSpecial();
new BookletChapter("displayStand", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(ActuallyBlocks.DISPLAY_STAND.get()), new PageTextOnly(1), new PageTextOnly(2), new PageCrafting(3, BlockCrafting.recipeDisplayStand).setNoText()).setSpecial();
new BookletChapter("shockSuppressor", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(ActuallyBlocks.SHOCK_SUPPRESSOR.get()), new PageTextOnly(1).addTextReplacement("<range>", TileEntityShockSuppressor.RANGE).addTextReplacement("<rf>", TileEntityShockSuppressor.USE_PER), new PageCrafting(2, BlockCrafting.recipeShockSuppressor));
//RF Generating Blocks
// new BookletChapter("solarPanel", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(ActuallyBlocks.blockFurnaceSolar.get()), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityFurnaceSolar.PRODUCE), new PageCrafting(2, BlockCrafting.recipeSolar).setNoText());
new BookletChapter("heatCollector", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(ActuallyBlocks.HEAT_COLLECTOR.get()), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityHeatCollector.ENERGY_PRODUCE).addTextReplacement("<min>", TileEntityHeatCollector.BLOCKS_NEEDED), new PageCrafting(2, BlockCrafting.recipeHeatCollector).setNoText());
new BookletChapter("canola", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(ActuallyBlocks.FERMENTING_BARREL.get()), new PageTextOnly(1).addItemsToPage(new ItemStack(ActuallyItems.CANOLA.get())).addItemsToPage(new ItemStack(ActuallyItems.CANOLA_SEED.get())).addFluidToPage(InitFluids.fluidCanolaOil), new PageTextOnly(2).addFluidToPage(InitFluids.fluidRefinedCanolaOil).addFluidToPage(InitFluids.fluidCrystalOil).addFluidToPage(InitFluids.fluidEmpoweredOil), new PageCrafting(3, BlockCrafting.recipeCanolaPress).setNoText(), new PageCrafting(4, BlockCrafting.recipeFermentingBarrel), new PageCrafting(5, BlockCrafting.recipeOilGen), new PageReconstructor(6, LensRecipeHandler.recipeCrystallizedCanolaSeed).setNoText(), new PageEmpowerer(7, EmpowererHandler.recipeEmpoweredCanolaSeed).setNoText());
new BookletChapter("leafGen", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(ActuallyBlocks.LEAF_GENERATOR.get()), new PageTextOnly(1).addTextReplacement("<rf>", ConfigIntValues.LEAF_GENERATOR_CF_PER_LEAF.getValue()).addTextReplacement("<range>", ConfigIntValues.LEAF_GENERATOR_AREA.getValue()), new PageCrafting(2, BlockCrafting.recipeLeafGen)).setImportant();
new BookletChapter("bioReactor", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(ActuallyBlocks.BIOREACTOR.get()), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeBioReactor).setNoText()).setSpecial();
//No RF Using Items
chaptersIntroduction[9] = new BookletChapter("goggles", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(ActuallyItems.ENGINEER_GOGGLES.get()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeGoggles).setNoText(), new PageCrafting(3, ItemCrafting.recipeGogglesAdvanced).setNoText()).setImportant();
new BookletChapter("bags", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(ActuallyItems.BAG.get()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeBag), new PageCrafting(3, ItemCrafting.recipeVoidBag).setNoText()).setImportant();
new BookletChapter("wings", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(ActuallyItems.WINGS_OF_THE_BATS.get()), new PageTextOnly(1).addItemsToPage(new ItemStack(ActuallyItems.BAT_WING.get())).addTextReplacement("<secs>", ItemWingsOfTheBats.MAX_FLY_TIME / 20), new PageCrafting(2, ItemCrafting.recipeWings).setNoText()).setSpecial();
new BookletChapter("foods", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(ActuallyItems.FOOD.get(), 1, TheFoods.HAMBURGER.ordinal()), new PageCrafting(1, FoodCrafting.recipeBacon).setNoText(), new PageFurnace(2, new ItemStack(ActuallyItems.FOOD.get(), 1, TheFoods.RICE_BREAD.ordinal())).setNoText(), new PageCrafting(3, FoodCrafting.recipeHamburger).setNoText(), new PageCrafting(4, FoodCrafting.recipeBigCookie).setNoText(), new PageCrafting(5, FoodCrafting.recipeSubSandwich).setNoText(), new PageCrafting(6, FoodCrafting.recipeFrenchFry).setNoText(), new PageCrafting(7, FoodCrafting.recipeFrenchFries).setNoText(), new PageCrafting(8, FoodCrafting.recipeFishNChips).setNoText(), new PageCrafting(9, FoodCrafting.recipeCheese).setNoText(), new PageCrafting(10, FoodCrafting.recipePumpkinStew).setNoText(), new PageCrafting(11, FoodCrafting.recipeCarrotJuice).setNoText(), new PageCrafting(12, FoodCrafting.recipeSpaghetti).setNoText(), new PageCrafting(13, FoodCrafting.recipeNoodle).setNoText(), new PageCrafting(14, FoodCrafting.recipeChocolate).setNoText(), new PageCrafting(15, FoodCrafting.recipeChocolateCake).setNoText(), new PageCrafting(16, FoodCrafting.recipeToast).setNoText(), new PageFurnace(17, new ItemStack(ActuallyItems.FOOD.get(), 1, TheFoods.BAGUETTE.ordinal())).setNoText(), new PageCrafting(18, FoodCrafting.recipeChocolateToast).setNoText(), new PageCrafting(1, FoodCrafting.recipePizza).setNoText());
new BookletChapter("leafBlower", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(ActuallyItems.LEAF_BLOWER_ADVANCED.get()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeLeafBlower).setNoText(), new PageCrafting(3, ItemCrafting.recipeLeafBlowerAdvanced).setNoText()).setImportant();
new BookletChapter("playerProbe", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(ActuallyItems.PLAYER_PROBE.get()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipePlayerProbe).setNoText()).setSpecial();
ArrayList<BookletPage> aiotPages = new ArrayList<>();
aiotPages.add(new PageTextOnly(aiotPages.size() + 1));
for (IRecipe recipe : ToolCrafting.RECIPES_PAXELS) {
aiotPages.add(new PageCrafting(aiotPages.size() + 1, recipe).setWildcard().setNoText());
}
new BookletChapter("aiots", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(ActuallyItems.emeraldPaxel.get()), aiotPages.toArray(new BookletPage[aiotPages.size()])).setImportant();
new BookletChapter("jams", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(ActuallyItems.JAM.get()), new PageTextOnly(1).addItemsToPage(new ItemStack(ActuallyItems.JAM.get(), 1, Util.WILDCARD)), new PagePicture(2, "page_jam_house", 150), new PageTextOnly(3));
ArrayList<BookletPage> potionRingPages = new ArrayList<>();
potionRingPages.add(new PageTextOnly(potionRingPages.size() + 1));
for (IRecipe recipe : ItemCrafting.RECIPES_POTION_RINGS) {
potionRingPages.add(new PageCrafting(potionRingPages.size() + 1, recipe).setNoText());
}
new BookletChapter("potionRings", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(ActuallyItems.POTION_RING.get()), potionRingPages.toArray(new BookletPage[potionRingPages.size()]));
new BookletChapter("itemFilter", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(ActuallyItems.FILTER.get()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeFilter).setNoText()).setImportant();
//RF Using Items
new BookletChapter("drill", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(ActuallyItems.DRILL.get(), 1, TheColoredLampColors.LIGHT_BLUE.ordinal()), new PageTextOnly(1), new PageTextOnly(2), new PageCrafting(3, ItemCrafting.recipeDrill).setNoText(), new PageCrafting(4, ItemCrafting.RECIPES_DRILL_COLORING), new PageCrafting(4, ItemCrafting.recipeDrillCore).setNoText(), new PageCrafting(5, ItemCrafting.recipeDrillSpeedI).setNoText(), new PageCrafting(6, ItemCrafting.recipeDrillSpeedII).setNoText(), new PageCrafting(7, ItemCrafting.recipeDrillSpeedIII).setNoText(), new PageCrafting(8, ItemCrafting.recipeDrillFortuneI).setNoText(), new PageCrafting(9, ItemCrafting.recipeDrillFortuneII).setNoText(), new PageCrafting(10, ItemCrafting.recipeDrillSilk).setNoText(), new PageCrafting(11, ItemCrafting.recipeDrillThree).setNoText(), new PageCrafting(12, ItemCrafting.recipeDrillFive).setNoText(), new PageCrafting(13, ItemCrafting.recipeDrillPlacing).setNoText()).setSpecial();
new BookletChapter("fillingWand", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(ActuallyItems.FILLING_WAND.get()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeFillingWand).setNoText()).setSpecial();
new BookletChapter("staff", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(ActuallyItems.TELE_STAFF.get()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeStaff).setNoText()).setImportant();
new BookletChapter("magnetRing", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(ActuallyItems.MAGNET_RING.get()), new PageCrafting(1, ItemCrafting.recipeMagnetRing));
new BookletChapter("growthRing", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(ActuallyItems.GROWTH_RING.get()), new PageCrafting(1, ItemCrafting.recipeGrowthRing));
new BookletChapter("waterRemovalRing", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(ActuallyItems.WATER_REMOVAL_RING.get()), new PageCrafting(1, ItemCrafting.recipeWaterRing));
new BookletChapter("batteries", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(ActuallyItems.BATTERY_TRIPLE.get()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeBattery).setNoText(), new PageCrafting(3, ItemCrafting.recipeBatteryDouble).setNoText(), new PageCrafting(4, ItemCrafting.recipeBatteryTriple).setNoText(), new PageCrafting(5, ItemCrafting.recipeBatteryQuadruple).setNoText(), new PageCrafting(6, ItemCrafting.recipeBatteryQuintuple).setNoText());
//Updates and infos
new BookletChapter("changelog", ActuallyAdditionsAPI.entryUpdatesAndInfos, new ItemStack(Items.CLOCK), new PageLinkButton(1, UpdateChecker.CHANGELOG_LINK));
new BookletChapter("curse", ActuallyAdditionsAPI.entryUpdatesAndInfos, new ItemStack(Items.FLINT_AND_STEEL), new PageLinkButton(1, "http://ellpeck.de/actadd"));
new BookletChapter("patreon", ActuallyAdditionsAPI.entryUpdatesAndInfos, new ItemStack(ActuallyItems.EMERADIC_CRYSTAL.get(), 1), new PageLinkButton(1, "http://patreon.com/Ellpeck"), new PagePicture(2, "page_patreon", 153)).setImportant();
new BookletChapter("website", ActuallyAdditionsAPI.entryUpdatesAndInfos, new ItemStack(ActuallyItems.ITEM_BOOKLET.get()), new PageLinkButton(1, "http://ellpeck.de"));
//Trials
chaptersIntroduction[10] = new BookletChapter("trialsIntro", ActuallyAdditionsAPI.entryTrials, new ItemStack(Items.GOLD_INGOT), new PageTextOnly(1), new PageTextOnly(2)).setSpecial();
new BookletChapterTrials("crystalProduction", new ItemStack(ActuallyItems.EMERADIC_CRYSTAL.get()), false);
new BookletChapterTrials("leatherProduction", new ItemStack(Items.LEATHER), false);
new BookletChapterTrials("crystalOil", FluidUtil.getFilledBucket(new FluidStack(InitFluids.fluidCrystalOil, FluidAttributes.BUCKET_VOLUME)), false);
new BookletChapterTrials("autoDisenchanter", new ItemStack(ActuallyItems.DISENCHANTING_LENS.get()), false);
new BookletChapterTrials("empoweredOil", FluidUtil.getFilledBucket(new FluidStack(InitFluids.fluidEmpoweredOil, FluidAttributes.BUCKET_VOLUME)), false);
new BookletChapterTrials("mobFarm", new ItemStack(Items.ROTTEN_FLESH), false);
new BookletChapterTrials("empowererAutomation", new ItemStack(ActuallyBlocks.EMPOWERER.get()), false);
*/
}
}
///*
// * This file ("InitBooklet.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet;
//
//import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
//import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
//import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
//import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
//import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
//import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
//import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors;
//import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
//import de.ellpeck.actuallyadditions.mod.booklet.chapter.BookletChapter;
//import de.ellpeck.actuallyadditions.mod.booklet.chapter.BookletChapterCoffee;
//import de.ellpeck.actuallyadditions.mod.booklet.chapter.BookletChapterCrusher;
//import de.ellpeck.actuallyadditions.mod.booklet.chapter.BookletChapterTrials;
//import de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntry;
//import de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntryAllItems;
//import de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntryTrials;
//import de.ellpeck.actuallyadditions.mod.booklet.page.*;
//import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
//import de.ellpeck.actuallyadditions.mod.crafting.*;
//import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
//import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
//import de.ellpeck.actuallyadditions.mod.items.ItemWingsOfTheBats;
//import de.ellpeck.actuallyadditions.mod.items.lens.LensDisenchanting;
//import de.ellpeck.actuallyadditions.mod.items.lens.LensRecipeHandler;
//import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods;
//import de.ellpeck.actuallyadditions.mod.tile.*;
//import de.ellpeck.actuallyadditions.mod.update.UpdateChecker;
//import de.ellpeck.actuallyadditions.mod.util.Util;
//import net.minecraft.block.Blocks;
//import net.minecraft.fluid.Fluid;
//import net.minecraft.item.ItemStack;
//import net.minecraft.item.Items;
//import net.minecraft.item.crafting.IRecipe;
//import net.minecraft.item.crafting.Ingredient;
//import net.minecraftforge.fluids.FluidAttributes;
//import net.minecraftforge.fluids.FluidStack;
//import net.minecraftforge.fluids.FluidUtil;
//
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.Collections;
//import java.util.List;
//
//public final class InitBooklet {
//
// public static BookletChapter[] chaptersIntroduction = new BookletChapter[11];
//
// public static void init() {
// ActuallyAdditionsAPI.entryAllAndSearch = new BookletEntryAllItems("allAndSearch").setImportant();
// ActuallyAdditionsAPI.entryTrials = new BookletEntryTrials("trials");
//
// ActuallyAdditionsAPI.entryGettingStarted = new BookletEntry("gettingStarted").setImportant();
// ActuallyAdditionsAPI.entryReconstruction = new BookletEntry("reconstruction");
// ActuallyAdditionsAPI.entryLaserRelays = new BookletEntry("laserRelays").setSpecial();
// ActuallyAdditionsAPI.entryFunctionalNonRF = new BookletEntry("functionalNoRF");
// ActuallyAdditionsAPI.entryFunctionalRF = new BookletEntry("functionalRF");
// ActuallyAdditionsAPI.entryGeneratingRF = new BookletEntry("generatingRF");
// ActuallyAdditionsAPI.entryItemsNonRF = new BookletEntry("itemsNoRF");
// ActuallyAdditionsAPI.entryItemsRF = new BookletEntry("itemsRF");
// ActuallyAdditionsAPI.entryMisc = new BookletEntry("misc");
// ActuallyAdditionsAPI.entryUpdatesAndInfos = new BookletEntry("updatesAndInfos").setSpecial();
//
// initChapters();
//
// int chapCount = 0;
// int pageCount = 0;
// int infoCount = 0;
// for (IBookletEntry entry : ActuallyAdditionsAPI.BOOKLET_ENTRIES) {
// for (IBookletChapter chapter : entry.getAllChapters()) {
// if (!ActuallyAdditionsAPI.ALL_CHAPTERS.contains(chapter)) {
// ActuallyAdditionsAPI.ALL_CHAPTERS.add(chapter);
// chapCount++;
//
// for (IBookletPage page : chapter.getAllPages()) {
// pageCount++;
//
// List<ItemStack> items = new ArrayList<>();
// page.getItemStacksForPage(items);
// List<FluidStack> fluids = new ArrayList<>();
// page.getFluidStacksForPage(fluids);
//
// if (items != null && !items.isEmpty() || fluids != null && !fluids.isEmpty()) {
// if (!ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA.contains(page)) {
// ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA.add(page);
// infoCount++;
// }
// }
// }
// }
// }
// }
//
// Collections.sort(ActuallyAdditionsAPI.BOOKLET_ENTRIES, (entry1, entry2) -> {
// Integer prio1 = entry1.getSortingPriority();
// Integer prio2 = entry2.getSortingPriority();
// return prio2.compareTo(prio1);
// });
// Collections.sort(ActuallyAdditionsAPI.ALL_CHAPTERS, (chapter1, chapter2) -> {
// Integer prio1 = chapter1.getSortingPriority();
// Integer prio2 = chapter2.getSortingPriority();
// return prio2.compareTo(prio1);
// });
// Collections.sort(ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA, (page1, page2) -> {
// Integer prio1 = page1.getSortingPriority();
// Integer prio2 = page2.getSortingPriority();
// return prio2.compareTo(prio1);
// });
//
// ActuallyAdditions.LOGGER.info("Registered a total of " + chapCount + " booklet chapters, where " + infoCount + " out of " + pageCount + " booklet pages contain information about items or fluids!");
// }
//
// private static void initChapters() {
// /*
// //Getting Started
// chaptersIntroduction[0] = new BookletChapter("bookTutorial", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(ActuallyItems.ITEM_BOOKLET.get()), new PageTextOnly(1), new PageTextOnly(2), new PageTextOnly(3), new PageCrafting(4, ItemCrafting.recipeBook).setNoText());
// // chaptersIntroduction[1] = new BookletChapter("videoGuide", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitItems.itemMisc.get(), 1, TheMiscItems.YOUTUBE_ICON.ordinal()), new PageLinkButton(1, "https://www.youtube.com/watch?v=fhjz0Ew56pM"), new PageLinkButton(2, "https://www.youtube.com/playlist?list=PLJeFZ64pT89MrTRZYzD_rtHFajPVlt6cF")).setImportant();
// new BookletChapter("intro", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(ActuallyItems.ITEM_BOOKLET.get()), new PageTextOnly(1), new PageTextOnly(2), new PageTextOnly(3));
// ArrayList<BookletPage> crystalPages = new ArrayList<>();
// crystalPages.addAll(Arrays.asList(new PageTextOnly(1).addTextReplacement("<rf>", TileEntityAtomicReconstructor.ENERGY_USE), new PageTextOnly(2), new PageTextOnly(3), new PagePicture(4, "page_atomic_reconstructor", 0).setNoText(), new PageTextOnly(5), new PageCrafting(6, BlockCrafting.recipeAtomicReconstructor).setWildcard()));
// for (int i = 0; i < LensRecipeHandler.MAIN_PAGE_RECIPES.size(); i++) {
// crystalPages.add(new PageReconstructor(7 + i, LensRecipeHandler.MAIN_PAGE_RECIPES.get(i)).setNoText());
// }
// crystalPages.add(new PageCrafting(crystalPages.size() + 1, MiscCrafting.RECIPES_CRYSTALS).setNoText());
// crystalPages.add(new PageCrafting(crystalPages.size() + 1, MiscCrafting.RECIPES_CRYSTAL_BLOCKS).setNoText());
// chaptersIntroduction[2] = new BookletChapter("engineerHouse", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(Items.EMERALD), new PageTextOnly(1), new PagePicture(2, "page_engineer_house", 145));
// chaptersIntroduction[6] = new BookletChapter("crystals", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(ActuallyBlocks.ATOMIC_RECONSTRUCTOR.get()), crystalPages.toArray(new BookletPage[crystalPages.size()])).setSpecial();
// chaptersIntroduction[5] = new BookletChapter("coalGen", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(ActuallyBlocks.COAL_GENERATOR.get()), new PageTextOnly(1).addTextReplacement("<rf>", ConfigIntValues.COAL_GENERATOR_CF_PRODUCTION.getValue()), new PageCrafting(2, BlockCrafting.recipeCoalGen).setWildcard().setNoText());
// ArrayList<BookletPage> empowererPages = new ArrayList<>();
// empowererPages.addAll(Arrays.asList(new PageTextOnly(1), new PagePicture(2, "page_empowerer", 137), new PageCrafting(3, BlockCrafting.recipeEmpowerer), new PageCrafting(4, BlockCrafting.recipeDisplayStand)));
// for (int i = 0; i < EmpowererHandler.MAIN_PAGE_RECIPES.size(); i++) {
// empowererPages.add(new PageEmpowerer(7 + i, EmpowererHandler.MAIN_PAGE_RECIPES.get(i)).setNoText());
// }
// empowererPages.add(new PageCrafting(empowererPages.size() + 1, MiscCrafting.RECIPES_EMPOWERED_CRYSTALS).setNoText());
// empowererPages.add(new PageCrafting(empowererPages.size() + 1, MiscCrafting.RECIPES_EMPOWERED_CRYSTAL_BLOCKS).setNoText());
// new BookletChapter("empowerer", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(ActuallyBlocks.EMPOWERER.get()), empowererPages.toArray(new BookletPage[empowererPages.size()])).setSpecial();
// new BookletChapter("craftingIngs", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(ActuallyItems.COIL.get()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeCoil).setNoText(), new PageCrafting(3, ItemCrafting.recipeCoilAdvanced).setNoText(), new PageCrafting(4, BlockCrafting.recipeCase).setNoText(), new PageCrafting(5, BlockCrafting.recipeEnderPearlBlock).setNoText(), new PageCrafting(6, BlockCrafting.recipeEnderCase).setNoText(), new PageCrafting(7, ItemCrafting.recipeRing).setNoText(), new PageCrafting(8, ItemCrafting.recipeKnifeHandle).setNoText(), new PageCrafting(9, ItemCrafting.recipeKnifeBlade).setNoText(), new PageCrafting(10, ItemCrafting.recipeKnife).setNoText(), new PageCrafting(11, ItemCrafting.recipeDough).setNoText(), new PageCrafting(12, ItemCrafting.recipeRiceDough).setNoText(), new PageCrafting(13, BlockCrafting.recipeIronCase).setNoText(), new PageCrafting(14, ItemCrafting.recipeLens).setNoText());
// chaptersIntroduction[4] = new BookletChapter("rf", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(Items.REDSTONE), new PageTextOnly(1), new PageTextOnly(2)).setImportant();
//
// //Miscellaneous
// new BookletChapter("worms", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyItems.WORM.get()), new PageTextOnly(1).addItemsToPage(new ItemStack(ActuallyItems.WORM.get())), new PagePicture(2, "page_worms", 145)).setImportant();
// new BookletChapter("lushCaves", ActuallyAdditionsAPI.entryMisc, new ItemStack(Blocks.STONE), new PageTextOnly(1), new PagePicture(2, "page_lush_caves", 0).setNoText());
// new BookletChapter("crystalClusters", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyBlocks.EMERADIC_CRYSTAL_CLUSTER.get()), new PageTextOnly(1).addItemsToPage(WorldGenLushCaves.CRYSTAL_CLUSTERS), new PageCrafting(2, MiscCrafting.RECIPES_CRYSTAL_SHARDS).setNoText(), new PageCrafting(3, MiscCrafting.RECIPES_CRYSTAL_SHARDS_BACK).setNoText()).setSpecial();
// new BookletChapter("banners", ActuallyAdditionsAPI.entryMisc, new ItemStack(Items.BLUE_BANNER, 1), new PageTextOnly(1));
// new BookletChapter("miscDecorStuffsAndThings", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyBlocks.ETHETIC_GREEN_BLOCK.get()), new PageTextOnly(1), new PageReconstructor(2, LensRecipeHandler.recipeWhiteWall).setNoText(), new PageReconstructor(3, LensRecipeHandler.recipeGreenWall).setNoText());
// chaptersIntroduction[3] = new BookletChapter("quartz", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyItems.BLACK_QUARTZ.get()), new PageTextOnly(1).addItemsToPage(new ItemStack(ActuallyBlocks.blockMisc, 1, TheMiscBlocks.ORE_QUARTZ.ordinal())).addTextReplacement("<lowest>", AAWorldGen.QUARTZ_MIN).addTextReplacement("<highest>", AAWorldGen.QUARTZ_MAX), new PageTextOnly(2).addItemsToPage(new ItemStack(ActuallyItems.itemBlackQuartz.get())), new PageCrafting(3, BlockCrafting.recipeQuartzBlock).setNoText(), new PageCrafting(4, BlockCrafting.recipeQuartzPillar).setNoText(), new PageCrafting(5, BlockCrafting.recipeQuartzChiseled).setNoText());
// // new BookletChapter("cloud", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyBlocks.blockSmileyCloud), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeSmileyCloud).setWildcard()).setSpecial();
// new BookletChapter("coalStuff", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyItems.TINY_COAL.get()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeTinyCoal).setNoText(), new PageCrafting(3, ItemCrafting.recipeTinyChar).setNoText(), new PageCrafting(4, BlockCrafting.recipeBlockChar).setNoText());
// ArrayList<BookletPage> lampPages = new ArrayList<>();
// lampPages.add(new PageTextOnly(lampPages.size() + 1));
// lampPages.add(new PageTextOnly(lampPages.size() + 1));
// lampPages.add(new PageCrafting(lampPages.size() + 1, BlockCrafting.recipePowerer).setWildcard().setNoText());
// for (IRecipe recipe : BlockCrafting.RECIPES_LAMPS) {
// lampPages.add(new PageCrafting(lampPages.size() + 1, recipe).setNoText());
// }
// new BookletChapter("lamps", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyBlocks.blockColoredLampOn.get(), 1, TheColoredLampColors.GREEN.ordinal()), lampPages.toArray(new BookletPage[lampPages.size()]));
// new BookletChapter("enderStar", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyItems.ENDER_STAR.get()), new PageCrafting(1, ItemCrafting.recipeEnderStar));
// new BookletChapter("spawnerShard", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyItems.SPAWNER_SHARD.get()), new PageTextOnly(1).addItemsToPage(new ItemStack(ActuallyItems.SPAWNER_SHARD.get())));
// // new BookletChapter("treasureChest", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitBlocks.blockTreasureChest.get()), new PagePicture(1, "page_treasure_chest", 150).addItemsToPage(new ItemStack(InitBlocks.blockTreasureChest.get())), new PageTextOnly(2)).setSpecial();
// new BookletChapter("hairBalls", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyItems.HAIRY_BALL.get()), new PagePicture(1, "page_fur_balls", 110).addItemsToPage(new ItemStack(ActuallyItems.HAIRY_BALL.get())), new PageTextOnly(2)).setSpecial();
// // new BookletChapter("blackLotus", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitBlocks.blockBlackLotus.get()), new PageTextOnly(1).addItemsToPage(new ItemStack(InitBlocks.blockBlackLotus.get())), new PageCrafting(2, ItemCrafting.recipeBlackDye));
// new BookletChapter("waterBowl", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyItems.WATER_BOWL.get()), new PageTextOnly(1).addItemsToPage(new ItemStack(ActuallyItems.WATER_BOWL.get())));
// new BookletChapter("tinyTorch", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyBlocks.TINY_TORCH.get()), new PageCrafting(1, BlockCrafting.recipesTinyTorch).setWildcard()).setSpecial();
//
// //Reconstruction
// chaptersIntroduction[7] = new BookletChapter("reconstructorLenses", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(ActuallyItems.LENS.get()), new PageTextOnly(1)).setImportant();
// new BookletChapter("additionalRecipes", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(Items.LEATHER), new PageReconstructor(1, LensRecipeHandler.recipeSoulSand).setNoText(), new PageReconstructor(2, LensRecipeHandler.recipeLeather).setNoText(), new PageReconstructor(3, LensRecipeHandler.recipeNetherWart).setNoText(), new PageReconstructor(4, LensRecipeHandler.recipePrismarine).setNoText()).setSpecial();
// new BookletChapter("bookSplitting", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(Items.ENCHANTED_BOOK), new PageTextOnly(1), new PageReconstructor(2, new LensConversionRecipe(Ingredient.fromItem(Items.ENCHANTED_BOOK), new ItemStack(Items.ENCHANTED_BOOK), 0, ActuallyAdditionsAPI.lensDefaultConversion)).setNoText());
// new BookletChapter("lensColor", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(ActuallyItems.COLOR_LENS.get()), new PageTextOnly(1), new PageReconstructor(2, LensRecipeHandler.recipeColorLens).setNoText());
// new BookletChapter("lensDeath", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(ActuallyItems.DAMAGE_LENS.get()), new PageTextOnly(1), new PageReconstructor(2, LensRecipeHandler.recipeDamageLens).setNoText());
// new BookletChapter("lensMoreDeath", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(ActuallyItems.MORE_DAMAGE_LENS.get()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeLensMoreDeath).setNoText());
// new BookletChapter("lensDetonation", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(ActuallyItems.EXPLOSION_LENS.get()), new PageTextOnly(1), new PageReconstructor(2, LensRecipeHandler.recipeExplosionLens).setNoText());
// new BookletChapter("lensDisenchanting", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(ActuallyItems.DISENCHANTING_LENS.get()), new PageTextOnly(1).addTextReplacement("<energy>", LensDisenchanting.ENERGY_USE), new PageCrafting(2, ItemCrafting.recipeDisenchantingLens).setNoText()).setSpecial();
// new BookletChapter("lensMining", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(ActuallyItems.MINING_LENS.get()), new PageTextOnly(1).addTextReplacement("<energy>", ConfigIntValues.MINING_LENS_USE.getValue()), new PageCrafting(2, ItemCrafting.recipeMiningLens).setNoText()).setImportant();
//
// //Laser Relays
// chaptersIntroduction[8] = new BookletChapter("laserIntro", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(ActuallyItems.LASER_WRENCH.get()), new PageTextOnly(1), new PageTextOnly(2).addTextReplacement("<range>", TileEntityLaserRelay.MAX_DISTANCE), new PageCrafting(3, ItemCrafting.recipeLaserWrench)).setImportant();
// new BookletChapter("laserRelays", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(ActuallyBlocks.LASER_RELAY.get()), new PageTextOnly(1), new PageTextOnly(2).addTextReplacement("<cap1>", TileEntityLaserRelayEnergy.CAP).addTextReplacement("<cap2>", TileEntityLaserRelayEnergyAdvanced.CAP).addTextReplacement("<cap3>", TileEntityLaserRelayEnergyExtreme.CAP), new PagePicture(3, "page_laser_relay", 0).setNoText(), new PageCrafting(4, BlockCrafting.recipeLaserRelay).setWildcard().setNoText(), new PageCrafting(5, BlockCrafting.recipeLaserRelayAdvanced).setWildcard().setNoText(), new PageCrafting(6, BlockCrafting.recipeLaserRelayExtreme).setWildcard().setNoText());
// new BookletChapter("fluidLaser", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(ActuallyBlocks.LASER_RELAY_FLUIDS.get()), new PageTextOnly(1), new PageReconstructor(2, LensRecipeHandler.recipeFluidLaser).setWildcard().setNoText());
// new BookletChapter("itemRelays", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(ActuallyBlocks.LASER_RELAY_ITEM.get()), new PageTextOnly(1), new PageReconstructor(2, LensRecipeHandler.recipeItemLaser).setWildcard().setNoText()).setSpecial();
// new BookletChapter("itemInterfaces", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(ActuallyBlocks.ITEM_VIEWER.get()), new PageTextOnly(1), new PageTextOnly(2), new PageCrafting(3, BlockCrafting.recipeItemInterface).setNoText());
// new BookletChapter("itemRelaysAdvanced", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(ActuallyBlocks.LASER_RELAY_ITEM_ADVANCED.get()), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeLaserRelayItemWhitelist).setWildcard());
// new BookletChapter("itemInterfacesHopping", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(ActuallyBlocks.ITEM_VIEWER_HOPPING.get()), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeItemInterfaceHopping).setWildcard().setNoText());
// new BookletChapter("laserUpgradeInvisibility", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(ActuallyItems.LASER_UPGRADE_INVISIBILITY.get()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeLaserUpgradeInvisibility).setNoText()).setImportant();
// new BookletChapter("laserUpgradeRange", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(ActuallyItems.LASER_UPGRADE_RANGE.get()), new PageTextOnly(1).addTextReplacement("<def>", TileEntityLaserRelay.MAX_DISTANCE).addTextReplacement("<upgraded>", TileEntityLaserRelay.MAX_DISTANCE_RANGED), new PageCrafting(2, ItemCrafting.recipeLaserUpgradeRange).setNoText()).setImportant();
//
// //No RF Using Blocks
// new BookletChapter("breaker", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(ActuallyBlocks.BREAKER.get()), new PageCrafting(1, BlockCrafting.recipeBreaker).setWildcard(), new PageCrafting(2, BlockCrafting.recipePlacer).setWildcard(), new PageCrafting(3, BlockCrafting.recipeLiquidPlacer).setWildcard(), new PageCrafting(4, BlockCrafting.recipeLiquidCollector).setWildcard());
// new BookletChapter("dropper", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(ActuallyBlocks.DROPPER.get()), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeDropper).setNoText());
// new BookletChapter("phantomfaces", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(ActuallyBlocks.PHANTOM_LIQUIFACE.get()), new PageTextOnly(1).addTextReplacement("<range>", TileEntityPhantomFace.RANGE), new PageTextOnly(2), new PageCrafting(3, BlockCrafting.recipePhantomface), new PageCrafting(4, BlockCrafting.recipeLiquiface), new PageCrafting(5, BlockCrafting.recipeEnergyface), new PageCrafting(6, ItemCrafting.recipePhantomConnector).setNoText(), new PageCrafting(7, BlockCrafting.recipePhantomBooster)).setImportant();
// new BookletChapter("phantomRedstoneface", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(ActuallyBlocks.PHANTOM_REDSTONEFACE.get()), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipePhantomRedstoneface).setNoText());
// new BookletChapter("phantomBreaker", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(ActuallyBlocks.PHANTOM_BREAKER.get()), new PageTextOnly(1).addTextReplacement("<range>", TileEntityPhantomPlacer.RANGE), new PageCrafting(2, BlockCrafting.recipePhantomPlacer).setNoText(), new PageCrafting(3, BlockCrafting.recipePhantomBreaker).setNoText());
// new BookletChapter("esd", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(ActuallyBlocks.INPUTTER_ADVANCED.get()), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeESD).setNoText(), new PageCrafting(3, BlockCrafting.recipeAdvancedESD).setNoText()).setSpecial();
// new BookletChapter("xpSolidifier", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(ActuallyBlocks.XP_SOLIDIFIER.get()), new PageTextOnly(1).addItemsToPage(new ItemStack(ActuallyItems.SOLIDIFIED_EXPERIENCE.get())), new PageCrafting(2, BlockCrafting.recipeSolidifier).setNoText()).setImportant();
// new BookletChapter("greenhouseGlass", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(ActuallyBlocks.GREENHOUSE_GLASS.get()), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeGlass));
// new BookletChapter("feeder", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(ActuallyBlocks.FEEDER.get()), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeFeeder).setNoText());
// new BookletChapter("crate", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(ActuallyBlocks.blockGiantChest.get()), new PageCrafting(1, BlockCrafting.recipeCrate), new PageCrafting(2, BlockCrafting.recipeCrateMedium).setNoText(), new PageCrafting(3, BlockCrafting.recipeCrateLarge).setNoText(), new PageCrafting(4, ItemCrafting.recipeCrateKeeper), new PageCrafting(5, ItemCrafting.recipeChestToCrateUpgrade), new PageCrafting(6, ItemCrafting.recipeSmallToMediumCrateUpgrade), new PageCrafting(7, ItemCrafting.recipeMediumToLargeCrateUpgrade));
// new BookletChapter("rangedCollector", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(ActuallyBlocks.RANGED_COLLECTOR.get()), new PageTextOnly(1).addTextReplacement("<range>", TileEntityRangedCollector.RANGE), new PageCrafting(2, BlockCrafting.recipeRangedCollector).setNoText());
//
// //RF Using Blocks
// new BookletChapter("fireworkBox", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(ActuallyBlocks.FIREWORK_BOX.get()), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityFireworkBox.USE_PER_SHOT), new PageCrafting(2, BlockCrafting.recipeFireworkBox)).setSpecial();
// new BookletChapter("batteryBox", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(ActuallyBlocks.BATTERY_BOX.get()), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeBatteryBox).setNoText()).setSpecial();
// new BookletChapter("farmer", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(ActuallyBlocks.FARMER.get()), new PageTextOnly(1), new PagePicture(2, "page_farmer_crops", 95).addItemsToPage(new ItemStack(Items.WHEAT_SEEDS)).addItemsToPage(new ItemStack(ActuallyItems.CANOLA_SEED.get())), new PagePicture(3, "page_farmer_cactus", 105).addItemsToPage(new ItemStack(Blocks.CACTUS)), new PagePicture(4, "page_farmer_wart", 95).addItemsToPage(new ItemStack(Items.NETHER_WART)), new PagePicture(5, "page_farmer_reeds", 105).addItemsToPage(new ItemStack(Items.REEDS)), new PagePicture(6, "page_farmer_melons", 105).addItemsToPage(new ItemStack(Items.MELON), new ItemStack(Blocks.PUMPKIN), new ItemStack(Blocks.MELON_BLOCK)), new PagePicture(7, "page_farmer_enderlilly", 105), new PagePicture(8, "page_farmer_redorchid", 105), new PageCrafting(4, BlockCrafting.recipeFarmer).setWildcard().setNoText()).setImportant();
// new BookletChapter("miner", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(ActuallyBlocks.VERTICAL_DIGGER.get()), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityVerticalDigger.ENERGY_USE_PER_BLOCK).addTextReplacement("<range>", TileEntityVerticalDigger.DEFAULT_RANGE), new PageCrafting(2, BlockCrafting.recipeMiner)).setSpecial();
// new BookletChapterCoffee("coffeeMachine", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(ActuallyBlocks.COFFEE_MACHINE.get()), new PageTextOnly(1).addItemsToPage(new ItemStack(ActuallyItems.COFFEE_BEANS.get())).addTextReplacement("<rf>", TileEntityCoffeeMachine.ENERGY_USED).addTextReplacement("<coffee>", TileEntityCoffeeMachine.CACHE_USE).addTextReplacement("<water>", TileEntityCoffeeMachine.WATER_USE), new PageTextOnly(2).addItemsToPage(new ItemStack(ActuallyItems.COFFEE.get())), new PagePicture(3, "page_coffee_machine", 115), new PageCrafting(4, BlockCrafting.recipeCoffeeMachine).setWildcard().setNoText(), new PageCrafting(5, ItemCrafting.recipeCup).setNoText()).setImportant();
//
// List<IBookletPage> list = new ArrayList<>();
// list.add(new PageTextOnly(1).addTextReplacement("<rf>", TileEntityCrusher.ENERGY_USE));
// list.add(new PageCrafting(2, BlockCrafting.recipeCrusher).setWildcard().setNoText());
// list.add(new PageCrafting(3, BlockCrafting.recipeDoubleCrusher).setWildcard().setNoText());
// if (CrusherCrafting.recipeIronHorseArmor != null) {
// list.add(new PageCrusherRecipe(4, CrusherCrafting.recipeIronHorseArmor).setNoText());
// }
// if (CrusherCrafting.recipeGoldHorseArmor != null) {
// list.add(new PageCrusherRecipe(5, CrusherCrafting.recipeGoldHorseArmor).setNoText());
// }
// if (CrusherCrafting.recipeDiamondHorseArmor != null) {
// list.add(new PageCrusherRecipe(6, CrusherCrafting.recipeDiamondHorseArmor).setNoText());
// }
//
// new BookletChapterCrusher("crusher", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(ActuallyBlocks.CRUSHER_DOUBLE.get()), list.toArray(new IBookletPage[0]));
// new BookletChapter("furnaceDouble", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(ActuallyBlocks.POWERED_FURNACE.get()), new PageCrafting(1, BlockCrafting.recipeFurnace).setWildcard().addTextReplacement("<rf>", TileEntityPoweredFurnace.ENERGY_USE));
// new BookletChapter("lavaFactory", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(ActuallyBlocks.LAVA_FACTORY_CONTROLLER.get()), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityLavaFactoryController.ENERGY_USE), new PagePicture(2, "page_lava_factory", 0).setNoText(), new PageCrafting(3, BlockCrafting.recipeLavaFactory).setNoText(), new PageCrafting(4, BlockCrafting.recipeCasing).setNoText());
// new BookletChapter("energizer", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(ActuallyBlocks.ENERGIZER.get()), new PageCrafting(1, BlockCrafting.recipeEnergizer), new PageCrafting(2, BlockCrafting.recipeEnervator));
// // new BookletChapter("repairer", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockItemRepairer.get()), new PageCrafting(1, BlockCrafting.recipeRepairer).addTextReplacement("<rf>", TileEntityItemRepairer.ENERGY_USE));
// new BookletChapter("longRangeBreaker", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(ActuallyBlocks.LONG_RANGE_BREAKER.get()), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityLongRangeBreaker.ENERGY_USE).addTextReplacement("<range>", TileEntityLongRangeBreaker.RANGE), new PageCrafting(2, BlockCrafting.recipeDirectionalBreaker).setWildcard());
// new BookletChapter("playerInterface", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(ActuallyBlocks.PLAYER_INTERFACE.get()), new PageTextOnly(1).addTextReplacement("<range>", TileEntityPlayerInterface.DEFAULT_RANGE), new PageCrafting(2, BlockCrafting.recipePlayerInterface).setNoText()).setSpecial();
// new BookletChapter("displayStand", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(ActuallyBlocks.DISPLAY_STAND.get()), new PageTextOnly(1), new PageTextOnly(2), new PageCrafting(3, BlockCrafting.recipeDisplayStand).setNoText()).setSpecial();
// new BookletChapter("shockSuppressor", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(ActuallyBlocks.SHOCK_SUPPRESSOR.get()), new PageTextOnly(1).addTextReplacement("<range>", TileEntityShockSuppressor.RANGE).addTextReplacement("<rf>", TileEntityShockSuppressor.USE_PER), new PageCrafting(2, BlockCrafting.recipeShockSuppressor));
//
// //RF Generating Blocks
// // new BookletChapter("solarPanel", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(ActuallyBlocks.blockFurnaceSolar.get()), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityFurnaceSolar.PRODUCE), new PageCrafting(2, BlockCrafting.recipeSolar).setNoText());
// new BookletChapter("heatCollector", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(ActuallyBlocks.HEAT_COLLECTOR.get()), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityHeatCollector.ENERGY_PRODUCE).addTextReplacement("<min>", TileEntityHeatCollector.BLOCKS_NEEDED), new PageCrafting(2, BlockCrafting.recipeHeatCollector).setNoText());
// new BookletChapter("canola", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(ActuallyBlocks.FERMENTING_BARREL.get()), new PageTextOnly(1).addItemsToPage(new ItemStack(ActuallyItems.CANOLA.get())).addItemsToPage(new ItemStack(ActuallyItems.CANOLA_SEED.get())).addFluidToPage(InitFluids.fluidCanolaOil), new PageTextOnly(2).addFluidToPage(InitFluids.fluidRefinedCanolaOil).addFluidToPage(InitFluids.fluidCrystalOil).addFluidToPage(InitFluids.fluidEmpoweredOil), new PageCrafting(3, BlockCrafting.recipeCanolaPress).setNoText(), new PageCrafting(4, BlockCrafting.recipeFermentingBarrel), new PageCrafting(5, BlockCrafting.recipeOilGen), new PageReconstructor(6, LensRecipeHandler.recipeCrystallizedCanolaSeed).setNoText(), new PageEmpowerer(7, EmpowererHandler.recipeEmpoweredCanolaSeed).setNoText());
// new BookletChapter("leafGen", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(ActuallyBlocks.LEAF_GENERATOR.get()), new PageTextOnly(1).addTextReplacement("<rf>", ConfigIntValues.LEAF_GENERATOR_CF_PER_LEAF.getValue()).addTextReplacement("<range>", ConfigIntValues.LEAF_GENERATOR_AREA.getValue()), new PageCrafting(2, BlockCrafting.recipeLeafGen)).setImportant();
// new BookletChapter("bioReactor", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(ActuallyBlocks.BIOREACTOR.get()), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeBioReactor).setNoText()).setSpecial();
//
// //No RF Using Items
// chaptersIntroduction[9] = new BookletChapter("goggles", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(ActuallyItems.ENGINEER_GOGGLES.get()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeGoggles).setNoText(), new PageCrafting(3, ItemCrafting.recipeGogglesAdvanced).setNoText()).setImportant();
// new BookletChapter("bags", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(ActuallyItems.BAG.get()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeBag), new PageCrafting(3, ItemCrafting.recipeVoidBag).setNoText()).setImportant();
// new BookletChapter("wings", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(ActuallyItems.WINGS_OF_THE_BATS.get()), new PageTextOnly(1).addItemsToPage(new ItemStack(ActuallyItems.BAT_WING.get())).addTextReplacement("<secs>", ItemWingsOfTheBats.MAX_FLY_TIME / 20), new PageCrafting(2, ItemCrafting.recipeWings).setNoText()).setSpecial();
// new BookletChapter("foods", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(ActuallyItems.FOOD.get(), 1, TheFoods.HAMBURGER.ordinal()), new PageCrafting(1, FoodCrafting.recipeBacon).setNoText(), new PageFurnace(2, new ItemStack(ActuallyItems.FOOD.get(), 1, TheFoods.RICE_BREAD.ordinal())).setNoText(), new PageCrafting(3, FoodCrafting.recipeHamburger).setNoText(), new PageCrafting(4, FoodCrafting.recipeBigCookie).setNoText(), new PageCrafting(5, FoodCrafting.recipeSubSandwich).setNoText(), new PageCrafting(6, FoodCrafting.recipeFrenchFry).setNoText(), new PageCrafting(7, FoodCrafting.recipeFrenchFries).setNoText(), new PageCrafting(8, FoodCrafting.recipeFishNChips).setNoText(), new PageCrafting(9, FoodCrafting.recipeCheese).setNoText(), new PageCrafting(10, FoodCrafting.recipePumpkinStew).setNoText(), new PageCrafting(11, FoodCrafting.recipeCarrotJuice).setNoText(), new PageCrafting(12, FoodCrafting.recipeSpaghetti).setNoText(), new PageCrafting(13, FoodCrafting.recipeNoodle).setNoText(), new PageCrafting(14, FoodCrafting.recipeChocolate).setNoText(), new PageCrafting(15, FoodCrafting.recipeChocolateCake).setNoText(), new PageCrafting(16, FoodCrafting.recipeToast).setNoText(), new PageFurnace(17, new ItemStack(ActuallyItems.FOOD.get(), 1, TheFoods.BAGUETTE.ordinal())).setNoText(), new PageCrafting(18, FoodCrafting.recipeChocolateToast).setNoText(), new PageCrafting(1, FoodCrafting.recipePizza).setNoText());
// new BookletChapter("leafBlower", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(ActuallyItems.LEAF_BLOWER_ADVANCED.get()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeLeafBlower).setNoText(), new PageCrafting(3, ItemCrafting.recipeLeafBlowerAdvanced).setNoText()).setImportant();
// new BookletChapter("playerProbe", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(ActuallyItems.PLAYER_PROBE.get()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipePlayerProbe).setNoText()).setSpecial();
// ArrayList<BookletPage> aiotPages = new ArrayList<>();
// aiotPages.add(new PageTextOnly(aiotPages.size() + 1));
// for (IRecipe recipe : ToolCrafting.RECIPES_PAXELS) {
// aiotPages.add(new PageCrafting(aiotPages.size() + 1, recipe).setWildcard().setNoText());
// }
// new BookletChapter("aiots", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(ActuallyItems.emeraldPaxel.get()), aiotPages.toArray(new BookletPage[aiotPages.size()])).setImportant();
//
// new BookletChapter("jams", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(ActuallyItems.JAM.get()), new PageTextOnly(1).addItemsToPage(new ItemStack(ActuallyItems.JAM.get(), 1, Util.WILDCARD)), new PagePicture(2, "page_jam_house", 150), new PageTextOnly(3));
//
// ArrayList<BookletPage> potionRingPages = new ArrayList<>();
// potionRingPages.add(new PageTextOnly(potionRingPages.size() + 1));
// for (IRecipe recipe : ItemCrafting.RECIPES_POTION_RINGS) {
// potionRingPages.add(new PageCrafting(potionRingPages.size() + 1, recipe).setNoText());
// }
// new BookletChapter("potionRings", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(ActuallyItems.POTION_RING.get()), potionRingPages.toArray(new BookletPage[potionRingPages.size()]));
// new BookletChapter("itemFilter", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(ActuallyItems.FILTER.get()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeFilter).setNoText()).setImportant();
//
// //RF Using Items
// new BookletChapter("drill", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(ActuallyItems.DRILL.get(), 1, TheColoredLampColors.LIGHT_BLUE.ordinal()), new PageTextOnly(1), new PageTextOnly(2), new PageCrafting(3, ItemCrafting.recipeDrill).setNoText(), new PageCrafting(4, ItemCrafting.RECIPES_DRILL_COLORING), new PageCrafting(4, ItemCrafting.recipeDrillCore).setNoText(), new PageCrafting(5, ItemCrafting.recipeDrillSpeedI).setNoText(), new PageCrafting(6, ItemCrafting.recipeDrillSpeedII).setNoText(), new PageCrafting(7, ItemCrafting.recipeDrillSpeedIII).setNoText(), new PageCrafting(8, ItemCrafting.recipeDrillFortuneI).setNoText(), new PageCrafting(9, ItemCrafting.recipeDrillFortuneII).setNoText(), new PageCrafting(10, ItemCrafting.recipeDrillSilk).setNoText(), new PageCrafting(11, ItemCrafting.recipeDrillThree).setNoText(), new PageCrafting(12, ItemCrafting.recipeDrillFive).setNoText(), new PageCrafting(13, ItemCrafting.recipeDrillPlacing).setNoText()).setSpecial();
// new BookletChapter("fillingWand", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(ActuallyItems.FILLING_WAND.get()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeFillingWand).setNoText()).setSpecial();
// new BookletChapter("staff", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(ActuallyItems.TELE_STAFF.get()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeStaff).setNoText()).setImportant();
// new BookletChapter("magnetRing", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(ActuallyItems.MAGNET_RING.get()), new PageCrafting(1, ItemCrafting.recipeMagnetRing));
// new BookletChapter("growthRing", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(ActuallyItems.GROWTH_RING.get()), new PageCrafting(1, ItemCrafting.recipeGrowthRing));
// new BookletChapter("waterRemovalRing", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(ActuallyItems.WATER_REMOVAL_RING.get()), new PageCrafting(1, ItemCrafting.recipeWaterRing));
// new BookletChapter("batteries", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(ActuallyItems.BATTERY_TRIPLE.get()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeBattery).setNoText(), new PageCrafting(3, ItemCrafting.recipeBatteryDouble).setNoText(), new PageCrafting(4, ItemCrafting.recipeBatteryTriple).setNoText(), new PageCrafting(5, ItemCrafting.recipeBatteryQuadruple).setNoText(), new PageCrafting(6, ItemCrafting.recipeBatteryQuintuple).setNoText());
//
// //Updates and infos
// new BookletChapter("changelog", ActuallyAdditionsAPI.entryUpdatesAndInfos, new ItemStack(Items.CLOCK), new PageLinkButton(1, UpdateChecker.CHANGELOG_LINK));
// new BookletChapter("curse", ActuallyAdditionsAPI.entryUpdatesAndInfos, new ItemStack(Items.FLINT_AND_STEEL), new PageLinkButton(1, "http://ellpeck.de/actadd"));
// new BookletChapter("patreon", ActuallyAdditionsAPI.entryUpdatesAndInfos, new ItemStack(ActuallyItems.EMERADIC_CRYSTAL.get(), 1), new PageLinkButton(1, "http://patreon.com/Ellpeck"), new PagePicture(2, "page_patreon", 153)).setImportant();
// new BookletChapter("website", ActuallyAdditionsAPI.entryUpdatesAndInfos, new ItemStack(ActuallyItems.ITEM_BOOKLET.get()), new PageLinkButton(1, "http://ellpeck.de"));
//
// //Trials
// chaptersIntroduction[10] = new BookletChapter("trialsIntro", ActuallyAdditionsAPI.entryTrials, new ItemStack(Items.GOLD_INGOT), new PageTextOnly(1), new PageTextOnly(2)).setSpecial();
// new BookletChapterTrials("crystalProduction", new ItemStack(ActuallyItems.EMERADIC_CRYSTAL.get()), false);
// new BookletChapterTrials("leatherProduction", new ItemStack(Items.LEATHER), false);
// new BookletChapterTrials("crystalOil", FluidUtil.getFilledBucket(new FluidStack(InitFluids.fluidCrystalOil, FluidAttributes.BUCKET_VOLUME)), false);
// new BookletChapterTrials("autoDisenchanter", new ItemStack(ActuallyItems.DISENCHANTING_LENS.get()), false);
// new BookletChapterTrials("empoweredOil", FluidUtil.getFilledBucket(new FluidStack(InitFluids.fluidEmpoweredOil, FluidAttributes.BUCKET_VOLUME)), false);
// new BookletChapterTrials("mobFarm", new ItemStack(Items.ROTTEN_FLESH), false);
// new BookletChapterTrials("empowererAutomation", new ItemStack(ActuallyBlocks.EMPOWERER.get()), false);
//
// */
// }
//}

View file

@ -1,119 +1,119 @@
/*
* This file ("BookmarkButton.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.button;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiPage;
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.client.gui.GuiUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@OnlyIn(Dist.CLIENT)
public class BookmarkButton extends Button {
private final GuiBooklet booklet;
public IBookletPage assignedPage;
public BookmarkButton(int x, int y, GuiBooklet booklet) {
super(x, y, 16, 16, StringTextComponent.EMPTY, btn -> {
BookmarkButton button = (BookmarkButton) btn;
if (button.assignedPage != null) {
if (Screen.hasShiftDown()) {
button.assignedPage = null;
} else if (!(button.booklet instanceof GuiPage) || ((GuiPage) button.booklet).pages[0] != button.assignedPage) {
GuiPage gui = BookletUtils.createPageGui(button.booklet.previousScreen, button.booklet, button.assignedPage);
Minecraft.getInstance().setScreen(gui);
}
} else {
if (button.booklet instanceof GuiPage) {
button.assignedPage = ((GuiPage) button.booklet).pages[0];
}
}
});
this.booklet = booklet;
}
@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) {
if (this.visible) {
Minecraft.getInstance().getTextureManager().bind(GuiBooklet.RES_LOC_GADGETS);
GlStateManager._color4f(1.0F, 1.0F, 1.0F, 1.0F);
this.isHovered = mouseX >= this.x && mouseY >= this.y && this.x < this.x + this.width && this.y < this.y + this.height;
int offset = this.isHovered
? 1
: 0;
GlStateManager._enableBlend();
GlStateManager._blendFuncSeparate(770, 771, 1, 0);
GlStateManager._blendFunc(770, 771);
int renderHeight = 25;
this.blit(matrices, this.x, this.y, 224 + (this.assignedPage == null
? 0
: 16), 14 - renderHeight + offset * renderHeight, this.width, renderHeight);
// TODO: FIX THIS
// this.mouseDragged(minecraft, mouseX, mouseY);
if (this.assignedPage != null) {
ItemStack display = this.assignedPage.getChapter().getDisplayItemStack();
if (StackUtil.isValid(display)) {
GlStateManager._pushMatrix();
AssetUtil.renderStackToGui(display, this.x + 2, this.y + 1, 0.725F);
GlStateManager._popMatrix();
}
}
}
}
public void drawHover(MatrixStack stack, int mouseX, int mouseY) {
if (this.isMouseOver(mouseX, mouseY)) {
List<String> list = new ArrayList<>();
if (this.assignedPage != null) {
IBookletChapter chapter = this.assignedPage.getChapter();
list.add(TextFormatting.GOLD + chapter.getLocalizedName() + ", Page " + (chapter.getPageIndex(this.assignedPage) + 1));
list.add(StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".bookmarkButton.bookmark.openDesc"));
list.add(TextFormatting.ITALIC + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".bookmarkButton.bookmark.removeDesc"));
} else {
list.add(TextFormatting.GOLD + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".bookmarkButton.noBookmark.name"));
if (this.booklet instanceof GuiPage) {
list.add(StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".bookmarkButton.noBookmark.pageDesc"));
} else {
list.add(StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".bookmarkButton.noBookmark.notPageDesc"));
}
}
Minecraft mc = Minecraft.getInstance();
GuiUtils.drawHoveringText(stack, list.stream().map(StringTextComponent::new).collect(Collectors.toList()), mouseX, mouseY, mc.screen.width, mc.screen.height, -1, mc.font);
}
}
}
///*
// * This file ("BookmarkButton.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet.button;
//
//import com.mojang.blaze3d.matrix.MatrixStack;
//import com.mojang.blaze3d.platform.GlStateManager;
//import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
//import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
//import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
//import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiPage;
//import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
//import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
//import de.ellpeck.actuallyadditions.mod.util.StackUtil;
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
//import net.minecraft.client.Minecraft;
//import net.minecraft.client.gui.screen.Screen;
//import net.minecraft.client.gui.widget.button.Button;
//import net.minecraft.item.ItemStack;
//import net.minecraft.util.text.StringTextComponent;
//import net.minecraft.util.text.TextFormatting;
//import net.minecraftforge.api.distmarker.Dist;
//import net.minecraftforge.api.distmarker.OnlyIn;
//import net.minecraftforge.fml.client.gui.GuiUtils;
//
//import java.util.ArrayList;
//import java.util.List;
//import java.util.stream.Collectors;
//
//@OnlyIn(Dist.CLIENT)
//public class BookmarkButton extends Button {
//
// private final GuiBooklet booklet;
// public IBookletPage assignedPage;
//
// public BookmarkButton(int x, int y, GuiBooklet booklet) {
// super(x, y, 16, 16, StringTextComponent.EMPTY, btn -> {
// BookmarkButton button = (BookmarkButton) btn;
// if (button.assignedPage != null) {
// if (Screen.hasShiftDown()) {
// button.assignedPage = null;
// } else if (!(button.booklet instanceof GuiPage) || ((GuiPage) button.booklet).pages[0] != button.assignedPage) {
// GuiPage gui = BookletUtils.createPageGui(button.booklet.previousScreen, button.booklet, button.assignedPage);
// Minecraft.getInstance().setScreen(gui);
// }
// } else {
// if (button.booklet instanceof GuiPage) {
// button.assignedPage = ((GuiPage) button.booklet).pages[0];
// }
// }
// });
// this.booklet = booklet;
// }
//
// @Override
// public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) {
// if (this.visible) {
// Minecraft.getInstance().getTextureManager().bind(GuiBooklet.RES_LOC_GADGETS);
// GlStateManager._color4f(1.0F, 1.0F, 1.0F, 1.0F);
// this.isHovered = mouseX >= this.x && mouseY >= this.y && this.x < this.x + this.width && this.y < this.y + this.height;
// int offset = this.isHovered
// ? 1
// : 0;
//
// GlStateManager._enableBlend();
// GlStateManager._blendFuncSeparate(770, 771, 1, 0);
// GlStateManager._blendFunc(770, 771);
// int renderHeight = 25;
// this.blit(matrices, this.x, this.y, 224 + (this.assignedPage == null
// ? 0
// : 16), 14 - renderHeight + offset * renderHeight, this.width, renderHeight);
//
// // TODO: FIX THIS
// // this.mouseDragged(minecraft, mouseX, mouseY);
//
// if (this.assignedPage != null) {
// ItemStack display = this.assignedPage.getChapter().getDisplayItemStack();
// if (StackUtil.isValid(display)) {
// GlStateManager._pushMatrix();
// AssetUtil.renderStackToGui(display, this.x + 2, this.y + 1, 0.725F);
// GlStateManager._popMatrix();
// }
// }
// }
// }
//
// public void drawHover(MatrixStack stack, int mouseX, int mouseY) {
// if (this.isMouseOver(mouseX, mouseY)) {
// List<String> list = new ArrayList<>();
//
// if (this.assignedPage != null) {
// IBookletChapter chapter = this.assignedPage.getChapter();
//
// list.add(TextFormatting.GOLD + chapter.getLocalizedName() + ", Page " + (chapter.getPageIndex(this.assignedPage) + 1));
// list.add(StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".bookmarkButton.bookmark.openDesc"));
// list.add(TextFormatting.ITALIC + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".bookmarkButton.bookmark.removeDesc"));
// } else {
// list.add(TextFormatting.GOLD + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".bookmarkButton.noBookmark.name"));
//
// if (this.booklet instanceof GuiPage) {
// list.add(StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".bookmarkButton.noBookmark.pageDesc"));
// } else {
// list.add(StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".bookmarkButton.noBookmark.notPageDesc"));
// }
// }
//
// Minecraft mc = Minecraft.getInstance();
// GuiUtils.drawHoveringText(stack, list.stream().map(StringTextComponent::new).collect(Collectors.toList()), mouseX, mouseY, mc.screen.width, mc.screen.height, -1, mc.font);
// }
// }
//}

View file

@ -1,67 +1,67 @@
/*
* This file ("EntryButton.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.button;
import com.mojang.blaze3d.platform.GlStateManager;
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class EntryButton extends Button {
private final GuiBookletBase gui;
private final ItemStack stackToRender;
public EntryButton(GuiBookletBase gui, int id, int x, int y, int width, int height, String text, ItemStack stackToRender) {
super(id, x, y, width, height, text);
this.gui = gui;
StackUtil.isValid(stackToRender);
this.stackToRender = stackToRender;
}
@Override
public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float f) {
if (this.visible) {
GlStateManager.color3arg(1.0F, 1.0F, 1.0F, 1.0F);
this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
GlStateManager._enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager._blendFunc(770, 771);
this.mouseDragged(minecraft, mouseX, mouseY);
int textOffsetX = 0;
if (StackUtil.isValid(this.stackToRender)) {
GlStateManager._pushMatrix();
AssetUtil.renderStackToGui(this.stackToRender, this.x - 4, this.y, 0.725F);
GlStateManager._popMatrix();
textOffsetX = 10;
}
float scale = this.gui.getMediumFontSize();
if (this.hovered) {
GlStateManager._pushMatrix();
AssetUtil.drawHorizontalGradientRect(this.x + textOffsetX - 1, this.y + this.height - 1, this.x + (int) (minecraft.font.width(this.displayString) * scale) + textOffsetX + 1, this.y + this.height, 0x80 << 24 | 22271, 22271, this.zLevel);
GlStateManager._popMatrix();
}
StringUtil.renderScaledAsciiString(minecraft.font, this.displayString, this.x + textOffsetX, this.y + 2 + (this.height - 8) / 2, 0, false, scale);
}
}
}
///*
// * This file ("EntryButton.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet.button;
//
//import com.mojang.blaze3d.platform.GlStateManager;
//import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
//import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
//import de.ellpeck.actuallyadditions.mod.util.StackUtil;
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
//import net.minecraft.client.Minecraft;
//import net.minecraft.client.gui.widget.button.Button;
//import net.minecraft.item.ItemStack;
//import net.minecraftforge.api.distmarker.Dist;
//import net.minecraftforge.api.distmarker.OnlyIn;
//
//
//@OnlyIn(Dist.CLIENT)
//public class EntryButton extends Button {
//
// private final GuiBookletBase gui;
// private final ItemStack stackToRender;
//
// public EntryButton(GuiBookletBase gui, int id, int x, int y, int width, int height, String text, ItemStack stackToRender) {
// super(id, x, y, width, height, text);
// this.gui = gui;
// StackUtil.isValid(stackToRender);
// this.stackToRender = stackToRender;
// }
//
// @Override
// public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float f) {
// if (this.visible) {
// GlStateManager.color3arg(1.0F, 1.0F, 1.0F, 1.0F);
// this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
// GlStateManager._enableBlend();
// GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
// GlStateManager._blendFunc(770, 771);
// this.mouseDragged(minecraft, mouseX, mouseY);
//
// int textOffsetX = 0;
// if (StackUtil.isValid(this.stackToRender)) {
// GlStateManager._pushMatrix();
// AssetUtil.renderStackToGui(this.stackToRender, this.x - 4, this.y, 0.725F);
// GlStateManager._popMatrix();
// textOffsetX = 10;
// }
//
// float scale = this.gui.getMediumFontSize();
//
// if (this.hovered) {
// GlStateManager._pushMatrix();
// AssetUtil.drawHorizontalGradientRect(this.x + textOffsetX - 1, this.y + this.height - 1, this.x + (int) (minecraft.font.width(this.displayString) * scale) + textOffsetX + 1, this.y + this.height, 0x80 << 24 | 22271, 22271, this.zLevel);
// GlStateManager._popMatrix();
// }
//
// StringUtil.renderScaledAsciiString(minecraft.font, this.displayString, this.x + textOffsetX, this.y + 2 + (this.height - 8) / 2, 0, false, scale);
// }
// }
//}

View file

@ -1,52 +1,52 @@
/*
* This file ("TrialsButton.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.button;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
import de.ellpeck.actuallyadditions.mod.inventory.gui.TexturedButton;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.widget.button.Button.IPressable;
public class TrialsButton extends TexturedButton {
private final boolean isTrials;
public TrialsButton(GuiBooklet gui, IPressable action) {
super(GuiBooklet.RES_LOC_GADGETS, gui.getGuiLeft() + gui.getSizeX(), gui.getGuiTop() + 10, 0, 204, 52, 16, action);
this.isTrials = gui.areTrialsOpened();
this.active = !this.isTrials;
}
@Override
public void drawButton(Minecraft minecraft, int x, int y, float f) {
super.drawButton(minecraft, x, y, f);
if (this.visible) {
if (this.isHovered || this.isTrials) {
this.drawCenteredString(minecraft.font, StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".trialsButton.name"), this.x + (this.width - 8) / 2, this.y + (this.height - 8) / 2, 14737632);
}
}
}
@Override
protected int getHoverState(boolean mouseOver) {
if (mouseOver || this.isTrials) {
return 2;
} else if (!this.active) {
return 0;
} else {
return 1;
}
}
}
///*
// * This file ("TrialsButton.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet.button;
//
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
//import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
//import de.ellpeck.actuallyadditions.mod.inventory.gui.TexturedButton;
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
//import net.minecraft.client.Minecraft;
//
//import net.minecraft.client.gui.widget.button.Button.IPressable;
//
//public class TrialsButton extends TexturedButton {
//
// private final boolean isTrials;
//
// public TrialsButton(GuiBooklet gui, IPressable action) {
// super(GuiBooklet.RES_LOC_GADGETS, gui.getGuiLeft() + gui.getSizeX(), gui.getGuiTop() + 10, 0, 204, 52, 16, action);
// this.isTrials = gui.areTrialsOpened();
// this.active = !this.isTrials;
// }
//
// @Override
// public void drawButton(Minecraft minecraft, int x, int y, float f) {
// super.drawButton(minecraft, x, y, f);
//
// if (this.visible) {
// if (this.isHovered || this.isTrials) {
// this.drawCenteredString(minecraft.font, StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".trialsButton.name"), this.x + (this.width - 8) / 2, this.y + (this.height - 8) / 2, 14737632);
// }
// }
// }
//
// @Override
// protected int getHoverState(boolean mouseOver) {
// if (mouseOver || this.isTrials) {
// return 2;
// } else if (!this.active) {
// return 0;
// } else {
// return 1;
// }
// }
//}

View file

@ -1,110 +1,110 @@
/*
* This file ("BookletChapter.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.chapter;
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.api.misc.IDisableableItem;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class BookletChapter implements IBookletChapter {
public final IBookletPage[] pages;
public final IBookletEntry entry;
public final ItemStack displayStack;
private final String identifier;
private final int priority;
public TextFormatting color;
public BookletChapter(String identifier, IBookletEntry entry, ItemStack displayStack, IBookletPage... pages) {
this(identifier, entry, displayStack, 0, pages);
}
public BookletChapter(String identifier, IBookletEntry entry, ItemStack displayStack, int priority, IBookletPage... pages) {
this.pages = pages;
this.identifier = identifier;
this.entry = entry;
this.displayStack = displayStack;
if (displayStack.getItem() instanceof IDisableableItem && ((IDisableableItem) displayStack.getItem()).isDisabled()) {
displayStack = ItemStack.EMPTY;
}
this.priority = priority;
this.color = TextFormatting.RESET;
this.entry.addChapter(this);
for (IBookletPage page : this.pages) {
page.setChapter(this);
}
}
@Override
public IBookletPage[] getAllPages() {
return this.pages;
}
@Override
@OnlyIn(Dist.CLIENT)
public String getLocalizedName() {
return StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".chapter." + this.getIdentifier() + ".name");
}
@Override
@OnlyIn(Dist.CLIENT)
public String getLocalizedNameWithFormatting() {
return this.color + this.getLocalizedName();
}
@Override
public IBookletEntry getEntry() {
return this.entry;
}
@Override
public ItemStack getDisplayItemStack() {
return this.displayStack;
}
@Override
public String getIdentifier() {
return this.identifier;
}
@Override
public int getPageIndex(IBookletPage page) {
for (int i = 0; i < this.pages.length; i++) {
if (this.pages[i] == page) {
return i;
}
}
return -1;
}
@Override
public int getSortingPriority() {
return this.priority;
}
public BookletChapter setImportant() {
this.color = TextFormatting.DARK_GREEN;
return this;
}
public BookletChapter setSpecial() {
this.color = TextFormatting.DARK_PURPLE;
return this;
}
}
///*
// * This file ("BookletChapter.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet.chapter;
//
//import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
//import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
//import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
//import de.ellpeck.actuallyadditions.api.misc.IDisableableItem;
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
//import net.minecraft.item.ItemStack;
//import net.minecraft.util.text.TextFormatting;
//import net.minecraftforge.api.distmarker.Dist;
//import net.minecraftforge.api.distmarker.OnlyIn;
//
//public class BookletChapter implements IBookletChapter {
//
// public final IBookletPage[] pages;
// public final IBookletEntry entry;
// public final ItemStack displayStack;
// private final String identifier;
// private final int priority;
// public TextFormatting color;
//
// public BookletChapter(String identifier, IBookletEntry entry, ItemStack displayStack, IBookletPage... pages) {
// this(identifier, entry, displayStack, 0, pages);
// }
//
// public BookletChapter(String identifier, IBookletEntry entry, ItemStack displayStack, int priority, IBookletPage... pages) {
// this.pages = pages;
// this.identifier = identifier;
// this.entry = entry;
// this.displayStack = displayStack;
// if (displayStack.getItem() instanceof IDisableableItem && ((IDisableableItem) displayStack.getItem()).isDisabled()) {
// displayStack = ItemStack.EMPTY;
// }
// this.priority = priority;
// this.color = TextFormatting.RESET;
//
// this.entry.addChapter(this);
// for (IBookletPage page : this.pages) {
// page.setChapter(this);
// }
// }
//
// @Override
// public IBookletPage[] getAllPages() {
// return this.pages;
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public String getLocalizedName() {
// return StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".chapter." + this.getIdentifier() + ".name");
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public String getLocalizedNameWithFormatting() {
// return this.color + this.getLocalizedName();
// }
//
// @Override
// public IBookletEntry getEntry() {
// return this.entry;
// }
//
// @Override
// public ItemStack getDisplayItemStack() {
// return this.displayStack;
// }
//
// @Override
// public String getIdentifier() {
// return this.identifier;
// }
//
// @Override
// public int getPageIndex(IBookletPage page) {
// for (int i = 0; i < this.pages.length; i++) {
// if (this.pages[i] == page) {
// return i;
// }
// }
// return -1;
// }
//
// @Override
// public int getSortingPriority() {
// return this.priority;
// }
//
// public BookletChapter setImportant() {
// this.color = TextFormatting.DARK_GREEN;
// return this;
// }
//
// public BookletChapter setSpecial() {
// this.color = TextFormatting.DARK_PURPLE;
// return this;
// }
//}

View file

@ -1,46 +1,46 @@
/*
* This file ("BookletChapterCoffee.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.chapter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
import de.ellpeck.actuallyadditions.mod.booklet.page.BookletPage;
import de.ellpeck.actuallyadditions.mod.booklet.page.PageCoffeeMachine;
import de.ellpeck.actuallyadditions.mod.items.ItemCoffee;
import net.minecraft.item.ItemStack;
public class BookletChapterCoffee extends BookletChapter {
public BookletChapterCoffee(String identifier, IBookletEntry entry, ItemStack displayStack, IBookletPage... pages) {
super(identifier, entry, displayStack, getPages(pages));
}
private static IBookletPage[] getPages(IBookletPage... pages) {
List<IBookletPage> allPages = new ArrayList<>();
allPages.addAll(Arrays.asList(pages));
for (CoffeeIngredient ingredient : ActuallyAdditionsAPI.COFFEE_MACHINE_INGREDIENTS) {
BookletPage page = new PageCoffeeMachine(allPages.size() + 1, ingredient);
if (!(ingredient instanceof ItemCoffee.MilkIngredient)) {
page.setNoText();
}
allPages.add(page);
}
return allPages.toArray(new IBookletPage[allPages.size()]);
}
}
///*
// * This file ("BookletChapterCoffee.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet.chapter;
//
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.List;
//
//import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
//import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
//import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
//import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
//import de.ellpeck.actuallyadditions.mod.booklet.page.BookletPage;
//import de.ellpeck.actuallyadditions.mod.booklet.page.PageCoffeeMachine;
//import de.ellpeck.actuallyadditions.mod.items.ItemCoffee;
//import net.minecraft.item.ItemStack;
//
//public class BookletChapterCoffee extends BookletChapter {
//
// public BookletChapterCoffee(String identifier, IBookletEntry entry, ItemStack displayStack, IBookletPage... pages) {
// super(identifier, entry, displayStack, getPages(pages));
// }
//
// private static IBookletPage[] getPages(IBookletPage... pages) {
// List<IBookletPage> allPages = new ArrayList<>();
// allPages.addAll(Arrays.asList(pages));
//
// for (CoffeeIngredient ingredient : ActuallyAdditionsAPI.COFFEE_MACHINE_INGREDIENTS) {
// BookletPage page = new PageCoffeeMachine(allPages.size() + 1, ingredient);
// if (!(ingredient instanceof ItemCoffee.MilkIngredient)) {
// page.setNoText();
// }
// allPages.add(page);
// }
//
// return allPages.toArray(new IBookletPage[allPages.size()]);
// }
//}

View file

@ -1,40 +1,40 @@
/*
* This file ("BookletChapterCrusher.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.chapter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
import de.ellpeck.actuallyadditions.mod.booklet.page.PageCrusherRecipe;
import de.ellpeck.actuallyadditions.mod.crafting.CrusherCrafting;
import net.minecraft.item.ItemStack;
public class BookletChapterCrusher extends BookletChapter {
public BookletChapterCrusher(String identifier, IBookletEntry entry, ItemStack displayStack, IBookletPage... pages) {
super(identifier, entry, displayStack, getPages(pages));
}
private static IBookletPage[] getPages(IBookletPage... pages) {
List<IBookletPage> allPages = new ArrayList<>();
allPages.addAll(Arrays.asList(pages));
for (CrusherRecipe recipe : CrusherCrafting.MISC_RECIPES) {
allPages.add(new PageCrusherRecipe(allPages.size() + 1, recipe).setNoText());
}
return allPages.toArray(new IBookletPage[allPages.size()]);
}
}
///*
// * This file ("BookletChapterCrusher.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet.chapter;
//
//import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
//import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
//import de.ellpeck.actuallyadditions.mod.booklet.page.PageCrusherRecipe;
//import de.ellpeck.actuallyadditions.mod.crafting.CrusherCrafting;
//import de.ellpeck.actuallyadditions.mod.crafting.CrushingRecipe;
//import net.minecraft.item.ItemStack;
//
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.List;
//
//public class BookletChapterCrusher extends BookletChapter {
//
// public BookletChapterCrusher(String identifier, IBookletEntry entry, ItemStack displayStack, IBookletPage... pages) {
// super(identifier, entry, displayStack, getPages(pages));
// }
//
// private static IBookletPage[] getPages(IBookletPage... pages) {
// List<IBookletPage> allPages = new ArrayList<>();
// allPages.addAll(Arrays.asList(pages));
//
// for (CrushingRecipe recipe : CrusherCrafting.MISC_RECIPES) {
// allPages.add(new PageCrusherRecipe(allPages.size() + 1, recipe).setNoText());
// }
//
// return allPages.toArray(new IBookletPage[allPages.size()]);
// }
//}

View file

@ -1,48 +1,48 @@
/*
* This file ("BookletChapterTrials.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.chapter;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.booklet.page.PageTrials;
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.Minecraft;
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;
public class BookletChapterTrials extends BookletChapter {
public BookletChapterTrials(String identifier, ItemStack displayStack, boolean secondPageText) {
super(identifier, ActuallyAdditionsAPI.entryTrials, displayStack, new PageTrials(1, false, true), new PageTrials(2, true, secondPageText));
}
@Override
@OnlyIn(Dist.CLIENT)
public String getLocalizedName() {
return StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".trials." + this.getIdentifier() + ".name");
}
@Override
@OnlyIn(Dist.CLIENT)
public String getLocalizedNameWithFormatting() {
PlayerEntity player = Minecraft.getInstance().player;
PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player);
boolean completed = data.completedTrials.contains(this.getIdentifier());
return (completed
? TextFormatting.DARK_GREEN
: TextFormatting.DARK_RED) + TextFormatting.ITALIC.toString() + this.getLocalizedName();
}
}
///*
// * This file ("BookletChapterTrials.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet.chapter;
//
//import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
//import de.ellpeck.actuallyadditions.mod.booklet.page.PageTrials;
//import de.ellpeck.actuallyadditions.mod.data.PlayerData;
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
//import net.minecraft.client.Minecraft;
//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;
//
//public class BookletChapterTrials extends BookletChapter {
//
// public BookletChapterTrials(String identifier, ItemStack displayStack, boolean secondPageText) {
// super(identifier, ActuallyAdditionsAPI.entryTrials, displayStack, new PageTrials(1, false, true), new PageTrials(2, true, secondPageText));
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public String getLocalizedName() {
// return StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".trials." + this.getIdentifier() + ".name");
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public String getLocalizedNameWithFormatting() {
// PlayerEntity player = Minecraft.getInstance().player;
// PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player);
// boolean completed = data.completedTrials.contains(this.getIdentifier());
//
// return (completed
// ? TextFormatting.DARK_GREEN
// : TextFormatting.DARK_RED) + TextFormatting.ITALIC.toString() + this.getLocalizedName();
// }
//}

View file

@ -1,162 +1,162 @@
/*
* This file ("BookletEntry.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.entry;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fluids.FluidStack;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
public class BookletEntry implements IBookletEntry {
private final String identifier;
private final int priority;
private final List<IBookletChapter> chapters = new ArrayList<>();
private TextFormatting color;
public BookletEntry(String identifier) {
this(identifier, 0);
}
public BookletEntry(String identifier, int prio) {
this.identifier = identifier;
this.priority = prio;
ActuallyAdditionsAPI.addBookletEntry(this);
this.color = TextFormatting.RESET;
}
@OnlyIn(Dist.CLIENT)
private static boolean fitsFilter(IBookletPage page, String searchBarText) {
Minecraft mc = Minecraft.getInstance();
List<ItemStack> items = new ArrayList<>();
page.getItemStacksForPage(items);
if (!items.isEmpty()) {
for (ItemStack stack : items) {
if (StackUtil.isValid(stack)) {
List<String> tooltip = stack.getTooltipLines(mc.player, mc.options.advancedItemTooltips
? ITooltipFlag.TooltipFlags.ADVANCED
: ITooltipFlag.TooltipFlags.NORMAL);
for (String strg : tooltip) {
if (strg != null && strg.toLowerCase(Locale.ROOT).contains(searchBarText)) {
return true;
}
}
}
}
}
List<FluidStack> fluids = new ArrayList<>();
page.getFluidStacksForPage(fluids);
if (!fluids.isEmpty()) {
for (FluidStack stack : fluids) {
if (stack != null) {
String strg = stack.getLocalizedName();
if (strg != null && strg.toLowerCase(Locale.ROOT).contains(searchBarText)) {
return true;
}
}
}
}
return false;
}
@Override
public List<IBookletChapter> getAllChapters() {
return this.chapters;
}
@Override
public String getIdentifier() {
return this.identifier;
}
@Override
@OnlyIn(Dist.CLIENT)
public String getLocalizedName() {
return StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".indexEntry." + this.getIdentifier() + ".name");
}
@Override
@OnlyIn(Dist.CLIENT)
public String getLocalizedNameWithFormatting() {
return this.color + this.getLocalizedName();
}
@Override
public void addChapter(IBookletChapter chapter) {
this.chapters.add(chapter);
}
@Override
@OnlyIn(Dist.CLIENT)
public List<IBookletChapter> getChaptersForDisplay(String searchBarText) {
if (searchBarText != null && !searchBarText.isEmpty()) {
String search = searchBarText.toLowerCase(Locale.ROOT);
List<IBookletChapter> fittingChapters = new ArrayList<>();
for (IBookletChapter chapter : this.getAllChapters()) {
if (chapter.getLocalizedName().toLowerCase(Locale.ROOT).contains(search)) {
fittingChapters.add(chapter);
} else {
for (IBookletPage page : chapter.getAllPages()) {
if (fitsFilter(page, search)) {
fittingChapters.add(chapter);
break;
}
}
}
}
return fittingChapters;
} else {
return this.getAllChapters();
}
}
@Override
public int getSortingPriority() {
return this.priority;
}
@Override
@OnlyIn(Dist.CLIENT)
public boolean visibleOnFrontPage() {
return true;
}
public BookletEntry setImportant() {
this.color = TextFormatting.DARK_GREEN;
return this;
}
public BookletEntry setSpecial() {
this.color = TextFormatting.DARK_PURPLE;
return this;
}
}
///*
// * This file ("BookletEntry.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet.entry;
//
//import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
//import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
//import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
//import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
//import de.ellpeck.actuallyadditions.mod.util.StackUtil;
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
//import net.minecraft.client.Minecraft;
//import net.minecraft.client.util.ITooltipFlag;
//import net.minecraft.item.ItemStack;
//import net.minecraft.util.text.TextFormatting;
//import net.minecraftforge.api.distmarker.Dist;
//import net.minecraftforge.api.distmarker.OnlyIn;
//import net.minecraftforge.fluids.FluidStack;
//
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Locale;
//
//public class BookletEntry implements IBookletEntry {
//
// private final String identifier;
// private final int priority;
// private final List<IBookletChapter> chapters = new ArrayList<>();
// private TextFormatting color;
//
// public BookletEntry(String identifier) {
// this(identifier, 0);
// }
//
// public BookletEntry(String identifier, int prio) {
// this.identifier = identifier;
// this.priority = prio;
// ActuallyAdditionsAPI.addBookletEntry(this);
//
// this.color = TextFormatting.RESET;
// }
//
// @OnlyIn(Dist.CLIENT)
// private static boolean fitsFilter(IBookletPage page, String searchBarText) {
// Minecraft mc = Minecraft.getInstance();
//
// List<ItemStack> items = new ArrayList<>();
// page.getItemStacksForPage(items);
// if (!items.isEmpty()) {
// for (ItemStack stack : items) {
// if (StackUtil.isValid(stack)) {
// List<String> tooltip = stack.getTooltipLines(mc.player, mc.options.advancedItemTooltips
// ? ITooltipFlag.TooltipFlags.ADVANCED
// : ITooltipFlag.TooltipFlags.NORMAL);
// for (String strg : tooltip) {
// if (strg != null && strg.toLowerCase(Locale.ROOT).contains(searchBarText)) {
// return true;
// }
// }
// }
// }
// }
//
// List<FluidStack> fluids = new ArrayList<>();
// page.getFluidStacksForPage(fluids);
// if (!fluids.isEmpty()) {
// for (FluidStack stack : fluids) {
// if (stack != null) {
// String strg = stack.getLocalizedName();
// if (strg != null && strg.toLowerCase(Locale.ROOT).contains(searchBarText)) {
// return true;
// }
// }
// }
// }
//
// return false;
// }
//
// @Override
// public List<IBookletChapter> getAllChapters() {
// return this.chapters;
// }
//
// @Override
// public String getIdentifier() {
// return this.identifier;
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public String getLocalizedName() {
// return StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".indexEntry." + this.getIdentifier() + ".name");
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public String getLocalizedNameWithFormatting() {
// return this.color + this.getLocalizedName();
// }
//
// @Override
// public void addChapter(IBookletChapter chapter) {
// this.chapters.add(chapter);
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public List<IBookletChapter> getChaptersForDisplay(String searchBarText) {
// if (searchBarText != null && !searchBarText.isEmpty()) {
// String search = searchBarText.toLowerCase(Locale.ROOT);
//
// List<IBookletChapter> fittingChapters = new ArrayList<>();
// for (IBookletChapter chapter : this.getAllChapters()) {
// if (chapter.getLocalizedName().toLowerCase(Locale.ROOT).contains(search)) {
// fittingChapters.add(chapter);
// } else {
// for (IBookletPage page : chapter.getAllPages()) {
// if (fitsFilter(page, search)) {
// fittingChapters.add(chapter);
// break;
// }
// }
// }
// }
//
// return fittingChapters;
// } else {
// return this.getAllChapters();
// }
// }
//
// @Override
// public int getSortingPriority() {
// return this.priority;
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public boolean visibleOnFrontPage() {
// return true;
// }
//
// public BookletEntry setImportant() {
// this.color = TextFormatting.DARK_GREEN;
// return this;
// }
//
// public BookletEntry setSpecial() {
// this.color = TextFormatting.DARK_PURPLE;
// return this;
// }
//
//}

View file

@ -1,33 +1,33 @@
/*
* This file ("BookletEntryAllItems.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.entry;
import java.util.List;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
public class BookletEntryAllItems extends BookletEntry {
public BookletEntryAllItems(String identifier) {
super(identifier, -Integer.MAX_VALUE);
}
@Override
public void addChapter(IBookletChapter chapter) {
}
@Override
public List<IBookletChapter> getAllChapters() {
return ActuallyAdditionsAPI.ALL_CHAPTERS;
}
}
///*
// * This file ("BookletEntryAllItems.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet.entry;
//
//import java.util.List;
//
//import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
//import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
//
//public class BookletEntryAllItems extends BookletEntry {
//
// public BookletEntryAllItems(String identifier) {
// super(identifier, -Integer.MAX_VALUE);
// }
//
// @Override
// public void addChapter(IBookletChapter chapter) {
//
// }
//
// @Override
// public List<IBookletChapter> getAllChapters() {
// return ActuallyAdditionsAPI.ALL_CHAPTERS;
// }
//}

View file

@ -1,23 +1,23 @@
/*
* This file ("BookletEntryTrials.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.entry;
public class BookletEntryTrials extends BookletEntry {
public BookletEntryTrials(String identifier) {
super(identifier, -Integer.MAX_VALUE);
}
@Override
public boolean visibleOnFrontPage() {
return false;
}
}
///*
// * This file ("BookletEntryTrials.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet.entry;
//
//public class BookletEntryTrials extends BookletEntry {
//
// public BookletEntryTrials(String identifier) {
// super(identifier, -Integer.MAX_VALUE);
// }
//
// @Override
// public boolean visibleOnFrontPage() {
// return false;
// }
//}

View file

@ -1,369 +1,369 @@
/*
* This file ("GuiBooklet.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.gui;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.booklet.button.BookmarkButton;
import de.ellpeck.actuallyadditions.mod.booklet.button.TrialsButton;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
import de.ellpeck.actuallyadditions.mod.data.PlayerData.PlayerSave;
import de.ellpeck.actuallyadditions.mod.inventory.gui.TexturedButton;
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.gui.IGuiEventListener;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@OnlyIn(Dist.CLIENT)
public abstract class GuiBooklet extends GuiBookletBase {
public static final int BUTTONS_PER_PAGE = 12;
public static final ResourceLocation RES_LOC_GUI = AssetUtil.getBookletGuiLocation("gui_booklet");
public static final ResourceLocation RES_LOC_GADGETS = AssetUtil.getBookletGuiLocation("gui_booklet_gadgets");
protected final BookmarkButton[] bookmarkButtons = new BookmarkButton[12];
public Screen previousScreen;
public GuiBookletBase parentPage;
public TextFieldWidget searchField;
protected int xSize;
protected int ySize;
protected int guiLeft;
protected int guiTop;
private Button buttonLeft;
private Button buttonRight;
private Button buttonBack;
private Button buttonTrials;
private float smallFontSize;
private float mediumFontSize;
private float largeFontSize;
public GuiBooklet(Screen previousScreen, GuiBookletBase parentPage) {
super(StringTextComponent.EMPTY);
this.previousScreen = previousScreen;
this.parentPage = parentPage;
this.xSize = 281;
this.ySize = 180;
}
private static float getFontSize(String lang, ConfigIntValues config, float defaultValue) {
int conf = config.getValue();
if (conf <= 0) {
try {
return Float.parseFloat(StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".fontSize." + lang));
} catch (Exception e) {
return defaultValue;
}
} else {
return conf / 100F;
}
}
@Override
public void init() {
super.init();
this.guiLeft = (this.width - this.xSize) / 2;
this.guiTop = (this.height - this.ySize) / 2;
this.smallFontSize = getFontSize("small", ConfigIntValues.FONT_SIZE_SMALL, 0.5F);
this.mediumFontSize = getFontSize("medium", ConfigIntValues.FONT_SIZE_MEDIUM, 0.75F);
this.largeFontSize = getFontSize("large", ConfigIntValues.FONT_SIZE_LARGE, 0.8F);
if (this.hasPageLeftButton()) {
List<String> hoverText = Arrays.asList(TextFormatting.GOLD + "Previous Page", TextFormatting.ITALIC + "Or scroll up");
this.buttonLeft = new TexturedButton(RES_LOC_GADGETS, this.guiLeft - 12, this.guiTop + this.ySize - 8, 18, 54, 18, 10, hoverText, btn -> this.onPageLeftButtonPressed());
this.addButton(this.buttonLeft);
}
if (this.hasPageRightButton()) {
List<String> hoverText = Arrays.asList(TextFormatting.GOLD + "Next Page", TextFormatting.ITALIC + "Or scroll down");
this.buttonRight = new TexturedButton(RES_LOC_GADGETS, this.guiLeft + this.xSize - 6, this.guiTop + this.ySize - 8, 0, 54, 18, 10, hoverText, btn -> this.onPageRightButtonPressed());
this.addButton(this.buttonRight);
}
if (this.hasBackButton()) {
List<String> hoverText = Arrays.asList(TextFormatting.GOLD + "Go Back", TextFormatting.ITALIC + "Or right-click", TextFormatting.ITALIC.toString() + TextFormatting.GRAY + "Hold Shift for Main Page");
this.buttonBack = new TexturedButton(RES_LOC_GADGETS, this.guiLeft - 15, this.guiTop - 3, 36, 54, 18, 10, hoverText, btn -> this.onBackButtonPressed());
this.addButton(this.buttonBack);
}
if (this.hasSearchBar()) {
this.searchField = new TextFieldWidget(this.font, this.guiLeft + this.xSize + 2, this.guiTop + this.ySize - 40 + 2, 64, 12, StringTextComponent.EMPTY);
this.searchField.setMaxLength(50);
this.searchField.setBordered(false);
this.children.add(this.searchField);
}
if (this.hasBookmarkButtons()) {
PlayerSave data = PlayerData.getDataFromPlayer(this.getMinecraft().player);
int xStart = this.guiLeft + this.xSize / 2 - 16 * this.bookmarkButtons.length / 2;
for (int i = 0; i < this.bookmarkButtons.length; i++) {
this.bookmarkButtons[i] = new BookmarkButton(xStart + i * 16, this.guiTop + this.ySize, this);
this.addButton(this.bookmarkButtons[i]);
if (data.bookmarks[i] != null) {
this.bookmarkButtons[i].assignedPage = data.bookmarks[i];
}
}
}
this.buttonTrials = new TrialsButton(this, btn -> this.getMinecraft().setScreen(new GuiEntry(this.previousScreen, this, ActuallyAdditionsAPI.entryTrials, 0, "", false)));
this.addButton(this.buttonTrials);
}
@Override
public void removed() {
super.removed();
//Don't cache the parent GUI, otherwise it opens again when you close the cached book!
this.previousScreen = null;
if (this.getMinecraft().player == null) {
return;
}
PlayerSave data = PlayerData.getDataFromPlayer(this.getMinecraft().player);
data.lastOpenBooklet = this;
boolean change = false;
for (int i = 0; i < this.bookmarkButtons.length; i++) {
if (data.bookmarks[i] != this.bookmarkButtons[i].assignedPage) {
data.bookmarks[i] = this.bookmarkButtons[i].assignedPage;
change = true;
}
}
if (change) {
PacketHandlerHelper.sendPlayerDataToServer(true, 0);
}
}
@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
this.drawScreenPre(matrixStack, mouseX, mouseY, partialTicks);
super.render(matrixStack, mouseX, mouseY, partialTicks);
this.drawScreenPost(matrixStack, mouseX, mouseY, partialTicks);
}
public void drawScreenPre(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) {
GlStateManager._color4f(1F, 1F, 1F, 1F);
this.getMinecraft().getTextureManager().bind(RES_LOC_GUI);
blit(matrices, this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize, 512, 512);
if (this.hasSearchBar()) {
this.getMinecraft().getTextureManager().bind(RES_LOC_GADGETS);
this.blit(matrices, this.guiLeft + this.xSize, this.guiTop + this.ySize - 40, 188, 0, 68, 14);
// boolean unicodeBefore = this.font.getUnicodeFlag();
// this.font.setUnicodeFlag(true);
if (!this.searchField.isFocused() && (this.searchField.getValue() == null || this.searchField.getValue().isEmpty())) {
this.font.draw(matrices, TextFormatting.ITALIC + StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.searchField"), this.guiLeft + this.xSize + 2, this.guiTop + this.ySize - 40 + 2, 0xFFFFFF);
}
this.searchField.render(matrices, mouseX, mouseY, partialTicks);
// this.font.setUnicodeFlag(unicodeBefore);
}
}
public void drawScreenPost(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
for (IGuiEventListener button : this.children) {
if (button instanceof BookmarkButton) {
((BookmarkButton) button).drawHover(matrixStack, mouseX, mouseY);
} else if (button instanceof TexturedButton) {
((TexturedButton) button).drawHover(matrixStack, mouseX, mouseY);
}
}
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
return super.mouseClicked(mouseX, mouseY, button);
}
// TODO: Ensure replacement works
@Override
public boolean mouseScrolled(double mouseX, double mouseY, double delta) {
if (delta < 0) {
if (this.hasPageRightButton()) {
this.onPageRightButtonPressed();
}
} else if (delta > 0) {
if (this.hasPageLeftButton()) {
this.onPageLeftButtonPressed();
}
}
return super.mouseScrolled(mouseX, mouseY, delta);
}
// @Override
// public void handleMouseInput() throws IOException {
// int wheel = Mouse.getEventDWheel();
// if (wheel != 0) {
// if (wheel < 0) {
// if (this.hasPageRightButton()) {
// this.onPageRightButtonPressed();
// }
// } else if (wheel > 0) {
// if (this.hasPageLeftButton()) {
// this.onPageLeftButtonPressed();
// }
// }
// }
// super.handleMouseInput();
// }
@Override
public void tick() {
if (this.hasSearchBar()) {
this.searchField.tick();
}
}
@Override
public boolean isPauseScreen() {
return false;
}
public boolean hasPageLeftButton() {
return false;
}
public void onPageLeftButtonPressed() {
}
public boolean hasPageRightButton() {
return false;
}
public void onPageRightButtonPressed() {
}
public boolean areTrialsOpened() {
return false;
}
public boolean hasBackButton() {
return false;
}
public void onBackButtonPressed() {
this.getMinecraft().setScreen(new GuiMainPage(this.previousScreen));
}
public boolean hasSearchBar() {
return true;
}
public boolean hasBookmarkButtons() {
return true;
}
@Override
public float getSmallFontSize() {
return this.smallFontSize;
}
@Override
public float getMediumFontSize() {
return this.mediumFontSize;
}
@Override
public float getLargeFontSize() {
return this.largeFontSize;
}
// TODO: Check if not being used
public void onSearchBarChanged(String searchBarText) {
GuiBookletBase parent = !(this instanceof GuiEntry)
? this
: this.parentPage;
this.getMinecraft().setScreen(new GuiEntry(this.previousScreen, parent, ActuallyAdditionsAPI.entryAllAndSearch, 0, searchBarText, true));
}
// TODO: ensure typing still works
// @Override
// protected void keyTyped(char typedChar, int key) throws IOException {
// if (key == Keyboard.KEY_ESCAPE || key == this.mc.gameSettings.keyBindInventory.getKeyCode() && (!this.hasSearchBar() || !this.searchField.isFocused())) {
// this.mc.displayGuiScreen(this.previousScreen);
// } else if (this.hasSearchBar() & this.searchField.isFocused()) {
// String lastText = this.searchField.getText();
//
// this.searchField.textboxKeyTyped(typedChar, key);
//
// if (!lastText.equals(this.searchField.getText())) {
// this.onSearchBarChanged(this.searchField.getText());
// }
// } else {
// super.keyTyped(typedChar, key);
// }
// }
@Override
public void renderScaledAsciiString(String text, int x, int y, int color, boolean shadow, float scale) {
StringUtil.renderScaledAsciiString(this.font, text, x, y, color, shadow, scale);
}
@Override
public void renderSplitScaledAsciiString(String text, int x, int y, int color, boolean shadow, float scale, int length) {
StringUtil.renderSplitScaledAsciiString(this.font, text, x, y, color, shadow, scale, length);
}
@Override
public List<IGuiEventListener> getButtonList() {
return this.children.stream().filter(e -> e instanceof Button).collect(Collectors.toList());
}
@Override
public int getGuiLeft() {
return this.guiLeft;
}
@Override
public int getGuiTop() {
return this.guiTop;
}
@Override
public int getSizeX() {
return this.xSize;
}
@Override
public int getSizeY() {
return this.ySize;
}
}
///*
// * This file ("GuiBooklet.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet.gui;
//
//import com.mojang.blaze3d.matrix.MatrixStack;
//import com.mojang.blaze3d.platform.GlStateManager;
//import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
//import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
//import de.ellpeck.actuallyadditions.mod.booklet.button.BookmarkButton;
//import de.ellpeck.actuallyadditions.mod.booklet.button.TrialsButton;
//import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
//import de.ellpeck.actuallyadditions.mod.data.PlayerData;
//import de.ellpeck.actuallyadditions.mod.data.PlayerData.PlayerSave;
//import de.ellpeck.actuallyadditions.mod.inventory.gui.TexturedButton;
//import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
//import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
//import net.minecraft.client.gui.IGuiEventListener;
//import net.minecraft.client.gui.screen.Screen;
//import net.minecraft.client.gui.widget.TextFieldWidget;
//import net.minecraft.client.gui.widget.button.Button;
//import net.minecraft.util.ResourceLocation;
//import net.minecraft.util.text.StringTextComponent;
//import net.minecraft.util.text.TextFormatting;
//import net.minecraftforge.api.distmarker.Dist;
//import net.minecraftforge.api.distmarker.OnlyIn;
//
//import java.util.Arrays;
//import java.util.List;
//import java.util.stream.Collectors;
//
//@OnlyIn(Dist.CLIENT)
//public abstract class GuiBooklet extends GuiBookletBase {
//
// public static final int BUTTONS_PER_PAGE = 12;
// public static final ResourceLocation RES_LOC_GUI = AssetUtil.getBookletGuiLocation("gui_booklet");
// public static final ResourceLocation RES_LOC_GADGETS = AssetUtil.getBookletGuiLocation("gui_booklet_gadgets");
// protected final BookmarkButton[] bookmarkButtons = new BookmarkButton[12];
// public Screen previousScreen;
// public GuiBookletBase parentPage;
// public TextFieldWidget searchField;
// protected int xSize;
// protected int ySize;
// protected int guiLeft;
// protected int guiTop;
// private Button buttonLeft;
// private Button buttonRight;
// private Button buttonBack;
//
// private Button buttonTrials;
//
// private float smallFontSize;
// private float mediumFontSize;
// private float largeFontSize;
//
// public GuiBooklet(Screen previousScreen, GuiBookletBase parentPage) {
// super(StringTextComponent.EMPTY);
//
// this.previousScreen = previousScreen;
// this.parentPage = parentPage;
//
// this.xSize = 281;
// this.ySize = 180;
// }
//
// private static float getFontSize(String lang, ConfigIntValues config, float defaultValue) {
// int conf = config.getValue();
// if (conf <= 0) {
// try {
// return Float.parseFloat(StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".fontSize." + lang));
// } catch (Exception e) {
// return defaultValue;
// }
// } else {
// return conf / 100F;
// }
// }
//
// @Override
// public void init() {
// super.init();
//
// this.guiLeft = (this.width - this.xSize) / 2;
// this.guiTop = (this.height - this.ySize) / 2;
//
// this.smallFontSize = getFontSize("small", ConfigIntValues.FONT_SIZE_SMALL, 0.5F);
// this.mediumFontSize = getFontSize("medium", ConfigIntValues.FONT_SIZE_MEDIUM, 0.75F);
// this.largeFontSize = getFontSize("large", ConfigIntValues.FONT_SIZE_LARGE, 0.8F);
//
// if (this.hasPageLeftButton()) {
// List<String> hoverText = Arrays.asList(TextFormatting.GOLD + "Previous Page", TextFormatting.ITALIC + "Or scroll up");
// this.buttonLeft = new TexturedButton(RES_LOC_GADGETS, this.guiLeft - 12, this.guiTop + this.ySize - 8, 18, 54, 18, 10, hoverText, btn -> this.onPageLeftButtonPressed());
// this.addButton(this.buttonLeft);
// }
//
// if (this.hasPageRightButton()) {
// List<String> hoverText = Arrays.asList(TextFormatting.GOLD + "Next Page", TextFormatting.ITALIC + "Or scroll down");
// this.buttonRight = new TexturedButton(RES_LOC_GADGETS, this.guiLeft + this.xSize - 6, this.guiTop + this.ySize - 8, 0, 54, 18, 10, hoverText, btn -> this.onPageRightButtonPressed());
// this.addButton(this.buttonRight);
// }
//
// if (this.hasBackButton()) {
// List<String> hoverText = Arrays.asList(TextFormatting.GOLD + "Go Back", TextFormatting.ITALIC + "Or right-click", TextFormatting.ITALIC.toString() + TextFormatting.GRAY + "Hold Shift for Main Page");
// this.buttonBack = new TexturedButton(RES_LOC_GADGETS, this.guiLeft - 15, this.guiTop - 3, 36, 54, 18, 10, hoverText, btn -> this.onBackButtonPressed());
// this.addButton(this.buttonBack);
// }
//
// if (this.hasSearchBar()) {
// this.searchField = new TextFieldWidget(this.font, this.guiLeft + this.xSize + 2, this.guiTop + this.ySize - 40 + 2, 64, 12, StringTextComponent.EMPTY);
// this.searchField.setMaxLength(50);
// this.searchField.setBordered(false);
// this.children.add(this.searchField);
// }
//
// if (this.hasBookmarkButtons()) {
// PlayerSave data = PlayerData.getDataFromPlayer(this.getMinecraft().player);
//
// int xStart = this.guiLeft + this.xSize / 2 - 16 * this.bookmarkButtons.length / 2;
// for (int i = 0; i < this.bookmarkButtons.length; i++) {
// this.bookmarkButtons[i] = new BookmarkButton(xStart + i * 16, this.guiTop + this.ySize, this);
// this.addButton(this.bookmarkButtons[i]);
//
// if (data.bookmarks[i] != null) {
// this.bookmarkButtons[i].assignedPage = data.bookmarks[i];
// }
// }
// }
//
// this.buttonTrials = new TrialsButton(this, btn -> this.getMinecraft().setScreen(new GuiEntry(this.previousScreen, this, ActuallyAdditionsAPI.entryTrials, 0, "", false)));
// this.addButton(this.buttonTrials);
// }
//
// @Override
// public void removed() {
// super.removed();
//
// //Don't cache the parent GUI, otherwise it opens again when you close the cached book!
// this.previousScreen = null;
//
// if (this.getMinecraft().player == null) {
// return;
// }
// PlayerSave data = PlayerData.getDataFromPlayer(this.getMinecraft().player);
// data.lastOpenBooklet = this;
//
// boolean change = false;
// for (int i = 0; i < this.bookmarkButtons.length; i++) {
// if (data.bookmarks[i] != this.bookmarkButtons[i].assignedPage) {
// data.bookmarks[i] = this.bookmarkButtons[i].assignedPage;
// change = true;
// }
// }
//
// if (change) {
// PacketHandlerHelper.sendPlayerDataToServer(true, 0);
// }
// }
//
// @Override
// public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
// this.drawScreenPre(matrixStack, mouseX, mouseY, partialTicks);
// super.render(matrixStack, mouseX, mouseY, partialTicks);
// this.drawScreenPost(matrixStack, mouseX, mouseY, partialTicks);
// }
//
// public void drawScreenPre(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) {
// GlStateManager._color4f(1F, 1F, 1F, 1F);
// this.getMinecraft().getTextureManager().bind(RES_LOC_GUI);
// blit(matrices, this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize, 512, 512);
//
// if (this.hasSearchBar()) {
// this.getMinecraft().getTextureManager().bind(RES_LOC_GADGETS);
// this.blit(matrices, this.guiLeft + this.xSize, this.guiTop + this.ySize - 40, 188, 0, 68, 14);
//
// // boolean unicodeBefore = this.font.getUnicodeFlag();
// // this.font.setUnicodeFlag(true);
//
// if (!this.searchField.isFocused() && (this.searchField.getValue() == null || this.searchField.getValue().isEmpty())) {
// this.font.draw(matrices, TextFormatting.ITALIC + StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.searchField"), this.guiLeft + this.xSize + 2, this.guiTop + this.ySize - 40 + 2, 0xFFFFFF);
// }
//
// this.searchField.render(matrices, mouseX, mouseY, partialTicks);
//
// // this.font.setUnicodeFlag(unicodeBefore);
// }
// }
//
// public void drawScreenPost(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
// for (IGuiEventListener button : this.children) {
// if (button instanceof BookmarkButton) {
// ((BookmarkButton) button).drawHover(matrixStack, mouseX, mouseY);
// } else if (button instanceof TexturedButton) {
// ((TexturedButton) button).drawHover(matrixStack, mouseX, mouseY);
// }
// }
// }
//
// @Override
// public boolean mouseClicked(double mouseX, double mouseY, int button) {
// return super.mouseClicked(mouseX, mouseY, button);
// }
//
// // TODO: Ensure replacement works
// @Override
// public boolean mouseScrolled(double mouseX, double mouseY, double delta) {
// if (delta < 0) {
// if (this.hasPageRightButton()) {
// this.onPageRightButtonPressed();
// }
// } else if (delta > 0) {
// if (this.hasPageLeftButton()) {
// this.onPageLeftButtonPressed();
// }
// }
// return super.mouseScrolled(mouseX, mouseY, delta);
// }
//
// // @Override
// // public void handleMouseInput() throws IOException {
// // int wheel = Mouse.getEventDWheel();
// // if (wheel != 0) {
// // if (wheel < 0) {
// // if (this.hasPageRightButton()) {
// // this.onPageRightButtonPressed();
// // }
// // } else if (wheel > 0) {
// // if (this.hasPageLeftButton()) {
// // this.onPageLeftButtonPressed();
// // }
// // }
// // }
// // super.handleMouseInput();
// // }
//
//
// @Override
// public void tick() {
// if (this.hasSearchBar()) {
// this.searchField.tick();
// }
// }
//
// @Override
// public boolean isPauseScreen() {
// return false;
// }
//
// public boolean hasPageLeftButton() {
// return false;
// }
//
// public void onPageLeftButtonPressed() {
//
// }
//
// public boolean hasPageRightButton() {
// return false;
// }
//
// public void onPageRightButtonPressed() {
//
// }
//
// public boolean areTrialsOpened() {
// return false;
// }
//
// public boolean hasBackButton() {
// return false;
// }
//
// public void onBackButtonPressed() {
// this.getMinecraft().setScreen(new GuiMainPage(this.previousScreen));
// }
//
// public boolean hasSearchBar() {
// return true;
// }
//
// public boolean hasBookmarkButtons() {
// return true;
// }
//
// @Override
// public float getSmallFontSize() {
// return this.smallFontSize;
// }
//
// @Override
// public float getMediumFontSize() {
// return this.mediumFontSize;
// }
//
// @Override
// public float getLargeFontSize() {
// return this.largeFontSize;
// }
//
// // TODO: Check if not being used
// public void onSearchBarChanged(String searchBarText) {
// GuiBookletBase parent = !(this instanceof GuiEntry)
// ? this
// : this.parentPage;
// this.getMinecraft().setScreen(new GuiEntry(this.previousScreen, parent, ActuallyAdditionsAPI.entryAllAndSearch, 0, searchBarText, true));
// }
//
// // TODO: ensure typing still works
//
// // @Override
// // protected void keyTyped(char typedChar, int key) throws IOException {
// // if (key == Keyboard.KEY_ESCAPE || key == this.mc.gameSettings.keyBindInventory.getKeyCode() && (!this.hasSearchBar() || !this.searchField.isFocused())) {
// // this.mc.displayGuiScreen(this.previousScreen);
// // } else if (this.hasSearchBar() & this.searchField.isFocused()) {
// // String lastText = this.searchField.getText();
// //
// // this.searchField.textboxKeyTyped(typedChar, key);
// //
// // if (!lastText.equals(this.searchField.getText())) {
// // this.onSearchBarChanged(this.searchField.getText());
// // }
// // } else {
// // super.keyTyped(typedChar, key);
// // }
// // }
//
// @Override
// public void renderScaledAsciiString(String text, int x, int y, int color, boolean shadow, float scale) {
// StringUtil.renderScaledAsciiString(this.font, text, x, y, color, shadow, scale);
// }
//
// @Override
// public void renderSplitScaledAsciiString(String text, int x, int y, int color, boolean shadow, float scale, int length) {
// StringUtil.renderSplitScaledAsciiString(this.font, text, x, y, color, shadow, scale, length);
// }
//
// @Override
// public List<IGuiEventListener> getButtonList() {
// return this.children.stream().filter(e -> e instanceof Button).collect(Collectors.toList());
// }
//
// @Override
// public int getGuiLeft() {
// return this.guiLeft;
// }
//
// @Override
// public int getGuiTop() {
// return this.guiTop;
// }
//
// @Override
// public int getSizeX() {
// return this.xSize;
// }
//
// @Override
// public int getSizeY() {
// return this.ySize;
// }
//}

View file

@ -1,170 +1,170 @@
/*
* This file ("GuiEntry.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.gui;
import com.mojang.blaze3d.matrix.MatrixStack;
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
import de.ellpeck.actuallyadditions.mod.booklet.button.EntryButton;
import de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntryTrials;
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import java.io.IOException;
import java.util.List;
@OnlyIn(Dist.CLIENT)
public class GuiEntry extends GuiBooklet {
//The page in the entry. Say you have 2 more chapters than fit on one double page, then those 2 would be displayed on entryPage 1 instead.
private final int entryPage;
private final int pageAmount;
private final IBookletEntry entry;
private final List<IBookletChapter> chapters;
private final String searchText;
private final boolean focusSearch;
public GuiEntry(Screen previousScreen, GuiBookletBase parentPage, IBookletEntry entry, int entryPage, String search, boolean focusSearch) {
super(previousScreen, parentPage);
this.entryPage = entryPage;
this.entry = entry;
this.searchText = search;
this.focusSearch = focusSearch;
this.chapters = entry.getChaptersForDisplay(search);
if (!this.chapters.isEmpty()) {
IBookletChapter lastChap = this.chapters.get(this.chapters.size() - 1);
this.pageAmount = lastChap == null
? 1
: calcEntryPage(this.entry, lastChap, this.searchText) + 1;
} else {
this.pageAmount = 1;
}
}
public GuiEntry(Screen previousScreen, GuiBookletBase parentPage, IBookletEntry entry, IBookletChapter chapterForPageCalc, String search, boolean focusSearch) {
this(previousScreen, parentPage, entry, calcEntryPage(entry, chapterForPageCalc, search), search, focusSearch);
}
private static int calcEntryPage(IBookletEntry entry, IBookletChapter chapterForPageCalc, String search) {
int index = entry.getChaptersForDisplay(search).indexOf(chapterForPageCalc);
return index / (BUTTONS_PER_PAGE * 2);
}
@Override
public void drawScreenPre(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) {
super.drawScreenPre(matrices, mouseX, mouseY, partialTicks);
String name = this.entry.getLocalizedName();
this.font.draw(matrices, name, this.guiLeft + this.xSize / 2 - this.font.width(name) / 2, this.guiTop - 1, 0xFFFFFF);
for (int i = 0; i < 2; i++) {
String pageStrg = "Page " + (this.entryPage * 2 + i + 1) + "/" + this.pageAmount * 2;
this.renderScaledAsciiString(pageStrg, this.guiLeft + 25 + i * 136, this.guiTop + this.ySize - 7, 0xFFFFFF, false, this.getLargeFontSize());
}
}
@Override
public void init() {
super.init();
if (this.hasSearchBar() && this.searchText != null) {
this.searchField.setValue(this.searchText);
if (this.focusSearch) {
this.searchField.setFocus(true);
}
}
int idOffset = this.entryPage * BUTTONS_PER_PAGE * 2;
for (int x = 0; x < 2; x++) {
for (int y = 0; y < BUTTONS_PER_PAGE; y++) {
int id = y + x * BUTTONS_PER_PAGE;
if (this.chapters.size() > id + idOffset) {
IBookletChapter chapter = this.chapters.get(id + idOffset);
this.addButton(new EntryButton(this, id, this.guiLeft + 14 + x * 142, this.guiTop + 11 + y * 13, 115, 10, chapter.getLocalizedNameWithFormatting(), chapter.getDisplayItemStack()));
} else {
return;
}
}
}
}
/*
@Override
protected void actionPerformed(Button button) throws IOException {
if (button instanceof EntryButton) {
int actualId = button.id + this.entryPage * BUTTONS_PER_PAGE * 2;
if (this.chapters.size() > actualId) {
IBookletChapter chapter = this.chapters.get(actualId);
if (chapter != null) {
IBookletPage[] pages = chapter.getAllPages();
if (pages != null && pages.length > 0) {
this.minecraft.setScreen(BookletUtils.createPageGui(this.previousScreen, this, pages[0]));
}
}
}
} else {
super.actionPerformed(button);
}
}
*/
@Override
public void addOrModifyItemRenderer(ItemStack renderedStack, int x, int y, float scale, boolean shouldTryTransfer) {
}
@Override
public boolean hasPageLeftButton() {
return this.entryPage > 0;
}
@Override
public void onPageLeftButtonPressed() {
this.minecraft.setScreen(new GuiEntry(this.previousScreen, this.parentPage, this.entry, this.entryPage - 1, this.searchText, this.searchField.isFocused()));
}
@Override
public boolean hasPageRightButton() {
return !this.chapters.isEmpty() && this.entryPage < this.pageAmount - 1;
}
@Override
public void onPageRightButtonPressed() {
this.minecraft.setScreen(new GuiEntry(this.previousScreen, this.parentPage, this.entry, this.entryPage + 1, this.searchText, this.searchField.isFocused()));
}
@Override
public boolean hasBackButton() {
return true;
}
@Override
public void onBackButtonPressed() {
if (!hasShiftDown()) {
this.minecraft.setScreen(this.parentPage);
} else {
super.onBackButtonPressed();
}
}
@Override
public boolean areTrialsOpened() {
return this.entry instanceof BookletEntryTrials;
}
}
///*
// * This file ("GuiEntry.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet.gui;
//
//import com.mojang.blaze3d.matrix.MatrixStack;
//import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
//import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
//import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
//import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
//import de.ellpeck.actuallyadditions.mod.booklet.button.EntryButton;
//import de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntryTrials;
//import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
//import net.minecraft.client.gui.screen.Screen;
//import net.minecraft.client.gui.widget.button.Button;
//import net.minecraft.item.ItemStack;
//import net.minecraftforge.api.distmarker.Dist;
//import net.minecraftforge.api.distmarker.OnlyIn;
//
//import java.io.IOException;
//import java.util.List;
//
//@OnlyIn(Dist.CLIENT)
//public class GuiEntry extends GuiBooklet {
//
// //The page in the entry. Say you have 2 more chapters than fit on one double page, then those 2 would be displayed on entryPage 1 instead.
// private final int entryPage;
// private final int pageAmount;
// private final IBookletEntry entry;
// private final List<IBookletChapter> chapters;
// private final String searchText;
// private final boolean focusSearch;
//
// public GuiEntry(Screen previousScreen, GuiBookletBase parentPage, IBookletEntry entry, int entryPage, String search, boolean focusSearch) {
// super(previousScreen, parentPage);
// this.entryPage = entryPage;
// this.entry = entry;
// this.searchText = search;
// this.focusSearch = focusSearch;
// this.chapters = entry.getChaptersForDisplay(search);
//
// if (!this.chapters.isEmpty()) {
// IBookletChapter lastChap = this.chapters.get(this.chapters.size() - 1);
// this.pageAmount = lastChap == null
// ? 1
// : calcEntryPage(this.entry, lastChap, this.searchText) + 1;
// } else {
// this.pageAmount = 1;
// }
// }
//
// public GuiEntry(Screen previousScreen, GuiBookletBase parentPage, IBookletEntry entry, IBookletChapter chapterForPageCalc, String search, boolean focusSearch) {
// this(previousScreen, parentPage, entry, calcEntryPage(entry, chapterForPageCalc, search), search, focusSearch);
// }
//
// private static int calcEntryPage(IBookletEntry entry, IBookletChapter chapterForPageCalc, String search) {
// int index = entry.getChaptersForDisplay(search).indexOf(chapterForPageCalc);
// return index / (BUTTONS_PER_PAGE * 2);
// }
//
// @Override
// public void drawScreenPre(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) {
// super.drawScreenPre(matrices, mouseX, mouseY, partialTicks);
//
// String name = this.entry.getLocalizedName();
// this.font.draw(matrices, name, this.guiLeft + this.xSize / 2 - this.font.width(name) / 2, this.guiTop - 1, 0xFFFFFF);
//
// for (int i = 0; i < 2; i++) {
// String pageStrg = "Page " + (this.entryPage * 2 + i + 1) + "/" + this.pageAmount * 2;
// this.renderScaledAsciiString(pageStrg, this.guiLeft + 25 + i * 136, this.guiTop + this.ySize - 7, 0xFFFFFF, false, this.getLargeFontSize());
// }
// }
//
// @Override
// public void init() {
// super.init();
//
// if (this.hasSearchBar() && this.searchText != null) {
// this.searchField.setValue(this.searchText);
// if (this.focusSearch) {
// this.searchField.setFocus(true);
// }
// }
//
// int idOffset = this.entryPage * BUTTONS_PER_PAGE * 2;
// for (int x = 0; x < 2; x++) {
// for (int y = 0; y < BUTTONS_PER_PAGE; y++) {
// int id = y + x * BUTTONS_PER_PAGE;
// if (this.chapters.size() > id + idOffset) {
// IBookletChapter chapter = this.chapters.get(id + idOffset);
// this.addButton(new EntryButton(this, id, this.guiLeft + 14 + x * 142, this.guiTop + 11 + y * 13, 115, 10, chapter.getLocalizedNameWithFormatting(), chapter.getDisplayItemStack()));
// } else {
// return;
// }
// }
// }
// }
///*
// @Override
// protected void actionPerformed(Button button) throws IOException {
// if (button instanceof EntryButton) {
// int actualId = button.id + this.entryPage * BUTTONS_PER_PAGE * 2;
//
// if (this.chapters.size() > actualId) {
// IBookletChapter chapter = this.chapters.get(actualId);
// if (chapter != null) {
// IBookletPage[] pages = chapter.getAllPages();
// if (pages != null && pages.length > 0) {
// this.minecraft.setScreen(BookletUtils.createPageGui(this.previousScreen, this, pages[0]));
// }
// }
// }
// } else {
// super.actionPerformed(button);
// }
// }
//
// */
//
// @Override
// public void addOrModifyItemRenderer(ItemStack renderedStack, int x, int y, float scale, boolean shouldTryTransfer) {
//
// }
//
// @Override
// public boolean hasPageLeftButton() {
// return this.entryPage > 0;
// }
//
// @Override
// public void onPageLeftButtonPressed() {
// this.minecraft.setScreen(new GuiEntry(this.previousScreen, this.parentPage, this.entry, this.entryPage - 1, this.searchText, this.searchField.isFocused()));
// }
//
// @Override
// public boolean hasPageRightButton() {
// return !this.chapters.isEmpty() && this.entryPage < this.pageAmount - 1;
// }
//
// @Override
// public void onPageRightButtonPressed() {
// this.minecraft.setScreen(new GuiEntry(this.previousScreen, this.parentPage, this.entry, this.entryPage + 1, this.searchText, this.searchField.isFocused()));
// }
//
// @Override
// public boolean hasBackButton() {
// return true;
// }
//
// @Override
// public void onBackButtonPressed() {
// if (!hasShiftDown()) {
// this.minecraft.setScreen(this.parentPage);
// } else {
// super.onBackButtonPressed();
// }
// }
//
// @Override
// public boolean areTrialsOpened() {
// return this.entry instanceof BookletEntryTrials;
// }
//}

View file

@ -1,240 +1,240 @@
/*
* This file ("GuiMainPage.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.gui;
import com.mojang.blaze3d.matrix.MatrixStack;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.booklet.InitBooklet;
import de.ellpeck.actuallyadditions.mod.booklet.button.EntryButton;
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
import de.ellpeck.actuallyadditions.mod.data.PlayerData.PlayerSave;
import de.ellpeck.actuallyadditions.mod.inventory.gui.TexturedButton;
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
//TODO Fix achievement button
@OnlyIn(Dist.CLIENT)
public class GuiMainPage extends GuiBooklet {
private static final String[] QUOTES = new String[]{"Actually Additions, to me, is quite magical in a way.@Saphrym", "Actually quite cool. Lots of nice little additions.@Direwolf20", "Mod Dev quite rude and arrogant@Bubb1e0seven", "A whimsical breath of fresh air in a stuffy tech-mod world.@mezz", "User-friendly :3@TheMeeep", "A lot of stuff, some of it really good.@Narubion", "I like the bookmarks.@Vazkii", "It's got some stuff I guess.@Ellpeck", "Actually Additions should be included in every new modpack that includes any form of tech.@YasminEndusa", "A mod that basically lets you do what ever the heck you want.@Ristelle", "TINY TORCHES!! BABY TORCHES!! Somebody actually finally did it!!@Soaryn", "Balanced mod wich makes things different - in a good way.@garantiertnicht", "The mod everyone needs, but not everyone knows@Brewpl", "The in-game documentation is the best Ive seen. I especially love the JEI integration. Even a derp like me can figure it out.@dannydjdk", "The second best mod I've ever used.@mmaas44", "The Fermenting Barrel is one of my favorite textures.@amadornes", "Smiley Clouds is the reason for fascism in 2016.@raoulvdberge", "The worms are an awesome idea!@greenking", "Can I use that mod in my pack?@Ibraheem", "Hello, love the mod.@SuntannedDuck2", "Quick! Have all the fun before they nerf it!@JuddMan03", "I have a feeling Actually Additions is also like Extra Utilities with Random things smashed together why is it...@lesslighter", "Leaf eater... munchdew... hummm@EiOs", "There is no such thing as canola seeds.@AlBoVa", "This mod is cancer, BRUTAL EXPENSIVE POWER usage..Just, cancer.@KoJo", "Spaghetti is spaghetti, and noodles are noodles.@robsonld04", "The Actually Additions name is actually true. It's actually great!@asiekierka", "Such a great mod@jsdeveloper", "That mod is kind of funny.@Anonymous", "Actually Additions is a lot of fun.@Anonymous", "Is Actually Additions still fugly?@Anonymous", "I like it, but it's so small.@Anonymous", "It has a couple of blocks I like, but overall it's just a mess.@Anonymous", "Direwolf's 1.10 playthrough is just him shilling Actually Additions@Anonymous", "We thought about sending the author a bunch of pizzas to his adress@Anonymous", "It's op as heck.@billofbong0", "Actually AdditionsってマイクラMODすごく良いのに日本人で遊んでる人あんまいないっぽい@stay_uk", "Actually Additions is OP. Not like my favorite combination of mods, Project E + Magic Crops + Draconic Evolution.@Anonymous", "To be perfectly honest, I never actually realized how much content Actually Additions has before.@Ellpeck", "I don't blame you, I actually downgraded to Actually Additions.@PvtSeaCow", "It is lonely because there is no device to fly items with the laser in the 1.7.10 version.@Google Translate", "始めまして。日本人です。このMODは本当に素晴らしいただ、1.7.10ヴァージョンだと、レーザーでアイテムを飛ばす装置がないので寂しいです。@Anonymous", "Some verses found in older translations, such as the KJV were actually additions made by later copyists.@Pat_Joel", "I can't place filters into Laser Relays, but the mod is very cool.@LP_Jakob", "Am I good enough to be an Actually Additions tool?@deanwhufc"};
//private TexturedButton achievementButton;
private TexturedButton configButton;
private Button tutorialButton;
private boolean showTutorial;
private String bookletName;
private String bookletEdition;
private List<String> quote;
private String quoteGuy;
public GuiMainPage(Screen previousScreen) {
super(previousScreen, null);
}
private static List<IBookletEntry> getDisplayedEntries() {
List<IBookletEntry> displayed = new ArrayList<>();
for (IBookletEntry entry : ActuallyAdditionsAPI.BOOKLET_ENTRIES) {
if (entry.visibleOnFrontPage()) {
displayed.add(entry);
}
}
return displayed;
}
@Override
public void init() {
super.init();
int flavor = 1;
if (this.getMinecraft().level.random.nextFloat() <= 0.1) {
flavor = MathHelper.nextInt(this.getMinecraft().level.random, 2, 7);
}
this.bookletName = "info." + ActuallyAdditions.MODID + ".booklet.manualName.1." + flavor;
String usedQuote = QUOTES[this.getMinecraft().level.random.nextInt(QUOTES.length)];
String[] quoteSplit = usedQuote.split("@");
if (quoteSplit.length == 2) {
//this.quote = this.font.listFormattedStringToWidth(quoteSplit[0], 120); //TODO wut
this.quoteGuy = quoteSplit[1];
}
String playerName = this.getMinecraft().player.getName().getString();
if (playerName.equalsIgnoreCase("dqmhose")) {
this.bookletEdition = "Pants Edition";
} else if (playerName.equalsIgnoreCase("TwoOfEight") || playerName.equalsIgnoreCase("BootyToast")) {
this.bookletEdition = "Illustrator's Edition";
} else if (playerName.equalsIgnoreCase("KittyVanCat")) {
this.bookletEdition = "Cat's Edition";
} else if (playerName.equalsIgnoreCase("canitzp")) {
this.bookletEdition = "P's Edition";
} else if (playerName.equalsIgnoreCase("direwolf20")) {
this.bookletEdition = "Edition 20";
} else if (playerName.equalsIgnoreCase("dannydjdk") || playerName.equalsIgnoreCase("andrew_period")) {
this.bookletEdition = "Derp's Edition";
} else if (playerName.equalsIgnoreCase("mezz")) {
this.bookletEdition = "Just Enough Editions";
} else if (playerName.equalsIgnoreCase("amadornes")) {
this.bookletEdition = "Beard's Edition";
} else if (playerName.equalsIgnoreCase("raoul")) {
this.bookletEdition = "Giraffe's Edition";
} else if (playerName.equalsIgnoreCase("ellpeck") || playerName.equalsIgnoreCase("profprospector")) {
String[] colors = new String[15];
for (int i = 0; i < colors.length; i++) {
colors[i] = TextFormatting.getById(this.getMinecraft().level.random.nextInt(15)).toString() + TextFormatting.ITALIC;
}
this.bookletEdition = String.format("%sC%so%sl%so%sr%sf%su%sl %sE%sd%si%st%si%so%sn", (Object[]) colors);
} else if (playerName.equalsIgnoreCase("oitsjustjose")) {
this.bookletEdition = "oitsjustanedition";
} else if (playerName.equalsIgnoreCase("xbony2")) {
this.bookletEdition = "Naughty Edition";
} else if (playerName.equalsIgnoreCase("themattabase")) {
this.bookletEdition = "Withered Edition";
} else if (playerName.equalsIgnoreCase("robsonld04")) {
this.bookletEdition = "Modpack Edition";
} else if (playerName.equalsIgnoreCase("snowshock35")) {
this.bookletEdition = "Edition 35";
} else if (playerName.equalsIgnoreCase("asiekierka")) {
this.bookletEdition = "‽ Edition";
} else if (playerName.equalsIgnoreCase("elucent")) {
this.bookletEdition = "";
} else {
if (Util.isDevVersion()) {
this.bookletEdition = "Dev's Edition";
} else {
this.bookletEdition = StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.edition") + " " + Util.getMajorModVersion();
}
}
List<String> configText = new ArrayList<>();
configText.add(TextFormatting.GOLD + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".configButton.name"));
//configText.addAll(this.font.listFormattedStringToWidth(StringUtil.localizeFormatted("booklet." + ActuallyAdditions.MODID + ".configButton.desc", ActuallyAdditions.NAME).replaceAll("\\\\n", "\n"), 200)); //TODO wut
this.configButton = new TexturedButton(RES_LOC_GADGETS, this.guiLeft + 16, this.guiTop + this.ySize - 30, 188, 14, 16, 16, configText, btn -> {
});
this.addButton(this.configButton);
List<String> achievementText = new ArrayList<>();
achievementText.add(TextFormatting.GOLD + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".achievementButton.name"));
//achievementText.addAll(this.font.listFormattedStringToWidth(StringUtil.localizeFormatted("booklet." + ActuallyAdditions.MODID + ".achievementButton.desc", ActuallyAdditions.NAME), 200)); //TODO wut
//this.achievementButton = new TexturedButton(RES_LOC_GADGETS, -389, this.guiLeft+36, this.guiTop+this.ySize-30, 204, 14, 16, 16, achievementText);
//this.addButton(this.achievementButton);
PlayerSave data = PlayerData.getDataFromPlayer(this.getMinecraft().player);
if (!data.didBookTutorial) {
this.showTutorial = true;
//this.tutorialButton = new GuiButton(666666, this.guiLeft + 140 / 2 - 50, this.guiTop + 146, 100, 20, "Please click me <3");
this.addButton(this.tutorialButton);
this.configButton.visible = false;
//this.achievementButton.visible = false;
}
for (int i = 0; i < BUTTONS_PER_PAGE; i++) {
List<IBookletEntry> displayed = getDisplayedEntries();
if (displayed.size() > i) {
IBookletEntry entry = displayed.get(i);
this.addButton(new EntryButton(this, i, this.guiLeft + 156, this.guiTop + 11 + i * 13, 115, 10, "- " + entry.getLocalizedNameWithFormatting(), ItemStack.EMPTY));
} else {
return;
}
}
}
/*
@Override
protected void actionPerformed(GuiButton button) throws IOException {
if (button instanceof EntryButton) {
List<IBookletEntry> displayed = getDisplayedEntries();
if (displayed.size() > button.id) {
IBookletEntry entry = displayed.get(button.id);
if (entry != null) {
this.getMinecraft().setScreen(new GuiEntry(this.previousScreen, this, entry, 0, "", false));
}
}
}
/*else if(button == this.achievementButton){
GuiScreen achievements = new GuiAAAchievements(this, this.getMinecraft().player.getStatFileWriter());
this.getMinecraft().displayGuiScreen(achievements);
}*/
/*
else if (button == this.configButton) {
GuiScreen config = new GuiConfiguration(this);
this.getMinecraft().setScreen(config);
} else if (this.showTutorial && button == this.tutorialButton) {
if (this.hasBookmarkButtons()) {
if (!isShiftKeyDown()) {
for (int i = 0; i < InitBooklet.chaptersIntroduction.length; i++) {
this.bookmarkButtons[i].assignedPage = InitBooklet.chaptersIntroduction[i].getAllPages()[0];
}
}
this.showTutorial = false;
this.tutorialButton.visible = false;
this.configButton.visible = true;
//this.achievementButton.visible = true;
PlayerSave data = PlayerData.getDataFromPlayer(this.getMinecraft().player);
data.didBookTutorial = true;
PacketHandlerHelper.sendPlayerDataToServer(false, 1);
}
} else {
super.actionPerformed(button);
}
}
*/
@Override
public void drawScreenPre(MatrixStack stack, int mouseX, int mouseY, float partialTicks) {
super.drawScreenPre(stack, mouseX, mouseY, partialTicks);
String strg = TextFormatting.DARK_GREEN + StringUtil.localize(this.bookletName);
this.font.draw(stack, strg, this.guiLeft + 72 - this.font.width(strg) / 2 - 3, this.guiTop + 19, 0);
strg = TextFormatting.DARK_GREEN + StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.manualName.2");
this.font.draw(stack, strg, this.guiLeft + 72 - this.font.width(strg) / 2 - 3, this.guiTop + 19 + this.font.lineHeight, 0);
strg = TextFormatting.GOLD + TextFormatting.ITALIC.toString() + this.bookletEdition;
this.font.draw(stack, strg, this.guiLeft + 72 - this.font.width(strg) / 2 - 3, this.guiTop + 40, 0);
if (this.showTutorial) {
String text = TextFormatting.BLUE + "It looks like this is the first time you are using this manual. \nIf you click the button below, some useful bookmarks will be stored at the bottom of the GUI. You should definitely check them out to get started with " + ActuallyAdditions.NAME + "! \nIf you don't want this, shift-click the button.";
this.renderSplitScaledAsciiString(text, this.guiLeft + 11, this.guiTop + 55, 0, false, this.getMediumFontSize(), 120);
} else if (this.quote != null && !this.quote.isEmpty() && this.quoteGuy != null) {
int quoteSize = this.quote.size();
for (int i = 0; i < quoteSize; i++) {
this.renderScaledAsciiString(TextFormatting.ITALIC + this.quote.get(i), this.guiLeft + 25, this.guiTop + 90 + i * 8, 0, false, this.getMediumFontSize());
}
this.renderScaledAsciiString("- " + this.quoteGuy, this.guiLeft + 60, this.guiTop + 93 + quoteSize * 8, 0, false, this.getLargeFontSize());
}
}
@Override
public void addOrModifyItemRenderer(ItemStack renderedStack, int x, int y, float scale, boolean shouldTryTransfer) {
}
}
///*
// * This file ("GuiMainPage.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet.gui;
//
//import com.mojang.blaze3d.matrix.MatrixStack;
//import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
//import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
//import de.ellpeck.actuallyadditions.mod.booklet.InitBooklet;
//import de.ellpeck.actuallyadditions.mod.booklet.button.EntryButton;
//import de.ellpeck.actuallyadditions.mod.data.PlayerData;
//import de.ellpeck.actuallyadditions.mod.data.PlayerData.PlayerSave;
//import de.ellpeck.actuallyadditions.mod.inventory.gui.TexturedButton;
//import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
//import de.ellpeck.actuallyadditions.mod.util.Util;
//import net.minecraft.client.gui.screen.Screen;
//import net.minecraft.client.gui.widget.button.Button;
//import net.minecraft.item.ItemStack;
//import net.minecraft.util.math.MathHelper;
//import net.minecraft.util.text.TextFormatting;
//import net.minecraftforge.api.distmarker.Dist;
//import net.minecraftforge.api.distmarker.OnlyIn;
//
//import java.io.IOException;
//import java.util.ArrayList;
//import java.util.List;
//
////TODO Fix achievement button
//@OnlyIn(Dist.CLIENT)
//public class GuiMainPage extends GuiBooklet {
//
// private static final String[] QUOTES = new String[]{"Actually Additions, to me, is quite magical in a way.@Saphrym", "Actually quite cool. Lots of nice little additions.@Direwolf20", "Mod Dev quite rude and arrogant@Bubb1e0seven", "A whimsical breath of fresh air in a stuffy tech-mod world.@mezz", "User-friendly :3@TheMeeep", "A lot of stuff, some of it really good.@Narubion", "I like the bookmarks.@Vazkii", "It's got some stuff I guess.@Ellpeck", "Actually Additions should be included in every new modpack that includes any form of tech.@YasminEndusa", "A mod that basically lets you do what ever the heck you want.@Ristelle", "TINY TORCHES!! BABY TORCHES!! Somebody actually finally did it!!@Soaryn", "Balanced mod wich makes things different - in a good way.@garantiertnicht", "The mod everyone needs, but not everyone knows@Brewpl", "The in-game documentation is the best Ive seen. I especially love the JEI integration. Even a derp like me can figure it out.@dannydjdk", "The second best mod I've ever used.@mmaas44", "The Fermenting Barrel is one of my favorite textures.@amadornes", "Smiley Clouds is the reason for fascism in 2016.@raoulvdberge", "The worms are an awesome idea!@greenking", "Can I use that mod in my pack?@Ibraheem", "Hello, love the mod.@SuntannedDuck2", "Quick! Have all the fun before they nerf it!@JuddMan03", "I have a feeling Actually Additions is also like Extra Utilities with Random things smashed together why is it...@lesslighter", "Leaf eater... munchdew... hummm@EiOs", "There is no such thing as canola seeds.@AlBoVa", "This mod is cancer, BRUTAL EXPENSIVE POWER usage..Just, cancer.@KoJo", "Spaghetti is spaghetti, and noodles are noodles.@robsonld04", "The Actually Additions name is actually true. It's actually great!@asiekierka", "Such a great mod@jsdeveloper", "That mod is kind of funny.@Anonymous", "Actually Additions is a lot of fun.@Anonymous", "Is Actually Additions still fugly?@Anonymous", "I like it, but it's so small.@Anonymous", "It has a couple of blocks I like, but overall it's just a mess.@Anonymous", "Direwolf's 1.10 playthrough is just him shilling Actually Additions@Anonymous", "We thought about sending the author a bunch of pizzas to his adress@Anonymous", "It's op as heck.@billofbong0", "Actually AdditionsってマイクラMODすごく良いのに日本人で遊んでる人あんまいないっぽい@stay_uk", "Actually Additions is OP. Not like my favorite combination of mods, Project E + Magic Crops + Draconic Evolution.@Anonymous", "To be perfectly honest, I never actually realized how much content Actually Additions has before.@Ellpeck", "I don't blame you, I actually downgraded to Actually Additions.@PvtSeaCow", "It is lonely because there is no device to fly items with the laser in the 1.7.10 version.@Google Translate", "始めまして。日本人です。このMODは本当に素晴らしいただ、1.7.10ヴァージョンだと、レーザーでアイテムを飛ばす装置がないので寂しいです。@Anonymous", "Some verses found in older translations, such as the KJV were actually additions made by later copyists.@Pat_Joel", "I can't place filters into Laser Relays, but the mod is very cool.@LP_Jakob", "Am I good enough to be an Actually Additions tool?@deanwhufc"};
//
// //private TexturedButton achievementButton;
// private TexturedButton configButton;
//
// private Button tutorialButton;
// private boolean showTutorial;
//
// private String bookletName;
// private String bookletEdition;
//
// private List<String> quote;
// private String quoteGuy;
//
// public GuiMainPage(Screen previousScreen) {
// super(previousScreen, null);
// }
//
// private static List<IBookletEntry> getDisplayedEntries() {
// List<IBookletEntry> displayed = new ArrayList<>();
//
// for (IBookletEntry entry : ActuallyAdditionsAPI.BOOKLET_ENTRIES) {
// if (entry.visibleOnFrontPage()) {
// displayed.add(entry);
// }
// }
//
// return displayed;
// }
//
// @Override
// public void init() {
// super.init();
//
// int flavor = 1;
// if (this.getMinecraft().level.random.nextFloat() <= 0.1) {
// flavor = MathHelper.nextInt(this.getMinecraft().level.random, 2, 7);
// }
// this.bookletName = "info." + ActuallyAdditions.MODID + ".booklet.manualName.1." + flavor;
//
// String usedQuote = QUOTES[this.getMinecraft().level.random.nextInt(QUOTES.length)];
// String[] quoteSplit = usedQuote.split("@");
// if (quoteSplit.length == 2) {
// //this.quote = this.font.listFormattedStringToWidth(quoteSplit[0], 120); //TODO wut
// this.quoteGuy = quoteSplit[1];
// }
//
// String playerName = this.getMinecraft().player.getName().getString();
// if (playerName.equalsIgnoreCase("dqmhose")) {
// this.bookletEdition = "Pants Edition";
// } else if (playerName.equalsIgnoreCase("TwoOfEight") || playerName.equalsIgnoreCase("BootyToast")) {
// this.bookletEdition = "Illustrator's Edition";
// } else if (playerName.equalsIgnoreCase("KittyVanCat")) {
// this.bookletEdition = "Cat's Edition";
// } else if (playerName.equalsIgnoreCase("canitzp")) {
// this.bookletEdition = "P's Edition";
// } else if (playerName.equalsIgnoreCase("direwolf20")) {
// this.bookletEdition = "Edition 20";
// } else if (playerName.equalsIgnoreCase("dannydjdk") || playerName.equalsIgnoreCase("andrew_period")) {
// this.bookletEdition = "Derp's Edition";
// } else if (playerName.equalsIgnoreCase("mezz")) {
// this.bookletEdition = "Just Enough Editions";
// } else if (playerName.equalsIgnoreCase("amadornes")) {
// this.bookletEdition = "Beard's Edition";
// } else if (playerName.equalsIgnoreCase("raoul")) {
// this.bookletEdition = "Giraffe's Edition";
// } else if (playerName.equalsIgnoreCase("ellpeck") || playerName.equalsIgnoreCase("profprospector")) {
// String[] colors = new String[15];
// for (int i = 0; i < colors.length; i++) {
// colors[i] = TextFormatting.getById(this.getMinecraft().level.random.nextInt(15)).toString() + TextFormatting.ITALIC;
// }
// this.bookletEdition = String.format("%sC%so%sl%so%sr%sf%su%sl %sE%sd%si%st%si%so%sn", (Object[]) colors);
// } else if (playerName.equalsIgnoreCase("oitsjustjose")) {
// this.bookletEdition = "oitsjustanedition";
// } else if (playerName.equalsIgnoreCase("xbony2")) {
// this.bookletEdition = "Naughty Edition";
// } else if (playerName.equalsIgnoreCase("themattabase")) {
// this.bookletEdition = "Withered Edition";
// } else if (playerName.equalsIgnoreCase("robsonld04")) {
// this.bookletEdition = "Modpack Edition";
// } else if (playerName.equalsIgnoreCase("snowshock35")) {
// this.bookletEdition = "Edition 35";
// } else if (playerName.equalsIgnoreCase("asiekierka")) {
// this.bookletEdition = "‽ Edition";
// } else if (playerName.equalsIgnoreCase("elucent")) {
// this.bookletEdition = "";
// } else {
// if (Util.isDevVersion()) {
// this.bookletEdition = "Dev's Edition";
// } else {
// this.bookletEdition = StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.edition") + " " + Util.getMajorModVersion();
// }
// }
//
// List<String> configText = new ArrayList<>();
// configText.add(TextFormatting.GOLD + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".configButton.name"));
// //configText.addAll(this.font.listFormattedStringToWidth(StringUtil.localizeFormatted("booklet." + ActuallyAdditions.MODID + ".configButton.desc", ActuallyAdditions.NAME).replaceAll("\\\\n", "\n"), 200)); //TODO wut
// this.configButton = new TexturedButton(RES_LOC_GADGETS, this.guiLeft + 16, this.guiTop + this.ySize - 30, 188, 14, 16, 16, configText, btn -> {
// });
// this.addButton(this.configButton);
//
// List<String> achievementText = new ArrayList<>();
// achievementText.add(TextFormatting.GOLD + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".achievementButton.name"));
// //achievementText.addAll(this.font.listFormattedStringToWidth(StringUtil.localizeFormatted("booklet." + ActuallyAdditions.MODID + ".achievementButton.desc", ActuallyAdditions.NAME), 200)); //TODO wut
// //this.achievementButton = new TexturedButton(RES_LOC_GADGETS, -389, this.guiLeft+36, this.guiTop+this.ySize-30, 204, 14, 16, 16, achievementText);
// //this.addButton(this.achievementButton);
//
// PlayerSave data = PlayerData.getDataFromPlayer(this.getMinecraft().player);
// if (!data.didBookTutorial) {
// this.showTutorial = true;
//
// //this.tutorialButton = new GuiButton(666666, this.guiLeft + 140 / 2 - 50, this.guiTop + 146, 100, 20, "Please click me <3");
// this.addButton(this.tutorialButton);
//
// this.configButton.visible = false;
// //this.achievementButton.visible = false;
// }
//
// for (int i = 0; i < BUTTONS_PER_PAGE; i++) {
// List<IBookletEntry> displayed = getDisplayedEntries();
// if (displayed.size() > i) {
// IBookletEntry entry = displayed.get(i);
// this.addButton(new EntryButton(this, i, this.guiLeft + 156, this.guiTop + 11 + i * 13, 115, 10, "- " + entry.getLocalizedNameWithFormatting(), ItemStack.EMPTY));
// } else {
// return;
// }
// }
// }
///*
// @Override
// protected void actionPerformed(GuiButton button) throws IOException {
// if (button instanceof EntryButton) {
// List<IBookletEntry> displayed = getDisplayedEntries();
// if (displayed.size() > button.id) {
// IBookletEntry entry = displayed.get(button.id);
// if (entry != null) {
// this.getMinecraft().setScreen(new GuiEntry(this.previousScreen, this, entry, 0, "", false));
// }
// }
// }
// /*else if(button == this.achievementButton){
// GuiScreen achievements = new GuiAAAchievements(this, this.getMinecraft().player.getStatFileWriter());
// this.getMinecraft().displayGuiScreen(achievements);
// }*/
// /*
// else if (button == this.configButton) {
// GuiScreen config = new GuiConfiguration(this);
// this.getMinecraft().setScreen(config);
// } else if (this.showTutorial && button == this.tutorialButton) {
// if (this.hasBookmarkButtons()) {
// if (!isShiftKeyDown()) {
// for (int i = 0; i < InitBooklet.chaptersIntroduction.length; i++) {
// this.bookmarkButtons[i].assignedPage = InitBooklet.chaptersIntroduction[i].getAllPages()[0];
// }
// }
// this.showTutorial = false;
// this.tutorialButton.visible = false;
//
// this.configButton.visible = true;
// //this.achievementButton.visible = true;
//
// PlayerSave data = PlayerData.getDataFromPlayer(this.getMinecraft().player);
// data.didBookTutorial = true;
// PacketHandlerHelper.sendPlayerDataToServer(false, 1);
// }
// } else {
// super.actionPerformed(button);
// }
// }
// */
// @Override
// public void drawScreenPre(MatrixStack stack, int mouseX, int mouseY, float partialTicks) {
// super.drawScreenPre(stack, mouseX, mouseY, partialTicks);
//
// String strg = TextFormatting.DARK_GREEN + StringUtil.localize(this.bookletName);
// this.font.draw(stack, strg, this.guiLeft + 72 - this.font.width(strg) / 2 - 3, this.guiTop + 19, 0);
// strg = TextFormatting.DARK_GREEN + StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.manualName.2");
// this.font.draw(stack, strg, this.guiLeft + 72 - this.font.width(strg) / 2 - 3, this.guiTop + 19 + this.font.lineHeight, 0);
//
// strg = TextFormatting.GOLD + TextFormatting.ITALIC.toString() + this.bookletEdition;
// this.font.draw(stack, strg, this.guiLeft + 72 - this.font.width(strg) / 2 - 3, this.guiTop + 40, 0);
//
// if (this.showTutorial) {
// String text = TextFormatting.BLUE + "It looks like this is the first time you are using this manual. \nIf you click the button below, some useful bookmarks will be stored at the bottom of the GUI. You should definitely check them out to get started with " + ActuallyAdditions.NAME + "! \nIf you don't want this, shift-click the button.";
// this.renderSplitScaledAsciiString(text, this.guiLeft + 11, this.guiTop + 55, 0, false, this.getMediumFontSize(), 120);
// } else if (this.quote != null && !this.quote.isEmpty() && this.quoteGuy != null) {
// int quoteSize = this.quote.size();
//
// for (int i = 0; i < quoteSize; i++) {
// this.renderScaledAsciiString(TextFormatting.ITALIC + this.quote.get(i), this.guiLeft + 25, this.guiTop + 90 + i * 8, 0, false, this.getMediumFontSize());
// }
// this.renderScaledAsciiString("- " + this.quoteGuy, this.guiLeft + 60, this.guiTop + 93 + quoteSize * 8, 0, false, this.getLargeFontSize());
// }
// }
//
// @Override
// public void addOrModifyItemRenderer(ItemStack renderedStack, int x, int y, float scale, boolean shouldTryTransfer) {
//
// }
//}

View file

@ -1,289 +1,289 @@
/*
* This file ("GuiPage.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.gui;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
import de.ellpeck.actuallyadditions.mod.booklet.page.ItemDisplay;
import de.ellpeck.actuallyadditions.mod.inventory.gui.TexturedButton;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import java.awt.*;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@OnlyIn(Dist.CLIENT)
public class GuiPage extends GuiBooklet {
public final IBookletPage[] pages = new IBookletPage[2];
private final List<ItemDisplay> itemDisplays = new ArrayList<>();
private int pageTimer;
private Button buttonViewOnline;
public GuiPage(Screen previousScreen, GuiBookletBase parentPage, IBookletPage page1, IBookletPage page2) {
super(previousScreen, parentPage);
this.pages[0] = page1;
this.pages[1] = page2;
}
@Override
public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
super.mouseClicked(mouseX, mouseY, mouseButton);
for (ItemDisplay display : this.itemDisplays) {
display.onMousePress(mouseButton, mouseX, mouseY);
}
for (IBookletPage page : this.pages) {
if (page != null) {
page.mouseClicked(this, mouseX, mouseY, mouseButton);
}
}
}
@Override
public void mouseReleased(int mouseX, int mouseY, int state) {
super.mouseReleased(mouseX, mouseY, state);
for (IBookletPage page : this.pages) {
if (page != null) {
page.mouseReleased(this, mouseX, mouseY, state);
}
}
}
@Override
public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
for (IBookletPage page : this.pages) {
if (page != null) {
page.mouseClickMove(this, mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
}
}
}
/*
@Override
public void actionPerformed(GuiButton button) throws IOException {
if (button == this.buttonViewOnline) {
List<String> links = this.getWebLinks();
if (Desktop.isDesktopSupported()) {
for (String link : links) {
try {
Desktop.getDesktop().browse(new URI(link));
} catch (Exception e) {
ActuallyAdditions.LOGGER.error("Couldn't open website from Booklet page!", e);
}
}
}
} else {
super.actionPerformed(button);
for (IBookletPage page : this.pages) {
if (page != null) {
page.actionPerformed(this, button);
}
}
}
}
*/
@Override
public void init() {
this.itemDisplays.clear();
super.init();
List<String> links = this.getWebLinks();
if (links != null && !links.isEmpty()) {
this.buttonViewOnline = new TexturedButton(RES_LOC_GADGETS, this.guiLeft + this.xSize - 24, this.guiTop + this.ySize - 25, 0, 172, 16, 16, Collections.singletonList(TextFormatting.GOLD + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".onlineButton.name")), btn -> {
});
this.addButton(this.buttonViewOnline);
}
for (int i = 0; i < this.pages.length; i++) {
IBookletPage page = this.pages[i];
if (page != null) {
page.init(this, this.guiLeft + 6 + i * 142, this.guiTop + 7);
}
}
}
private List<String> getWebLinks() {
List<String> links = new ArrayList<>();
for (IBookletPage page : this.pages) {
if (page != null) {
String link = page.getWebLink();
if (link != null && !links.contains(link)) {
links.add(link);
}
}
}
return links;
}
@Override
public void tick() {
super.tick();
for (int i = 0; i < this.pages.length; i++) {
IBookletPage page = this.pages[i];
if (page != null) {
page.updateScreen(this, this.guiLeft + 6 + i * 142, this.guiTop + 7, this.pageTimer);
}
}
this.pageTimer++;
}
@Override
public void drawScreenPre(MatrixStack stack, int mouseX, int mouseY, float partialTicks) {
super.drawScreenPre(stack, mouseX, mouseY, partialTicks);
if (this.pages[0] != null) {
IBookletChapter chapter = this.pages[0].getChapter();
String name = chapter.getLocalizedName();
this.font.draw(stack, name, this.guiLeft + this.xSize / 2 - this.font.width(name) / 2, this.guiTop - 1, 0xFFFFFF);
}
for (int i = 0; i < this.pages.length; i++) {
IBookletPage page = this.pages[i];
if (page != null) {
IBookletChapter chapter = this.pages[i].getChapter();
String pageStrg = "Page " + (chapter.getPageIndex(this.pages[i]) + 1) + "/" + chapter.getAllPages().length;
this.renderScaledAsciiString(pageStrg, this.guiLeft + 25 + i * 136, this.guiTop + this.ySize - 7, 0xFFFFFF, false, this.getLargeFontSize());
RenderSystem.color3f(1f, 1f, 1f);
page.drawScreenPre(this, this.guiLeft + 6 + i * 142, this.guiTop + 7, mouseX, mouseY, partialTicks);
}
}
for (ItemDisplay display : this.itemDisplays) {
display.drawPre();
}
}
@Override
public void drawScreenPost(MatrixStack stack, int mouseX, int mouseY, float partialTicks) {
super.drawScreenPost(stack, mouseX, mouseY, partialTicks);
for (int i = 0; i < this.pages.length; i++) {
IBookletPage page = this.pages[i];
if (page != null) {
RenderSystem.color3f(1F, 1F, 1F);
page.drawScreenPost(this, this.guiLeft + 6 + i * 142, this.guiTop + 7, mouseX, mouseY, partialTicks);
}
}
for (ItemDisplay display : this.itemDisplays) {
display.drawPost(mouseX, mouseY);
}
}
@Override
public void addOrModifyItemRenderer(ItemStack renderedStack, int x, int y, float scale, boolean shouldTryTransfer) {
for (ItemDisplay display : this.itemDisplays) {
if (display.x == x && display.y == y && display.scale == scale) {
display.stack = renderedStack;
return;
}
}
this.itemDisplays.add(new ItemDisplay(this, x, y, scale, renderedStack, shouldTryTransfer));
}
@Override
public boolean hasPageLeftButton() {
IBookletPage page = this.pages[0];
if (page != null) {
IBookletChapter chapter = page.getChapter();
if (chapter != null) {
return chapter.getPageIndex(page) > 0;
}
}
return false;
}
@Override
public void onPageLeftButtonPressed() {
IBookletPage page = this.pages[0];
if (page != null) {
IBookletChapter chapter = page.getChapter();
if (chapter != null) {
IBookletPage[] pages = chapter.getAllPages();
int pageNumToOpen = chapter.getPageIndex(page) - 1;
if (pageNumToOpen >= 0 && pageNumToOpen < pages.length) {
this.minecraft.setScreen(BookletUtils.createPageGui(this.previousScreen, this.parentPage, pages[pageNumToOpen]));
}
}
}
}
@Override
public boolean hasPageRightButton() {
IBookletPage page = this.pages[1];
if (page != null) {
IBookletChapter chapter = page.getChapter();
if (chapter != null) {
int pageIndex = chapter.getPageIndex(page);
int pageAmount = chapter.getAllPages().length;
return pageIndex + 1 < pageAmount;
}
}
return false;
}
@Override
public void onPageRightButtonPressed() {
IBookletPage page = this.pages[1];
if (page != null) {
IBookletChapter chapter = page.getChapter();
if (chapter != null) {
IBookletPage[] pages = chapter.getAllPages();
int pageNumToOpen = chapter.getPageIndex(page) + 1;
if (pageNumToOpen >= 0 && pageNumToOpen < pages.length) {
this.minecraft.setScreen(BookletUtils.createPageGui(this.previousScreen, this.parentPage, pages[pageNumToOpen]));
}
}
}
}
@Override
public boolean hasBackButton() {
return true;
}
@Override
public void onBackButtonPressed() {
if (!hasShiftDown()) {
this.minecraft.setScreen(this.parentPage);
} else {
super.onBackButtonPressed();
}
}
}
///*
// * This file ("GuiPage.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet.gui;
//
//import com.mojang.blaze3d.matrix.MatrixStack;
//import com.mojang.blaze3d.platform.GlStateManager;
//import com.mojang.blaze3d.systems.RenderSystem;
//import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
//import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
//import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
//import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
//import de.ellpeck.actuallyadditions.mod.booklet.page.ItemDisplay;
//import de.ellpeck.actuallyadditions.mod.inventory.gui.TexturedButton;
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
//import net.minecraft.client.gui.screen.Screen;
//import net.minecraft.client.gui.widget.button.Button;
//import net.minecraft.item.ItemStack;
//import net.minecraft.util.text.TextFormatting;
//import net.minecraftforge.api.distmarker.Dist;
//import net.minecraftforge.api.distmarker.OnlyIn;
//
//import java.awt.*;
//import java.io.IOException;
//import java.net.URI;
//import java.util.ArrayList;
//import java.util.Collections;
//import java.util.List;
//
//@OnlyIn(Dist.CLIENT)
//public class GuiPage extends GuiBooklet {
//
// public final IBookletPage[] pages = new IBookletPage[2];
// private final List<ItemDisplay> itemDisplays = new ArrayList<>();
// private int pageTimer;
//
// private Button buttonViewOnline;
//
// public GuiPage(Screen previousScreen, GuiBookletBase parentPage, IBookletPage page1, IBookletPage page2) {
// super(previousScreen, parentPage);
//
// this.pages[0] = page1;
// this.pages[1] = page2;
// }
//
// @Override
// public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
// super.mouseClicked(mouseX, mouseY, mouseButton);
//
// for (ItemDisplay display : this.itemDisplays) {
// display.onMousePress(mouseButton, mouseX, mouseY);
// }
//
// for (IBookletPage page : this.pages) {
// if (page != null) {
// page.mouseClicked(this, mouseX, mouseY, mouseButton);
// }
// }
// }
//
// @Override
// public void mouseReleased(int mouseX, int mouseY, int state) {
// super.mouseReleased(mouseX, mouseY, state);
//
// for (IBookletPage page : this.pages) {
// if (page != null) {
// page.mouseReleased(this, mouseX, mouseY, state);
// }
// }
// }
//
// @Override
// public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
// super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
//
// for (IBookletPage page : this.pages) {
// if (page != null) {
// page.mouseClickMove(this, mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
// }
// }
// }
///*
// @Override
// public void actionPerformed(GuiButton button) throws IOException {
// if (button == this.buttonViewOnline) {
// List<String> links = this.getWebLinks();
// if (Desktop.isDesktopSupported()) {
// for (String link : links) {
// try {
// Desktop.getDesktop().browse(new URI(link));
// } catch (Exception e) {
// ActuallyAdditions.LOGGER.error("Couldn't open website from Booklet page!", e);
// }
// }
// }
// } else {
// super.actionPerformed(button);
//
// for (IBookletPage page : this.pages) {
// if (page != null) {
// page.actionPerformed(this, button);
// }
// }
// }
// }
// */
// @Override
// public void init() {
// this.itemDisplays.clear();
// super.init();
//
// List<String> links = this.getWebLinks();
// if (links != null && !links.isEmpty()) {
// this.buttonViewOnline = new TexturedButton(RES_LOC_GADGETS, this.guiLeft + this.xSize - 24, this.guiTop + this.ySize - 25, 0, 172, 16, 16, Collections.singletonList(TextFormatting.GOLD + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".onlineButton.name")), btn -> {
// });
// this.addButton(this.buttonViewOnline);
// }
//
// for (int i = 0; i < this.pages.length; i++) {
// IBookletPage page = this.pages[i];
// if (page != null) {
// page.init(this, this.guiLeft + 6 + i * 142, this.guiTop + 7);
// }
// }
// }
//
// private List<String> getWebLinks() {
// List<String> links = new ArrayList<>();
//
// for (IBookletPage page : this.pages) {
// if (page != null) {
// String link = page.getWebLink();
// if (link != null && !links.contains(link)) {
// links.add(link);
// }
// }
// }
//
// return links;
// }
//
// @Override
// public void tick() {
// super.tick();
//
// for (int i = 0; i < this.pages.length; i++) {
// IBookletPage page = this.pages[i];
// if (page != null) {
// page.updateScreen(this, this.guiLeft + 6 + i * 142, this.guiTop + 7, this.pageTimer);
// }
// }
//
// this.pageTimer++;
// }
//
// @Override
// public void drawScreenPre(MatrixStack stack, int mouseX, int mouseY, float partialTicks) {
// super.drawScreenPre(stack, mouseX, mouseY, partialTicks);
//
// if (this.pages[0] != null) {
// IBookletChapter chapter = this.pages[0].getChapter();
// String name = chapter.getLocalizedName();
// this.font.draw(stack, name, this.guiLeft + this.xSize / 2 - this.font.width(name) / 2, this.guiTop - 1, 0xFFFFFF);
// }
//
// for (int i = 0; i < this.pages.length; i++) {
// IBookletPage page = this.pages[i];
// if (page != null) {
// IBookletChapter chapter = this.pages[i].getChapter();
// String pageStrg = "Page " + (chapter.getPageIndex(this.pages[i]) + 1) + "/" + chapter.getAllPages().length;
// this.renderScaledAsciiString(pageStrg, this.guiLeft + 25 + i * 136, this.guiTop + this.ySize - 7, 0xFFFFFF, false, this.getLargeFontSize());
//
// RenderSystem.color3f(1f, 1f, 1f);
// page.drawScreenPre(this, this.guiLeft + 6 + i * 142, this.guiTop + 7, mouseX, mouseY, partialTicks);
// }
// }
// for (ItemDisplay display : this.itemDisplays) {
// display.drawPre();
// }
// }
//
// @Override
// public void drawScreenPost(MatrixStack stack, int mouseX, int mouseY, float partialTicks) {
// super.drawScreenPost(stack, mouseX, mouseY, partialTicks);
//
// for (int i = 0; i < this.pages.length; i++) {
// IBookletPage page = this.pages[i];
// if (page != null) {
// RenderSystem.color3f(1F, 1F, 1F);
// page.drawScreenPost(this, this.guiLeft + 6 + i * 142, this.guiTop + 7, mouseX, mouseY, partialTicks);
// }
// }
// for (ItemDisplay display : this.itemDisplays) {
// display.drawPost(mouseX, mouseY);
// }
// }
//
// @Override
// public void addOrModifyItemRenderer(ItemStack renderedStack, int x, int y, float scale, boolean shouldTryTransfer) {
// for (ItemDisplay display : this.itemDisplays) {
// if (display.x == x && display.y == y && display.scale == scale) {
// display.stack = renderedStack;
// return;
// }
// }
//
// this.itemDisplays.add(new ItemDisplay(this, x, y, scale, renderedStack, shouldTryTransfer));
// }
//
// @Override
// public boolean hasPageLeftButton() {
// IBookletPage page = this.pages[0];
// if (page != null) {
// IBookletChapter chapter = page.getChapter();
// if (chapter != null) {
// return chapter.getPageIndex(page) > 0;
// }
// }
// return false;
// }
//
// @Override
// public void onPageLeftButtonPressed() {
// IBookletPage page = this.pages[0];
// if (page != null) {
// IBookletChapter chapter = page.getChapter();
// if (chapter != null) {
// IBookletPage[] pages = chapter.getAllPages();
//
// int pageNumToOpen = chapter.getPageIndex(page) - 1;
// if (pageNumToOpen >= 0 && pageNumToOpen < pages.length) {
// this.minecraft.setScreen(BookletUtils.createPageGui(this.previousScreen, this.parentPage, pages[pageNumToOpen]));
// }
// }
// }
// }
//
// @Override
// public boolean hasPageRightButton() {
// IBookletPage page = this.pages[1];
// if (page != null) {
// IBookletChapter chapter = page.getChapter();
// if (chapter != null) {
// int pageIndex = chapter.getPageIndex(page);
// int pageAmount = chapter.getAllPages().length;
// return pageIndex + 1 < pageAmount;
// }
// }
// return false;
// }
//
// @Override
// public void onPageRightButtonPressed() {
// IBookletPage page = this.pages[1];
// if (page != null) {
// IBookletChapter chapter = page.getChapter();
// if (chapter != null) {
// IBookletPage[] pages = chapter.getAllPages();
//
// int pageNumToOpen = chapter.getPageIndex(page) + 1;
// if (pageNumToOpen >= 0 && pageNumToOpen < pages.length) {
// this.minecraft.setScreen(BookletUtils.createPageGui(this.previousScreen, this.parentPage, pages[pageNumToOpen]));
// }
// }
// }
// }
//
// @Override
// public boolean hasBackButton() {
// return true;
// }
//
// @Override
// public void onBackButtonPressed() {
// if (!hasShiftDown()) {
// this.minecraft.setScreen(this.parentPage);
// } else {
// super.onBackButtonPressed();
// }
// }
//}

View file

@ -1,92 +1,92 @@
/*
* This file ("BookletUtils.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.misc;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiEntry;
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiMainPage;
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiPage;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import java.util.List;
public final class BookletUtils {
public static IBookletPage findFirstPageForStack(ItemStack stack) {
for (IBookletPage page : ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA) {
List<ItemStack> stacks = NonNullList.create();
page.getItemStacksForPage(stacks);
if (stacks != null && !stacks.isEmpty()) {
for (ItemStack pageStack : stacks) {
if (ItemUtil.areItemsEqual(pageStack, stack, true)) {
return page;
}
}
}
}
return null;
}
@OnlyIn(Dist.CLIENT)
public static GuiPage createBookletGuiFromPage(Screen previousScreen, IBookletPage page) {
GuiMainPage mainPage = new GuiMainPage(previousScreen);
IBookletChapter chapter = page.getChapter();
GuiEntry entry = new GuiEntry(previousScreen, mainPage, chapter.getEntry(), chapter, "", false);
return createPageGui(previousScreen, entry, page);
}
@OnlyIn(Dist.CLIENT)
public static GuiPage createPageGui(Screen previousScreen, GuiBookletBase parentPage, IBookletPage page) {
IBookletChapter chapter = page.getChapter();
IBookletPage[] allPages = chapter.getAllPages();
int pageIndex = chapter.getPageIndex(page);
IBookletPage page1;
IBookletPage page2;
if (page.shouldBeOnLeftSide()) {
page1 = page;
page2 = pageIndex >= allPages.length - 1
? null
: allPages[pageIndex + 1];
} else {
page1 = pageIndex <= 0
? null
: allPages[pageIndex - 1];
page2 = page;
}
return new GuiPage(previousScreen, parentPage, page1, page2);
}
public static IBookletPage getBookletPageById(String id) {
if (id != null) {
for (IBookletChapter chapter : ActuallyAdditionsAPI.ALL_CHAPTERS) {
for (IBookletPage page : chapter.getAllPages()) {
if (id.equals(page.getIdentifier())) {
return page;
}
}
}
}
return null;
}
}
///*
// * This file ("BookletUtils.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet.misc;
//
//import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
//import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
//import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
//import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
//import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiEntry;
//import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiMainPage;
//import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiPage;
//import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
//import net.minecraft.client.gui.screen.Screen;
//import net.minecraft.item.ItemStack;
//import net.minecraft.util.NonNullList;
//import net.minecraftforge.api.distmarker.Dist;
//import net.minecraftforge.api.distmarker.OnlyIn;
//
//import java.util.List;
//
//public final class BookletUtils {
//
// public static IBookletPage findFirstPageForStack(ItemStack stack) {
// for (IBookletPage page : ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA) {
// List<ItemStack> stacks = NonNullList.create();
// page.getItemStacksForPage(stacks);
// if (stacks != null && !stacks.isEmpty()) {
// for (ItemStack pageStack : stacks) {
// if (ItemUtil.areItemsEqual(pageStack, stack, true)) {
// return page;
// }
// }
// }
// }
// return null;
// }
//
// @OnlyIn(Dist.CLIENT)
// public static GuiPage createBookletGuiFromPage(Screen previousScreen, IBookletPage page) {
// GuiMainPage mainPage = new GuiMainPage(previousScreen);
//
// IBookletChapter chapter = page.getChapter();
// GuiEntry entry = new GuiEntry(previousScreen, mainPage, chapter.getEntry(), chapter, "", false);
//
// return createPageGui(previousScreen, entry, page);
// }
//
// @OnlyIn(Dist.CLIENT)
// public static GuiPage createPageGui(Screen previousScreen, GuiBookletBase parentPage, IBookletPage page) {
// IBookletChapter chapter = page.getChapter();
//
// IBookletPage[] allPages = chapter.getAllPages();
// int pageIndex = chapter.getPageIndex(page);
// IBookletPage page1;
// IBookletPage page2;
//
// if (page.shouldBeOnLeftSide()) {
// page1 = page;
// page2 = pageIndex >= allPages.length - 1
// ? null
// : allPages[pageIndex + 1];
// } else {
// page1 = pageIndex <= 0
// ? null
// : allPages[pageIndex - 1];
// page2 = page;
// }
//
// return new GuiPage(previousScreen, parentPage, page1, page2);
// }
//
// public static IBookletPage getBookletPageById(String id) {
// if (id != null) {
// for (IBookletChapter chapter : ActuallyAdditionsAPI.ALL_CHAPTERS) {
// for (IBookletPage page : chapter.getAllPages()) {
// if (id.equals(page.getIdentifier())) {
// return page;
// }
// }
// }
// }
// return null;
// }
//}

View file

@ -1,199 +1,199 @@
/*
* This file ("BookletPage.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.page;
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.Block;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fluids.FluidStack;
import java.util.*;
public class BookletPage implements IBookletPage {
protected final HashMap<String, String> textReplacements = new HashMap<>();
protected final int localizationKey;
private final int priority;
private final List<ItemStack> itemsForPage = new ArrayList<>();
private final List<FluidStack> fluidsForPage = new ArrayList<>();
protected IBookletChapter chapter;
protected boolean hasNoText;
public BookletPage(int localizationKey) {
this(localizationKey, 0);
}
public BookletPage(int localizationKey, int priority) {
this.localizationKey = localizationKey;
this.priority = priority;
}
@Override
public void getItemStacksForPage(List<ItemStack> list) {
list.addAll(this.itemsForPage);
}
@Override
public void getFluidStacksForPage(List<FluidStack> list) {
list.addAll(this.fluidsForPage);
}
@Override
public IBookletChapter getChapter() {
return this.chapter;
}
@Override
public void setChapter(IBookletChapter chapter) {
this.chapter = chapter;
}
@Override
@OnlyIn(Dist.CLIENT)
public String getInfoText() {
if (this.hasNoText) {
return null;
}
String base = StringUtil.localize(this.getLocalizationKey());
base = base.replaceAll("<imp>", TextFormatting.DARK_GREEN + "");
base = base.replaceAll("<item>", TextFormatting.BLUE + "");
base = base.replaceAll("<r>", TextFormatting.BLACK + "");
base = base.replaceAll("<n>", "\n");
base = base.replaceAll("<i>", TextFormatting.ITALIC + "");
base = base.replaceAll("<tifisgrin>", TextFormatting.DARK_RED + "" + TextFormatting.UNDERLINE); //This is fucking important so go read it now
for (Map.Entry<String, String> entry : this.textReplacements.entrySet()) {
base = base.replaceAll(entry.getKey(), entry.getValue());
}
return base;
}
@OnlyIn(Dist.CLIENT)
protected String getLocalizationKey() {
return "booklet." + ActuallyAdditions.MODID + ".chapter." + this.chapter.getIdentifier() + ".text." + this.localizationKey;
}
@Override
@OnlyIn(Dist.CLIENT)
public void mouseClicked(GuiBookletBase gui, int mouseX, int mouseY, int mouseButton) {
}
@Override
@OnlyIn(Dist.CLIENT)
public void mouseReleased(GuiBookletBase gui, int mouseX, int mouseY, int state) {
}
@Override
@OnlyIn(Dist.CLIENT)
public void mouseClickMove(GuiBookletBase gui, int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
}
@Override
@OnlyIn(Dist.CLIENT)
public void actionPerformed(GuiBookletBase gui, Button button) {
}
@Override
@OnlyIn(Dist.CLIENT)
public void init(GuiBookletBase gui, int startX, int startY) {
}
@Override
@OnlyIn(Dist.CLIENT)
public void updateScreen(GuiBookletBase gui, int startX, int startY, int pageTimer) {
}
@Override
@OnlyIn(Dist.CLIENT)
public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) {
}
@Override
@OnlyIn(Dist.CLIENT)
public void drawScreenPost(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) {
}
@Override
public boolean shouldBeOnLeftSide() {
return (this.chapter.getPageIndex(this) + 1) % 2 != 0;
}
@Override
public String getIdentifier() {
return this.chapter.getIdentifier() + "." + this.chapter.getPageIndex(this);
}
@Override
public String getWebLink() {
return "http://ellpeck.de/actaddmanual#" + this.chapter.getIdentifier();
}
public BookletPage setNoText() {
this.hasNoText = true;
return this;
}
public BookletPage addFluidToPage(Fluid fluid) {
this.fluidsForPage.add(new FluidStack(fluid, 1));
return this;
}
public BookletPage addItemsToPage(Block... blocks) {
for (Block block : blocks) {
this.addItemsToPage(new ItemStack(block));
}
return this;
}
public BookletPage addItemsToPage(ItemStack... stacks) {
Collections.addAll(this.itemsForPage, stacks);
return this;
}
@Override
public BookletPage addTextReplacement(String key, String value) {
this.textReplacements.put(key, value);
return this;
}
@Override
public BookletPage addTextReplacement(String key, float value) {
return this.addTextReplacement(key, Float.toString(value));
}
@Override
public BookletPage addTextReplacement(String key, int value) {
return this.addTextReplacement(key, Integer.toString(value));
}
@Override
public int getSortingPriority() {
return this.priority;
}
}
///*
// * This file ("BookletPage.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet.page;
//
//import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
//import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
//import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
//import net.minecraft.block.Block;
//import net.minecraft.client.gui.widget.button.Button;
//import net.minecraft.fluid.Fluid;
//import net.minecraft.item.ItemStack;
//import net.minecraft.util.text.TextFormatting;
//import net.minecraftforge.api.distmarker.Dist;
//import net.minecraftforge.api.distmarker.OnlyIn;
//import net.minecraftforge.fluids.FluidStack;
//
//import java.util.*;
//
//public class BookletPage implements IBookletPage {
//
// protected final HashMap<String, String> textReplacements = new HashMap<>();
// protected final int localizationKey;
// private final int priority;
// private final List<ItemStack> itemsForPage = new ArrayList<>();
// private final List<FluidStack> fluidsForPage = new ArrayList<>();
// protected IBookletChapter chapter;
// protected boolean hasNoText;
//
// public BookletPage(int localizationKey) {
// this(localizationKey, 0);
// }
//
// public BookletPage(int localizationKey, int priority) {
// this.localizationKey = localizationKey;
// this.priority = priority;
// }
//
// @Override
// public void getItemStacksForPage(List<ItemStack> list) {
// list.addAll(this.itemsForPage);
// }
//
// @Override
// public void getFluidStacksForPage(List<FluidStack> list) {
// list.addAll(this.fluidsForPage);
// }
//
// @Override
// public IBookletChapter getChapter() {
// return this.chapter;
// }
//
// @Override
// public void setChapter(IBookletChapter chapter) {
// this.chapter = chapter;
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public String getInfoText() {
// if (this.hasNoText) {
// return null;
// }
//
// String base = StringUtil.localize(this.getLocalizationKey());
// base = base.replaceAll("<imp>", TextFormatting.DARK_GREEN + "");
// base = base.replaceAll("<item>", TextFormatting.BLUE + "");
// base = base.replaceAll("<r>", TextFormatting.BLACK + "");
// base = base.replaceAll("<n>", "\n");
// base = base.replaceAll("<i>", TextFormatting.ITALIC + "");
// base = base.replaceAll("<tifisgrin>", TextFormatting.DARK_RED + "" + TextFormatting.UNDERLINE); //This is fucking important so go read it now
//
// for (Map.Entry<String, String> entry : this.textReplacements.entrySet()) {
// base = base.replaceAll(entry.getKey(), entry.getValue());
// }
// return base;
// }
//
// @OnlyIn(Dist.CLIENT)
// protected String getLocalizationKey() {
// return "booklet." + ActuallyAdditions.MODID + ".chapter." + this.chapter.getIdentifier() + ".text." + this.localizationKey;
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void mouseClicked(GuiBookletBase gui, int mouseX, int mouseY, int mouseButton) {
//
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void mouseReleased(GuiBookletBase gui, int mouseX, int mouseY, int state) {
//
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void mouseClickMove(GuiBookletBase gui, int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
//
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void actionPerformed(GuiBookletBase gui, Button button) {
//
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void init(GuiBookletBase gui, int startX, int startY) {
//
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void updateScreen(GuiBookletBase gui, int startX, int startY, int pageTimer) {
//
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) {
//
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void drawScreenPost(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) {
//
// }
//
// @Override
// public boolean shouldBeOnLeftSide() {
// return (this.chapter.getPageIndex(this) + 1) % 2 != 0;
// }
//
// @Override
// public String getIdentifier() {
// return this.chapter.getIdentifier() + "." + this.chapter.getPageIndex(this);
// }
//
// @Override
// public String getWebLink() {
// return "http://ellpeck.de/actaddmanual#" + this.chapter.getIdentifier();
// }
//
// public BookletPage setNoText() {
// this.hasNoText = true;
// return this;
// }
//
// public BookletPage addFluidToPage(Fluid fluid) {
// this.fluidsForPage.add(new FluidStack(fluid, 1));
// return this;
// }
//
// public BookletPage addItemsToPage(Block... blocks) {
// for (Block block : blocks) {
// this.addItemsToPage(new ItemStack(block));
// }
// return this;
// }
//
// public BookletPage addItemsToPage(ItemStack... stacks) {
// Collections.addAll(this.itemsForPage, stacks);
// return this;
// }
//
// @Override
// public BookletPage addTextReplacement(String key, String value) {
// this.textReplacements.put(key, value);
// return this;
// }
//
// @Override
// public BookletPage addTextReplacement(String key, float value) {
// return this.addTextReplacement(key, Float.toString(value));
// }
//
// @Override
// public BookletPage addTextReplacement(String key, int value) {
// return this.addTextReplacement(key, Integer.toString(value));
// }
//
// @Override
// public int getSortingPriority() {
// return this.priority;
// }
//}

View file

@ -1,99 +1,99 @@
/*
* This file ("ItemDisplay.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.page;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiPage;
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.util.ITooltipFlag.TooltipFlags;
import net.minecraft.item.ItemStack;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.client.gui.GuiUtils;
import java.util.List;
public class ItemDisplay {
public final int x;
public final int y;
public final float scale;
private final GuiPage gui;
private final IBookletPage page;
public ItemStack stack;
public ItemDisplay(GuiPage gui, int x, int y, float scale, ItemStack stack, boolean shouldTryTransfer) {
this.gui = gui;
this.x = x;
this.y = y;
this.scale = scale;
this.stack = stack;
this.page = shouldTryTransfer
? BookletUtils.findFirstPageForStack(stack)
: null;
}
@OnlyIn(Dist.CLIENT)
public void drawPre() {
AssetUtil.renderStackToGui(this.stack, this.x, this.y, this.scale);
}
@OnlyIn(Dist.CLIENT)
public void drawPost(int mouseX, int mouseY) {
if (this.isHovered(mouseX, mouseY)) {
Minecraft mc = this.gui.mc;
boolean flagBefore = mc.font.getUnicodeFlag();
mc.font.setUnicodeFlag(false);
List<String> list = this.stack.getTooltipLines(mc.player, mc.options.advancedItemTooltips
? TooltipFlags.ADVANCED
: TooltipFlags.NORMAL);
for (int k = 0; k < list.size(); ++k) {
if (k == 0) {
list.set(k, this.stack.getItem().getForgeRarity(this.stack).getColor() + list.get(k));
} else {
list.set(k, TextFormatting.GRAY + list.get(k));
}
}
if (this.page != null && this.page != this.gui.pages[0] && this.page != this.gui.pages[1]) {
list.add(TextFormatting.GOLD + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".clickToSeeRecipe"));
}
GuiUtils.drawHoveringText(list, mouseX, mouseY, mc.displayWidth, mc.displayHeight, -1, mc.font);
mc.font.setUnicodeFlag(flagBefore);
}
}
public void onMousePress(int button, int mouseX, int mouseY) {
if (button == 0 && this.isHovered(mouseX, mouseY)) {
if (this.page != null && this.page != this.gui.pages[0] && this.page != this.gui.pages[1]) {
this.gui.mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
GuiBooklet gui = BookletUtils.createPageGui(this.gui.previousScreen, this.gui, this.page);
this.gui.mc.displayGuiScreen(gui);
}
}
}
public boolean isHovered(int mouseX, int mouseY) {
return mouseX >= this.x && mouseY >= this.y && mouseX < this.x + 16 * this.scale && mouseY < this.y + 16 * this.scale;
}
}
///*
// * This file ("ItemDisplay.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet.page;
//
//import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
//import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
//import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiPage;
//import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
//import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
//import net.minecraft.client.Minecraft;
//import net.minecraft.client.util.ITooltipFlag.TooltipFlags;
//import net.minecraft.item.ItemStack;
//import net.minecraft.util.SoundEvents;
//import net.minecraft.util.text.TextFormatting;
//import net.minecraftforge.api.distmarker.Dist;
//import net.minecraftforge.api.distmarker.OnlyIn;
//import net.minecraftforge.fml.client.gui.GuiUtils;
//
//import java.util.List;
//
//public class ItemDisplay {
//
// public final int x;
// public final int y;
// public final float scale;
// private final GuiPage gui;
// private final IBookletPage page;
// public ItemStack stack;
//
// public ItemDisplay(GuiPage gui, int x, int y, float scale, ItemStack stack, boolean shouldTryTransfer) {
// this.gui = gui;
// this.x = x;
// this.y = y;
// this.scale = scale;
// this.stack = stack;
// this.page = shouldTryTransfer
// ? BookletUtils.findFirstPageForStack(stack)
// : null;
// }
//
// @OnlyIn(Dist.CLIENT)
// public void drawPre() {
// AssetUtil.renderStackToGui(this.stack, this.x, this.y, this.scale);
// }
//
// @OnlyIn(Dist.CLIENT)
// public void drawPost(int mouseX, int mouseY) {
// if (this.isHovered(mouseX, mouseY)) {
// Minecraft mc = this.gui.mc;
// boolean flagBefore = mc.font.getUnicodeFlag();
// mc.font.setUnicodeFlag(false);
//
// List<String> list = this.stack.getTooltipLines(mc.player, mc.options.advancedItemTooltips
// ? TooltipFlags.ADVANCED
// : TooltipFlags.NORMAL);
//
// for (int k = 0; k < list.size(); ++k) {
// if (k == 0) {
// list.set(k, this.stack.getItem().getForgeRarity(this.stack).getColor() + list.get(k));
// } else {
// list.set(k, TextFormatting.GRAY + list.get(k));
// }
// }
//
// if (this.page != null && this.page != this.gui.pages[0] && this.page != this.gui.pages[1]) {
// list.add(TextFormatting.GOLD + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".clickToSeeRecipe"));
// }
//
// GuiUtils.drawHoveringText(list, mouseX, mouseY, mc.displayWidth, mc.displayHeight, -1, mc.font);
//
// mc.font.setUnicodeFlag(flagBefore);
// }
// }
//
// public void onMousePress(int button, int mouseX, int mouseY) {
// if (button == 0 && this.isHovered(mouseX, mouseY)) {
// if (this.page != null && this.page != this.gui.pages[0] && this.page != this.gui.pages[1]) {
// this.gui.mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
//
// GuiBooklet gui = BookletUtils.createPageGui(this.gui.previousScreen, this.gui, this.page);
// this.gui.mc.displayGuiScreen(gui);
// }
// }
// }
//
// public boolean isHovered(int mouseX, int mouseY) {
// return mouseX >= this.x && mouseY >= this.y && mouseX < this.x + 16 * this.scale && mouseY < this.y + 16 * this.scale;
// }
//}

View file

@ -1,78 +1,78 @@
/*
* This file ("PageCoffeeMachine.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.page;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
import net.minecraft.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.client.gui.GuiUtils;
import java.util.List;
public class PageCoffeeMachine extends BookletPage {
private final CoffeeIngredient ingredient;
private final ItemStack outcome;
private int counter = 0;
private int rotate = 0;
private final ItemStack[] stacks;
public PageCoffeeMachine(int localizationKey, CoffeeIngredient ingredient) {
super(localizationKey);
this.ingredient = ingredient;
this.stacks = ingredient.getInput().getItems();
this.outcome = new ItemStack(ActuallyItems.COFFEE.get());
ActuallyAdditionsAPI.methodHandler.addEffectToStack(this.outcome, this.ingredient);
}
@Override
@OnlyIn(Dist.CLIENT)
public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) {
super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
gui.getMinecraft().getTextureManager().bind(GuiBooklet.RES_LOC_GADGETS);
GuiUtils.drawTexturedModalRect(startX + 5, startY + 10, 0, 74, 117, 72, 0);
gui.renderScaledAsciiString("(Coffee Maker Recipe)", startX + 6, startY + 78, 0, false, gui.getMediumFontSize());
gui.renderSplitScaledAsciiString("Hover over this to see the effect!", startX + 5, startY + 51, 0, false, gui.getSmallFontSize(), 35);
PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 90);
if (this.counter++ % 50 == 0) {
gui.addOrModifyItemRenderer(this.stacks[this.rotate++ % this.stacks.length], startX + 5 + 82, startY + 10 + 1, 1F, true);
}
}
@Override
@OnlyIn(Dist.CLIENT)
public void init(GuiBookletBase gui, int startX, int startY) {
super.init(gui, startX, startY);
gui.addOrModifyItemRenderer(this.stacks[0], startX + 5 + 82, startY + 10 + 1, 1F, true);
gui.addOrModifyItemRenderer(this.outcome, startX + 5 + 36, startY + 10 + 42, 1F, false);
gui.addOrModifyItemRenderer(new ItemStack(ActuallyItems.COFFEE_CUP.get()), startX + 5 + 37, startY + 10 + 1, 1F, true);
gui.addOrModifyItemRenderer(new ItemStack(ActuallyItems.COFFEE.get()), startX + 5 + 1, startY + 10 + 1, 1F, true);
}
@Override
public void getItemStacksForPage(List<ItemStack> list) {
super.getItemStacksForPage(list);
list.add(this.outcome);
}
}
///*
// * This file ("PageCoffeeMachine.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet.page;
//
//import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
//import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
//import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
//import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
//import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
//import net.minecraft.item.ItemStack;
//import net.minecraftforge.api.distmarker.Dist;
//import net.minecraftforge.api.distmarker.OnlyIn;
//import net.minecraftforge.fml.client.gui.GuiUtils;
//
//import java.util.List;
//
//public class PageCoffeeMachine extends BookletPage {
//
// private final CoffeeIngredient ingredient;
// private final ItemStack outcome;
// private int counter = 0;
// private int rotate = 0;
// private final ItemStack[] stacks;
//
// public PageCoffeeMachine(int localizationKey, CoffeeIngredient ingredient) {
// super(localizationKey);
// this.ingredient = ingredient;
// this.stacks = ingredient.getInput().getItems();
//
// this.outcome = new ItemStack(ActuallyItems.COFFEE.get());
// ActuallyAdditionsAPI.methodHandler.addEffectToStack(this.outcome, this.ingredient);
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) {
// super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
//
// gui.getMinecraft().getTextureManager().bind(GuiBooklet.RES_LOC_GADGETS);
// GuiUtils.drawTexturedModalRect(startX + 5, startY + 10, 0, 74, 117, 72, 0);
//
// gui.renderScaledAsciiString("(Coffee Maker Recipe)", startX + 6, startY + 78, 0, false, gui.getMediumFontSize());
// gui.renderSplitScaledAsciiString("Hover over this to see the effect!", startX + 5, startY + 51, 0, false, gui.getSmallFontSize(), 35);
//
// PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 90);
//
// if (this.counter++ % 50 == 0) {
// gui.addOrModifyItemRenderer(this.stacks[this.rotate++ % this.stacks.length], startX + 5 + 82, startY + 10 + 1, 1F, true);
// }
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void init(GuiBookletBase gui, int startX, int startY) {
// super.init(gui, startX, startY);
//
// gui.addOrModifyItemRenderer(this.stacks[0], startX + 5 + 82, startY + 10 + 1, 1F, true);
// gui.addOrModifyItemRenderer(this.outcome, startX + 5 + 36, startY + 10 + 42, 1F, false);
//
// gui.addOrModifyItemRenderer(new ItemStack(ActuallyItems.COFFEE_CUP.get()), startX + 5 + 37, startY + 10 + 1, 1F, true);
// gui.addOrModifyItemRenderer(new ItemStack(ActuallyItems.COFFEE.get()), startX + 5 + 1, startY + 10 + 1, 1F, true);
// }
//
// @Override
// public void getItemStacksForPage(List<ItemStack> list) {
// super.getItemStacksForPage(list);
//
// list.add(this.outcome);
// }
//}

View file

@ -1,194 +1,194 @@
/*
* This file ("PageCrafting.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.page;
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
import de.ellpeck.actuallyadditions.mod.util.RefHelp;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.client.gui.GuiUtils;
import java.util.Arrays;
import java.util.List;
public class PageCrafting extends BookletPage {
private final List<IRecipe> recipes;
private int recipeAt;
private String recipeTypeLocKey;
private boolean isWildcard;
public PageCrafting(int localizationKey, int priority, List<IRecipe> recipes) {
super(localizationKey, priority);
this.recipes = recipes;
}
public PageCrafting(int localizationKey, List<IRecipe> recipes) {
this(localizationKey, 0, recipes);
}
public PageCrafting(int localizationKey, IRecipe... recipes) {
this(localizationKey, 0, recipes);
}
public PageCrafting(int localizationKey, int priority, IRecipe... recipes) {
this(localizationKey, priority, Arrays.asList(recipes));
}
public BookletPage setWildcard() {
this.isWildcard = true;
return this;
}
@Override
@OnlyIn(Dist.CLIENT)
public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) {
super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
gui.getMinecraft().getTextureManager().bind(GuiBooklet.RES_LOC_GADGETS);
GuiUtils.drawTexturedModalRect(startX + 5, startY + 6, 20, 0, 116, 54, 0);
if (this.recipeTypeLocKey != null) {
gui.renderScaledAsciiString("(" + StringUtil.localize(this.recipeTypeLocKey) + ")", startX + 6, startY + 65, 0, false, gui.getMediumFontSize());
}
PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 80);
}
@Override
@OnlyIn(Dist.CLIENT)
public void updateScreen(GuiBookletBase gui, int startX, int startY, int pageTimer) {
super.updateScreen(gui, startX, startY, pageTimer);
if (pageTimer % 20 == 0) {
this.findRecipe(gui, startX, startY);
}
}
private void findRecipe(GuiBookletBase gui, int startX, int startY) {
if (!this.recipes.isEmpty()) {
IRecipe recipe = this.recipes.get(this.recipeAt);
if (recipe != null) {
this.setupRecipe(gui, recipe, startX, startY);
}
this.recipeAt++;
if (this.recipeAt >= this.recipes.size()) {
this.recipeAt = 0;
}
}
}
@Override
public void init(GuiBookletBase gui, int startX, int startY) {
super.init(gui, startX, startY);
this.findRecipe(gui, startX, startY);
}
@Override
public void getItemStacksForPage(List<ItemStack> list) {
super.getItemStacksForPage(list);
if (!this.recipes.isEmpty()) {
for (IRecipe recipe : this.recipes) {
if (recipe != null) {
ItemStack output = recipe.getResultItem();
if (StackUtil.isValid(output)) {
ItemStack copy = output.copy();
/*
if (this.isWildcard) {
copy.setItemDamage(Util.WILDCARD);
}
*/
list.add(copy);
}
}
}
}
}
private void setupRecipe(GuiBookletBase gui, IRecipe recipe, int startX, int startY) {
Ingredient[] ings = new Ingredient[9];
int width = 3;
int height = 3;
/*
if (recipe instanceof BlankRecipe) {
this.recipeTypeLocKey = "tooltip." + ActuallyAdditions.MODID + ".disabled";
gui.addOrModifyItemRenderer(recipe.getResultItem(), startX + 100, startY + 25, 1F, false);
return;
} else if (recipe instanceof ShapedRecipes) {
ShapedRecipes shaped = (ShapedRecipes) recipe;
width = shaped.recipeWidth;
height = shaped.recipeHeight;
ings = shaped.recipeItems.toArray(new Ingredient[shaped.recipeItems.size()]);
this.recipeTypeLocKey = "booklet." + ActuallyAdditions.MODID + ".shapedRecipe";
} else if (recipe instanceof ShapelessRecipes) {
ShapelessRecipes shapeless = (ShapelessRecipes) recipe;
for (int i = 0; i < shapeless.recipeItems.size(); i++) {
ings[i] = shapeless.recipeItems.get(i);
}
this.recipeTypeLocKey = "booklet." + ActuallyAdditions.MODID + ".shapelessRecipe";
} else if (recipe instanceof ShapedOreRecipe) {
ShapedOreRecipe shaped = (ShapedOreRecipe) recipe;
try {
width = RefHelp.getPrivateValue(ShapedOreRecipe.class, shaped, 4);
height = RefHelp.getPrivateValue(ShapedOreRecipe.class, shaped, 5);
} catch (Exception e) {
ActuallyAdditions.LOGGER.error("Something went wrong trying to get the Crafting Recipe in the booklet to display!", e);
}
for (int i = 0; i < shaped.getIngredients().size(); i++) {
ings[i] = shaped.getIngredients().get(i);
}
this.recipeTypeLocKey = "booklet." + ActuallyAdditions.MODID + ".shapedOreRecipe";
} else if (recipe instanceof ShapelessOreRecipe) {
ShapelessOreRecipe shapeless = (ShapelessOreRecipe) recipe;
for (int i = 0; i < shapeless.getIngredients().size(); i++) {
ings[i] = shapeless.getIngredients().get(i);
}
this.recipeTypeLocKey = "booklet." + ActuallyAdditions.MODID + ".shapelessOreRecipe";
}
*/
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
Ingredient ing = ings[y * width + x];
if (ing != null) {
ItemStack[] stacks = ing.getItems();
if (stacks != null && stacks.length > 0) {
ItemStack stack = stacks[0];
if (StackUtil.isValid(stack)) {
ItemStack copy = stack.copy();
copy.setCount(1);
/*
if (copy.getItemDamage() == Util.WILDCARD) {
copy.setItemDamage(0);
}
*/
gui.addOrModifyItemRenderer(copy, startX + 6 + x * 18, startY + 7 + y * 18, 1F, true);
}
}
}
}
}
gui.addOrModifyItemRenderer(recipe.getResultItem(), startX + 100, startY + 25, 1F, false);
}
}
///*
// * This file ("PageCrafting.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet.page;
//
//import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
//import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
//import de.ellpeck.actuallyadditions.mod.util.RefHelp;
//import de.ellpeck.actuallyadditions.mod.util.StackUtil;
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
//import de.ellpeck.actuallyadditions.mod.util.Util;
//import net.minecraft.item.ItemStack;
//import net.minecraft.item.crafting.IRecipe;
//import net.minecraft.item.crafting.Ingredient;
//import net.minecraftforge.api.distmarker.Dist;
//import net.minecraftforge.api.distmarker.OnlyIn;
//import net.minecraftforge.fml.client.gui.GuiUtils;
//
//import java.util.Arrays;
//import java.util.List;
//
//public class PageCrafting extends BookletPage {
//
// private final List<IRecipe> recipes;
// private int recipeAt;
// private String recipeTypeLocKey;
// private boolean isWildcard;
//
// public PageCrafting(int localizationKey, int priority, List<IRecipe> recipes) {
// super(localizationKey, priority);
// this.recipes = recipes;
// }
//
// public PageCrafting(int localizationKey, List<IRecipe> recipes) {
// this(localizationKey, 0, recipes);
// }
//
// public PageCrafting(int localizationKey, IRecipe... recipes) {
// this(localizationKey, 0, recipes);
// }
//
// public PageCrafting(int localizationKey, int priority, IRecipe... recipes) {
// this(localizationKey, priority, Arrays.asList(recipes));
// }
//
// public BookletPage setWildcard() {
// this.isWildcard = true;
// return this;
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) {
// super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
//
// gui.getMinecraft().getTextureManager().bind(GuiBooklet.RES_LOC_GADGETS);
// GuiUtils.drawTexturedModalRect(startX + 5, startY + 6, 20, 0, 116, 54, 0);
//
// if (this.recipeTypeLocKey != null) {
// gui.renderScaledAsciiString("(" + StringUtil.localize(this.recipeTypeLocKey) + ")", startX + 6, startY + 65, 0, false, gui.getMediumFontSize());
// }
//
// PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 80);
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void updateScreen(GuiBookletBase gui, int startX, int startY, int pageTimer) {
// super.updateScreen(gui, startX, startY, pageTimer);
//
// if (pageTimer % 20 == 0) {
// this.findRecipe(gui, startX, startY);
// }
// }
//
// private void findRecipe(GuiBookletBase gui, int startX, int startY) {
// if (!this.recipes.isEmpty()) {
// IRecipe recipe = this.recipes.get(this.recipeAt);
// if (recipe != null) {
// this.setupRecipe(gui, recipe, startX, startY);
// }
//
// this.recipeAt++;
// if (this.recipeAt >= this.recipes.size()) {
// this.recipeAt = 0;
// }
// }
// }
//
// @Override
// public void init(GuiBookletBase gui, int startX, int startY) {
// super.init(gui, startX, startY);
// this.findRecipe(gui, startX, startY);
// }
//
// @Override
// public void getItemStacksForPage(List<ItemStack> list) {
// super.getItemStacksForPage(list);
//
// if (!this.recipes.isEmpty()) {
// for (IRecipe recipe : this.recipes) {
// if (recipe != null) {
// ItemStack output = recipe.getResultItem();
// if (StackUtil.isValid(output)) {
// ItemStack copy = output.copy();
// /*
// if (this.isWildcard) {
// copy.setItemDamage(Util.WILDCARD);
// }
//
// */
// list.add(copy);
// }
// }
// }
// }
// }
//
// private void setupRecipe(GuiBookletBase gui, IRecipe recipe, int startX, int startY) {
// Ingredient[] ings = new Ingredient[9];
// int width = 3;
// int height = 3;
///*
// if (recipe instanceof BlankRecipe) {
// this.recipeTypeLocKey = "tooltip." + ActuallyAdditions.MODID + ".disabled";
// gui.addOrModifyItemRenderer(recipe.getResultItem(), startX + 100, startY + 25, 1F, false);
// return;
// } else if (recipe instanceof ShapedRecipes) {
// ShapedRecipes shaped = (ShapedRecipes) recipe;
// width = shaped.recipeWidth;
// height = shaped.recipeHeight;
// ings = shaped.recipeItems.toArray(new Ingredient[shaped.recipeItems.size()]);
// this.recipeTypeLocKey = "booklet." + ActuallyAdditions.MODID + ".shapedRecipe";
// } else if (recipe instanceof ShapelessRecipes) {
// ShapelessRecipes shapeless = (ShapelessRecipes) recipe;
// for (int i = 0; i < shapeless.recipeItems.size(); i++) {
// ings[i] = shapeless.recipeItems.get(i);
// }
// this.recipeTypeLocKey = "booklet." + ActuallyAdditions.MODID + ".shapelessRecipe";
// } else if (recipe instanceof ShapedOreRecipe) {
// ShapedOreRecipe shaped = (ShapedOreRecipe) recipe;
// try {
// width = RefHelp.getPrivateValue(ShapedOreRecipe.class, shaped, 4);
// height = RefHelp.getPrivateValue(ShapedOreRecipe.class, shaped, 5);
// } catch (Exception e) {
// ActuallyAdditions.LOGGER.error("Something went wrong trying to get the Crafting Recipe in the booklet to display!", e);
// }
// for (int i = 0; i < shaped.getIngredients().size(); i++) {
// ings[i] = shaped.getIngredients().get(i);
// }
// this.recipeTypeLocKey = "booklet." + ActuallyAdditions.MODID + ".shapedOreRecipe";
// } else if (recipe instanceof ShapelessOreRecipe) {
// ShapelessOreRecipe shapeless = (ShapelessOreRecipe) recipe;
// for (int i = 0; i < shapeless.getIngredients().size(); i++) {
// ings[i] = shapeless.getIngredients().get(i);
// }
// this.recipeTypeLocKey = "booklet." + ActuallyAdditions.MODID + ".shapelessOreRecipe";
// }
//
//
// */
// for (int x = 0; x < width; x++) {
// for (int y = 0; y < height; y++) {
// Ingredient ing = ings[y * width + x];
// if (ing != null) {
// ItemStack[] stacks = ing.getItems();
// if (stacks != null && stacks.length > 0) {
// ItemStack stack = stacks[0];
// if (StackUtil.isValid(stack)) {
// ItemStack copy = stack.copy();
// copy.setCount(1);
// /*
// if (copy.getItemDamage() == Util.WILDCARD) {
// copy.setItemDamage(0);
// }
// */
// gui.addOrModifyItemRenderer(copy, startX + 6 + x * 18, startY + 7 + y * 18, 1F, true);
// }
// }
// }
// }
// }
//
// gui.addOrModifyItemRenderer(recipe.getResultItem(), startX + 100, startY + 25, 1F, false);
// }
//}

View file

@ -1,83 +1,83 @@
/*
* This file ("PageCrusherRecipe.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.page;
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
import de.ellpeck.actuallyadditions.mod.crafting.CrushingRecipe;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.client.gui.GuiUtils;
import java.util.List;
public class PageCrusherRecipe extends BookletPage {
private final CrushingRecipe recipe;
private int counter = 0;
private int rotate = 0;
private final ItemStack[] stacks;
public PageCrusherRecipe(int localizationKey, CrushingRecipe recipe) {
super(localizationKey);
this.recipe = recipe;
this.stacks = recipe.getInput().getItems();
}
@Override
@OnlyIn(Dist.CLIENT)
public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) {
super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
gui.getMinecraft().getTextureManager().bind(GuiBooklet.RES_LOC_GADGETS);
GuiUtils.drawTexturedModalRect(startX + 38, startY + 6, 136, 0, 52, 74, 0);
gui.renderScaledAsciiString("(" + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".crusherRecipe") + ")", startX + 36, startY + 85, 0, false, gui.getMediumFontSize());
PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 100);
if (this.counter++ % 50 == 0) {
gui.addOrModifyItemRenderer(this.stacks[this.rotate++ % this.stacks.length], startX + 38 + 18, startY + 6 + 1, 1F, true);
}
}
@Override
@OnlyIn(Dist.CLIENT)
public void init(GuiBookletBase gui, int startX, int startY) {
super.init(gui, startX, startY);
if (this.recipe != null) {
gui.addOrModifyItemRenderer(this.stacks[this.rotate++ % this.stacks.length], startX + 38 + 18, startY + 6 + 1, 1F, true);
gui.addOrModifyItemRenderer(this.recipe.getOutputOne(), startX + 38 + 4, startY + 6 + 53, 1F, false);
if (StackUtil.isValid(this.recipe.getOutputTwo())) {
gui.addOrModifyItemRenderer(this.recipe.getOutputTwo(), startX + 38 + 30, startY + 6 + 53, 1F, false);
}
}
}
@Override
public void getItemStacksForPage(List<ItemStack> list) {
super.getItemStacksForPage(list);
if (this.recipe != null) {
list.add(this.recipe.getOutputOne());
if (StackUtil.isValid(this.recipe.getOutputTwo())) {
list.add(this.recipe.getOutputTwo());
}
}
}
}
///*
// * This file ("PageCrusherRecipe.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet.page;
//
//import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
//import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
//import de.ellpeck.actuallyadditions.mod.crafting.CrushingRecipe;
//import de.ellpeck.actuallyadditions.mod.util.StackUtil;
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
//import net.minecraft.item.ItemStack;
//import net.minecraftforge.api.distmarker.Dist;
//import net.minecraftforge.api.distmarker.OnlyIn;
//import net.minecraftforge.fml.client.gui.GuiUtils;
//
//import java.util.List;
//
//public class PageCrusherRecipe extends BookletPage {
//
// private final CrushingRecipe recipe;
// private int counter = 0;
// private int rotate = 0;
// private final ItemStack[] stacks;
//
// public PageCrusherRecipe(int localizationKey, CrushingRecipe recipe) {
// super(localizationKey);
// this.recipe = recipe;
// this.stacks = recipe.getInput().getItems();
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) {
// super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
//
// gui.getMinecraft().getTextureManager().bind(GuiBooklet.RES_LOC_GADGETS);
// GuiUtils.drawTexturedModalRect(startX + 38, startY + 6, 136, 0, 52, 74, 0);
//
// gui.renderScaledAsciiString("(" + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".crusherRecipe") + ")", startX + 36, startY + 85, 0, false, gui.getMediumFontSize());
//
// PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 100);
//
// if (this.counter++ % 50 == 0) {
// gui.addOrModifyItemRenderer(this.stacks[this.rotate++ % this.stacks.length], startX + 38 + 18, startY + 6 + 1, 1F, true);
// }
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void init(GuiBookletBase gui, int startX, int startY) {
// super.init(gui, startX, startY);
//
// if (this.recipe != null) {
// gui.addOrModifyItemRenderer(this.stacks[this.rotate++ % this.stacks.length], startX + 38 + 18, startY + 6 + 1, 1F, true);
// gui.addOrModifyItemRenderer(this.recipe.getOutputOne(), startX + 38 + 4, startY + 6 + 53, 1F, false);
//
// if (StackUtil.isValid(this.recipe.getOutputTwo())) {
// gui.addOrModifyItemRenderer(this.recipe.getOutputTwo(), startX + 38 + 30, startY + 6 + 53, 1F, false);
// }
// }
// }
//
// @Override
// public void getItemStacksForPage(List<ItemStack> list) {
// super.getItemStacksForPage(list);
//
// if (this.recipe != null) {
// list.add(this.recipe.getOutputOne());
//
// if (StackUtil.isValid(this.recipe.getOutputTwo())) {
// list.add(this.recipe.getOutputTwo());
// }
// }
// }
//}

View file

@ -1,105 +1,105 @@
/*
* This file ("PageEmpowerer.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.page;
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
import de.ellpeck.actuallyadditions.mod.crafting.EmpowererRecipe;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.client.gui.GuiUtils;
import java.util.List;
public class PageEmpowerer extends BookletPage {
private final EmpowererRecipe recipe;
private int counter = 0;
private int rotate = 0;
ItemStack[] inputs;
ItemStack[] stand1;
ItemStack[] stand2;
ItemStack[] stand3;
ItemStack[] stand4;
public PageEmpowerer(int localizationKey, EmpowererRecipe recipe) {
super(localizationKey);
this.recipe = recipe;
if (recipe != null) {
this.inputs = recipe.getInput().getItems();
this.stand1 = recipe.getStandOne().getItems();
this.stand2 = recipe.getStandTwo().getItems();
this.stand3 = recipe.getStandThree().getItems();
this.stand4 = recipe.getStandFour().getItems();
}
}
@Override
@OnlyIn(Dist.CLIENT)
public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) {
super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
gui.getMinecraft().getTextureManager().bind(GuiBooklet.RES_LOC_GADGETS);
GuiUtils.drawTexturedModalRect(startX + 5, startY + 10, 117, 74, 116, 72, 0);
gui.renderScaledAsciiString("(" + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".empowererRecipe") + ")", startX + 6, startY + 85, 0, false, gui.getMediumFontSize());
PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 100);
if (this.recipe != null) {
this.updateInputs(gui, startX, startY);
}
}
@Override
@OnlyIn(Dist.CLIENT)
public void init(GuiBookletBase gui, int startX, int startY) {
super.init(gui, startX, startY);
if (this.recipe != null) {
gui.addOrModifyItemRenderer(this.stand1[0], startX + 5 + 26, startY + 10 + 1, 1F, true);
gui.addOrModifyItemRenderer(this.stand2[0], startX + 5 + 1, startY + 10 + 26, 1F, true);
gui.addOrModifyItemRenderer(this.stand3[0], startX + 5 + 51, startY + 10 + 26, 1F, true);
gui.addOrModifyItemRenderer(this.stand4[0], startX + 5 + 26, startY + 10 + 51, 1F, true);
gui.addOrModifyItemRenderer(this.inputs[0], startX + 5 + 26, startY + 10 + 26, 1F, true);
gui.addOrModifyItemRenderer(this.recipe.getOutput(), startX + 5 + 96, startY + 10 + 26, 1F, false);
}
}
private void updateInputs(GuiBookletBase gui, int startX, int startY) {
if (this.counter++ % 50 == 0) {
this.rotate++;
gui.addOrModifyItemRenderer(this.stand1[this.rotate % this.stand1.length], startX + 5 + 26, startY + 10 + 1, 1F, true);
gui.addOrModifyItemRenderer(this.stand2[this.rotate % this.stand2.length], startX + 5 + 1, startY + 10 + 26, 1F, true);
gui.addOrModifyItemRenderer(this.stand3[this.rotate % this.stand3.length], startX + 5 + 51, startY + 10 + 26, 1F, true);
gui.addOrModifyItemRenderer(this.stand4[this.rotate % this.stand4.length], startX + 5 + 26, startY + 10 + 51, 1F, true);
gui.addOrModifyItemRenderer(this.inputs[this.rotate % this.inputs.length], startX + 5 + 26, startY + 10 + 26, 1F, true);
}
}
@Override
public void getItemStacksForPage(List<ItemStack> list) {
super.getItemStacksForPage(list);
if (this.recipe != null) {
list.add(this.recipe.getOutput());
}
}
@Override
public int getSortingPriority() {
return 20;
}
}
///*
// * This file ("PageEmpowerer.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet.page;
//
//import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
//import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
//import de.ellpeck.actuallyadditions.mod.crafting.EmpowererRecipe;
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
//import net.minecraft.item.ItemStack;
//import net.minecraftforge.api.distmarker.Dist;
//import net.minecraftforge.api.distmarker.OnlyIn;
//import net.minecraftforge.fml.client.gui.GuiUtils;
//
//import java.util.List;
//
//public class PageEmpowerer extends BookletPage {
//
// private final EmpowererRecipe recipe;
// private int counter = 0;
// private int rotate = 0;
// ItemStack[] inputs;
// ItemStack[] stand1;
// ItemStack[] stand2;
// ItemStack[] stand3;
// ItemStack[] stand4;
//
// public PageEmpowerer(int localizationKey, EmpowererRecipe recipe) {
// super(localizationKey);
// this.recipe = recipe;
// if (recipe != null) {
// this.inputs = recipe.getInput().getItems();
// this.stand1 = recipe.getStandOne().getItems();
// this.stand2 = recipe.getStandTwo().getItems();
// this.stand3 = recipe.getStandThree().getItems();
// this.stand4 = recipe.getStandFour().getItems();
// }
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) {
// super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
//
// gui.getMinecraft().getTextureManager().bind(GuiBooklet.RES_LOC_GADGETS);
// GuiUtils.drawTexturedModalRect(startX + 5, startY + 10, 117, 74, 116, 72, 0);
//
// gui.renderScaledAsciiString("(" + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".empowererRecipe") + ")", startX + 6, startY + 85, 0, false, gui.getMediumFontSize());
//
// PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 100);
// if (this.recipe != null) {
// this.updateInputs(gui, startX, startY);
// }
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void init(GuiBookletBase gui, int startX, int startY) {
// super.init(gui, startX, startY);
//
// if (this.recipe != null) {
// gui.addOrModifyItemRenderer(this.stand1[0], startX + 5 + 26, startY + 10 + 1, 1F, true);
// gui.addOrModifyItemRenderer(this.stand2[0], startX + 5 + 1, startY + 10 + 26, 1F, true);
// gui.addOrModifyItemRenderer(this.stand3[0], startX + 5 + 51, startY + 10 + 26, 1F, true);
// gui.addOrModifyItemRenderer(this.stand4[0], startX + 5 + 26, startY + 10 + 51, 1F, true);
//
// gui.addOrModifyItemRenderer(this.inputs[0], startX + 5 + 26, startY + 10 + 26, 1F, true);
// gui.addOrModifyItemRenderer(this.recipe.getOutput(), startX + 5 + 96, startY + 10 + 26, 1F, false);
// }
// }
//
// private void updateInputs(GuiBookletBase gui, int startX, int startY) {
// if (this.counter++ % 50 == 0) {
// this.rotate++;
// gui.addOrModifyItemRenderer(this.stand1[this.rotate % this.stand1.length], startX + 5 + 26, startY + 10 + 1, 1F, true);
// gui.addOrModifyItemRenderer(this.stand2[this.rotate % this.stand2.length], startX + 5 + 1, startY + 10 + 26, 1F, true);
// gui.addOrModifyItemRenderer(this.stand3[this.rotate % this.stand3.length], startX + 5 + 51, startY + 10 + 26, 1F, true);
// gui.addOrModifyItemRenderer(this.stand4[this.rotate % this.stand4.length], startX + 5 + 26, startY + 10 + 51, 1F, true);
//
// gui.addOrModifyItemRenderer(this.inputs[this.rotate % this.inputs.length], startX + 5 + 26, startY + 10 + 26, 1F, true);
// }
// }
//
// @Override
// public void getItemStacksForPage(List<ItemStack> list) {
// super.getItemStacksForPage(list);
//
// if (this.recipe != null) {
// list.add(this.recipe.getOutput());
// }
// }
//
// @Override
// public int getSortingPriority() {
// return 20;
// }
//}

View file

@ -1,82 +1,82 @@
/*
* This file ("PageFurnace.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.page;
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.item.ItemStack;
import net.minecraft.util.datafix.fixes.FurnaceRecipes;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.client.gui.GuiUtils;
import java.util.List;
import java.util.Map;
public class PageFurnace extends BookletPage {
private final ItemStack input;
private final ItemStack output;
public PageFurnace(int localizationKey, ItemStack output) {
this(localizationKey, output, 0);
}
public PageFurnace(int localizationKey, ItemStack output, int priority) {
super(localizationKey, priority);
this.output = output;
this.input = getInputForOutput(output);
}
private static ItemStack getInputForOutput(ItemStack output) {
for (Map.Entry<ItemStack, ItemStack> entry : FurnaceRecipes.instance().getSmeltingList().entrySet()) {
ItemStack stack = entry.getValue();
if (StackUtil.isValid(stack)) {
if (stack.sameItem(output)) {
return entry.getKey();
}
}
}
return ItemStack.EMPTY;
}
@Override
@OnlyIn(Dist.CLIENT)
public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) {
super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
gui.getMinecraft().getTextureManager().bind(GuiBooklet.RES_LOC_GADGETS);
GuiUtils.drawTexturedModalRect(startX + 23, startY + 10, 0, 146, 80, 26, 0);
gui.renderScaledAsciiString("(" + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".furnaceRecipe") + ")", startX + 32, startY + 42, 0, false, gui.getMediumFontSize());
PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 57);
}
@Override
@OnlyIn(Dist.CLIENT)
public void init(GuiBookletBase gui, int startX, int startY) {
super.init(gui, startX, startY);
gui.addOrModifyItemRenderer(this.input, startX + 23 + 1, startY + 10 + 5, 1F, true);
gui.addOrModifyItemRenderer(this.output, startX + 23 + 59, startY + 10 + 5, 1F, false);
}
@Override
public void getItemStacksForPage(List<ItemStack> list) {
super.getItemStacksForPage(list);
list.add(this.output);
}
}
///*
// * This file ("PageFurnace.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet.page;
//
//import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
//import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
//import de.ellpeck.actuallyadditions.mod.util.StackUtil;
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
//import net.minecraft.item.ItemStack;
//import net.minecraft.util.datafix.fixes.FurnaceRecipes;
//import net.minecraftforge.api.distmarker.Dist;
//import net.minecraftforge.api.distmarker.OnlyIn;
//import net.minecraftforge.fml.client.gui.GuiUtils;
//
//import java.util.List;
//import java.util.Map;
//
//public class PageFurnace extends BookletPage {
//
// private final ItemStack input;
// private final ItemStack output;
//
// public PageFurnace(int localizationKey, ItemStack output) {
// this(localizationKey, output, 0);
// }
//
// public PageFurnace(int localizationKey, ItemStack output, int priority) {
// super(localizationKey, priority);
// this.output = output;
// this.input = getInputForOutput(output);
// }
//
// private static ItemStack getInputForOutput(ItemStack output) {
// for (Map.Entry<ItemStack, ItemStack> entry : FurnaceRecipes.instance().getSmeltingList().entrySet()) {
// ItemStack stack = entry.getValue();
// if (StackUtil.isValid(stack)) {
// if (stack.sameItem(output)) {
// return entry.getKey();
// }
// }
// }
// return ItemStack.EMPTY;
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) {
// super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
//
// gui.getMinecraft().getTextureManager().bind(GuiBooklet.RES_LOC_GADGETS);
// GuiUtils.drawTexturedModalRect(startX + 23, startY + 10, 0, 146, 80, 26, 0);
//
// gui.renderScaledAsciiString("(" + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".furnaceRecipe") + ")", startX + 32, startY + 42, 0, false, gui.getMediumFontSize());
//
// PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 57);
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void init(GuiBookletBase gui, int startX, int startY) {
// super.init(gui, startX, startY);
//
// gui.addOrModifyItemRenderer(this.input, startX + 23 + 1, startY + 10 + 5, 1F, true);
// gui.addOrModifyItemRenderer(this.output, startX + 23 + 59, startY + 10 + 5, 1F, false);
// }
//
// @Override
// public void getItemStacksForPage(List<ItemStack> list) {
// super.getItemStacksForPage(list);
//
// list.add(this.output);
// }
//}

View file

@ -1,68 +1,68 @@
/*
* This file ("PageLinkButton.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.page;
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import java.awt.*;
import java.net.URI;
public class PageLinkButton extends BookletPage {
public static int nextButtonId = 23782;
private final int buttonId;
private final String link;
public PageLinkButton(int localizationKey, String link) {
super(localizationKey);
this.link = link;
this.buttonId = nextButtonId;
nextButtonId++;
}
@Override
@OnlyIn(Dist.CLIENT)
public void init(GuiBookletBase gui, int startX, int startY) {
super.init(gui, startX, startY);
gui.getButtonList().add(new Button(this.buttonId, startX + 125 / 2 - 50, startY + 130, 100, 20, StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".chapter." + this.chapter.getIdentifier() + ".button." + this.localizationKey)));
}
@Override
@OnlyIn(Dist.CLIENT)
public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) {
super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 5);
}
@Override
@OnlyIn(Dist.CLIENT)
public void actionPerformed(GuiBookletBase gui, Button button) {
if (button.id == this.buttonId) {
if (Desktop.isDesktopSupported()) {
try {
Desktop.getDesktop().browse(new URI(this.link));
} catch (Exception e) {
ActuallyAdditions.LOGGER.error("Couldn't open website from Link Button page!", e);
}
}
} else {
super.actionPerformed(gui, button);
}
}
}
///*
// * This file ("PageLinkButton.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet.page;
//
//import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
//import net.minecraft.client.gui.widget.button.Button;
//import net.minecraftforge.api.distmarker.Dist;
//import net.minecraftforge.api.distmarker.OnlyIn;
//
//import java.awt.*;
//import java.net.URI;
//
//public class PageLinkButton extends BookletPage {
//
// public static int nextButtonId = 23782;
// private final int buttonId;
//
// private final String link;
//
// public PageLinkButton(int localizationKey, String link) {
// super(localizationKey);
// this.link = link;
//
// this.buttonId = nextButtonId;
// nextButtonId++;
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void init(GuiBookletBase gui, int startX, int startY) {
// super.init(gui, startX, startY);
//
// gui.getButtonList().add(new Button(this.buttonId, startX + 125 / 2 - 50, startY + 130, 100, 20, StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".chapter." + this.chapter.getIdentifier() + ".button." + this.localizationKey)));
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) {
// super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
// PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 5);
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void actionPerformed(GuiBookletBase gui, Button button) {
// if (button.id == this.buttonId) {
// if (Desktop.isDesktopSupported()) {
// try {
// Desktop.getDesktop().browse(new URI(this.link));
// } catch (Exception e) {
// ActuallyAdditions.LOGGER.error("Couldn't open website from Link Button page!", e);
// }
// }
// } else {
// super.actionPerformed(gui, button);
// }
// }
//}

View file

@ -1,59 +1,59 @@
/*
* This file ("PagePicture.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.page;
import com.mojang.blaze3d.systems.RenderSystem;
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.client.gui.GuiUtils;
public class PagePicture extends BookletPage {
private final ResourceLocation resLoc;
private final int yTextOffset;
public PagePicture(int localizationKey, ResourceLocation resLoc, int yTextOffset, int priority) {
super(localizationKey, priority);
this.resLoc = resLoc;
this.yTextOffset = yTextOffset;
}
public PagePicture(int localizationKey, ResourceLocation resLoc, int yTextOffset) {
super(localizationKey);
this.yTextOffset = yTextOffset;
this.resLoc = resLoc;
}
public PagePicture(int localizationKey, String pictureLocation, int yTextOffset) {
this(localizationKey, AssetUtil.getBookletGuiLocation(pictureLocation), yTextOffset);
}
@Override
@OnlyIn(Dist.CLIENT)
public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) {
super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
gui.getMinecraft().getTextureManager().bind(this.resLoc);
RenderSystem.pushMatrix();
RenderSystem.enableBlend();
RenderSystem.disableAlphaTest();
GuiUtils.drawTexturedModalRect(startX - 6, startY - 7, 0, 0, 256, 256, 0);
RenderSystem.disableBlend();
RenderSystem.enableAlphaTest();
RenderSystem.popMatrix();
PageTextOnly.renderTextToPage(gui, this, startX + 6, startY - 7 + this.yTextOffset);
}
}
///*
// * This file ("PagePicture.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet.page;
//
//import com.mojang.blaze3d.systems.RenderSystem;
//import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
//import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
//import net.minecraft.util.ResourceLocation;
//import net.minecraftforge.api.distmarker.Dist;
//import net.minecraftforge.api.distmarker.OnlyIn;
//import net.minecraftforge.fml.client.gui.GuiUtils;
//
//public class PagePicture extends BookletPage {
//
// private final ResourceLocation resLoc;
// private final int yTextOffset;
//
// public PagePicture(int localizationKey, ResourceLocation resLoc, int yTextOffset, int priority) {
// super(localizationKey, priority);
// this.resLoc = resLoc;
// this.yTextOffset = yTextOffset;
// }
//
// public PagePicture(int localizationKey, ResourceLocation resLoc, int yTextOffset) {
// super(localizationKey);
// this.yTextOffset = yTextOffset;
// this.resLoc = resLoc;
// }
//
// public PagePicture(int localizationKey, String pictureLocation, int yTextOffset) {
// this(localizationKey, AssetUtil.getBookletGuiLocation(pictureLocation), yTextOffset);
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) {
// super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
//
// gui.getMinecraft().getTextureManager().bind(this.resLoc);
//
// RenderSystem.pushMatrix();
// RenderSystem.enableBlend();
// RenderSystem.disableAlphaTest();
// GuiUtils.drawTexturedModalRect(startX - 6, startY - 7, 0, 0, 256, 256, 0);
// RenderSystem.disableBlend();
// RenderSystem.enableAlphaTest();
// RenderSystem.popMatrix();
//
// PageTextOnly.renderTextToPage(gui, this, startX + 6, startY - 7 + this.yTextOffset);
// }
//}

View file

@ -1,93 +1,93 @@
/*
* This file ("PageReconstructor.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.page;
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.client.gui.GuiUtils;
import java.util.List;
public class PageReconstructor extends BookletPage {
private final LensConversionRecipe recipe;
private boolean isWildcard;
private int counter = 0;
private int rotate = 0;
private ItemStack[] stacks;
public PageReconstructor(int localizationKey, LensConversionRecipe recipe) {
super(localizationKey);
this.recipe = recipe;
if (recipe != null) {
this.stacks = recipe.getInput().getItems();
}
}
@Override
@OnlyIn(Dist.CLIENT)
public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) {
super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
gui.getMinecraft().getTextureManager().bind(GuiBooklet.RES_LOC_GADGETS);
GuiUtils.drawTexturedModalRect(startX + 30, startY + 10, 80, 146, 68, 48, 0);
gui.renderScaledAsciiString("(" + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".reconstructorRecipe") + ")", startX + 6, startY + 63, 0, false, gui.getMediumFontSize());
PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 88);
if (this.recipe != null) {
if (this.counter++ % 50 == 0) {
gui.addOrModifyItemRenderer(this.stacks[this.rotate++ % this.stacks.length], startX + 30 + 1, startY + 10 + 13, 1F, true);
}
}
}
@Override
@OnlyIn(Dist.CLIENT)
public void init(GuiBookletBase gui, int startX, int startY) {
super.init(gui, startX, startY);
if (this.recipe != null) {
gui.addOrModifyItemRenderer(this.stacks[0], startX + 30 + 1, startY + 10 + 13, 1F, true);
gui.addOrModifyItemRenderer(this.recipe.getOutput(), startX + 30 + 47, startY + 10 + 13, 1F, false);
}
}
@Override
public void getItemStacksForPage(List<ItemStack> list) {
super.getItemStacksForPage(list);
if (this.recipe != null) {
ItemStack copy = this.recipe.getOutput().copy();
if (this.isWildcard) {
copy.setDamageValue(Util.WILDCARD);
}
list.add(copy);
}
}
public BookletPage setWildcard() {
this.isWildcard = true;
return this;
}
@Override
public int getSortingPriority() {
return 20;
}
}
///*
// * This file ("PageReconstructor.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet.page;
//
//import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
//import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
//import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
//import de.ellpeck.actuallyadditions.mod.util.Util;
//import net.minecraft.item.ItemStack;
//import net.minecraftforge.api.distmarker.Dist;
//import net.minecraftforge.api.distmarker.OnlyIn;
//import net.minecraftforge.fml.client.gui.GuiUtils;
//
//import java.util.List;
//
//public class PageReconstructor extends BookletPage {
//
// private final LensConversionRecipe recipe;
// private boolean isWildcard;
// private int counter = 0;
// private int rotate = 0;
// private ItemStack[] stacks;
//
// public PageReconstructor(int localizationKey, LensConversionRecipe recipe) {
// super(localizationKey);
// this.recipe = recipe;
// if (recipe != null) {
// this.stacks = recipe.getInput().getItems();
// }
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) {
// super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
//
// gui.getMinecraft().getTextureManager().bind(GuiBooklet.RES_LOC_GADGETS);
// GuiUtils.drawTexturedModalRect(startX + 30, startY + 10, 80, 146, 68, 48, 0);
//
// gui.renderScaledAsciiString("(" + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".reconstructorRecipe") + ")", startX + 6, startY + 63, 0, false, gui.getMediumFontSize());
//
// PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 88);
// if (this.recipe != null) {
// if (this.counter++ % 50 == 0) {
// gui.addOrModifyItemRenderer(this.stacks[this.rotate++ % this.stacks.length], startX + 30 + 1, startY + 10 + 13, 1F, true);
// }
// }
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void init(GuiBookletBase gui, int startX, int startY) {
// super.init(gui, startX, startY);
//
// if (this.recipe != null) {
// gui.addOrModifyItemRenderer(this.stacks[0], startX + 30 + 1, startY + 10 + 13, 1F, true);
// gui.addOrModifyItemRenderer(this.recipe.getOutput(), startX + 30 + 47, startY + 10 + 13, 1F, false);
// }
// }
//
// @Override
// public void getItemStacksForPage(List<ItemStack> list) {
// super.getItemStacksForPage(list);
//
// if (this.recipe != null) {
// ItemStack copy = this.recipe.getOutput().copy();
// if (this.isWildcard) {
// copy.setDamageValue(Util.WILDCARD);
// }
// list.add(copy);
// }
// }
//
// public BookletPage setWildcard() {
// this.isWildcard = true;
// return this;
// }
//
// @Override
// public int getSortingPriority() {
// return 20;
// }
//}

View file

@ -1,41 +1,41 @@
/*
* This file ("PageTextOnly.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.page;
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class PageTextOnly extends BookletPage {
public PageTextOnly(int localizationKey, int priority) {
super(localizationKey, priority);
}
public PageTextOnly(int localizationKey) {
super(localizationKey);
}
@OnlyIn(Dist.CLIENT)
public static void renderTextToPage(GuiBookletBase gui, BookletPage page, int x, int y) {
String text = page.getInfoText();
if (text != null && !text.isEmpty()) {
gui.renderSplitScaledAsciiString(text, x, y, 0, false, gui.getMediumFontSize(), 120);
}
}
@Override
@OnlyIn(Dist.CLIENT)
public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) {
super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
renderTextToPage(gui, this, startX + 6, startY + 5);
}
}
///*
// * This file ("PageTextOnly.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet.page;
//
//import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
//import net.minecraftforge.api.distmarker.Dist;
//import net.minecraftforge.api.distmarker.OnlyIn;
//
//public class PageTextOnly extends BookletPage {
//
// public PageTextOnly(int localizationKey, int priority) {
// super(localizationKey, priority);
// }
//
// public PageTextOnly(int localizationKey) {
// super(localizationKey);
// }
//
// @OnlyIn(Dist.CLIENT)
// public static void renderTextToPage(GuiBookletBase gui, BookletPage page, int x, int y) {
// String text = page.getInfoText();
// if (text != null && !text.isEmpty()) {
// gui.renderSplitScaledAsciiString(text, x, y, 0, false, gui.getMediumFontSize(), 120);
// }
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) {
// super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
// renderTextToPage(gui, this, startX + 6, startY + 5);
// }
//}

View file

@ -1,109 +1,109 @@
/*
* This file ("PageTrials.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.booklet.page;
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
import de.ellpeck.actuallyadditions.mod.data.PlayerData.PlayerSave;
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class PageTrials extends BookletPage {
private final int buttonId;
@OnlyIn(Dist.CLIENT)
private Button button;
public PageTrials(int localizationKey, boolean button, boolean text) {
super(localizationKey);
if (!text) {
this.setNoText();
}
if (button) {
this.buttonId = PageLinkButton.nextButtonId;
PageLinkButton.nextButtonId++;
} else {
this.buttonId = -1;
}
}
@Override
@OnlyIn(Dist.CLIENT)
public void init(GuiBookletBase gui, int startX, int startY) {
super.init(gui, startX, startY);
if (this.buttonId >= 0) {
this.button = new Button(this.buttonId, startX + 125 / 2 - 50, startY + 120, 100, 20, "");
gui.getButtonList().add(this.button);
this.updateButton();
}
}
@Override
@OnlyIn(Dist.CLIENT)
public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) {
super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 5);
}
@Override
@OnlyIn(Dist.CLIENT)
protected String getLocalizationKey() {
return "booklet." + ActuallyAdditions.MODID + ".trials." + this.chapter.getIdentifier() + ".text." + this.localizationKey;
}
@Override
@OnlyIn(Dist.CLIENT)
public void actionPerformed(GuiBookletBase gui, Button button) {
if (this.buttonId >= 0 && button.id == this.buttonId) {
PlayerEntity player = Minecraft.getInstance().player;
PlayerSave data = PlayerData.getDataFromPlayer(player);
String id = this.chapter.getIdentifier();
boolean completed = data.completedTrials.contains(id);
if (completed) {
data.completedTrials.remove(id);
} else {
data.completedTrials.add(id);
}
this.updateButton();
PacketHandlerHelper.sendPlayerDataToServer(false, 2);
} else {
super.actionPerformed(gui, button);
}
}
@OnlyIn(Dist.CLIENT)
private void updateButton() {
if (this.buttonId >= 0 && this.button != null) {
PlayerEntity player = Minecraft.getInstance().player;
PlayerSave data = PlayerData.getDataFromPlayer(player);
boolean completed = data.completedTrials.contains(this.chapter.getIdentifier());
if (completed) {
this.button.displayString = TextFormatting.DARK_GREEN + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".trialFinishButton.completed.name");
} else {
this.button.displayString = TextFormatting.DARK_RED + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".trialFinishButton.uncompleted.name");
}
}
}
}
///*
// * This file ("PageTrials.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.booklet.page;
//
//import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
//import de.ellpeck.actuallyadditions.mod.data.PlayerData;
//import de.ellpeck.actuallyadditions.mod.data.PlayerData.PlayerSave;
//import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
//import net.minecraft.client.Minecraft;
//import net.minecraft.client.gui.widget.button.Button;
//import net.minecraft.entity.player.PlayerEntity;
//import net.minecraft.util.text.TextFormatting;
//import net.minecraftforge.api.distmarker.Dist;
//import net.minecraftforge.api.distmarker.OnlyIn;
//
//public class PageTrials extends BookletPage {
//
// private final int buttonId;
// @OnlyIn(Dist.CLIENT)
// private Button button;
//
// public PageTrials(int localizationKey, boolean button, boolean text) {
// super(localizationKey);
//
// if (!text) {
// this.setNoText();
// }
//
// if (button) {
// this.buttonId = PageLinkButton.nextButtonId;
// PageLinkButton.nextButtonId++;
// } else {
// this.buttonId = -1;
// }
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void init(GuiBookletBase gui, int startX, int startY) {
// super.init(gui, startX, startY);
//
// if (this.buttonId >= 0) {
// this.button = new Button(this.buttonId, startX + 125 / 2 - 50, startY + 120, 100, 20, "");
// gui.getButtonList().add(this.button);
// this.updateButton();
// }
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) {
// super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
// PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 5);
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// protected String getLocalizationKey() {
// return "booklet." + ActuallyAdditions.MODID + ".trials." + this.chapter.getIdentifier() + ".text." + this.localizationKey;
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void actionPerformed(GuiBookletBase gui, Button button) {
// if (this.buttonId >= 0 && button.id == this.buttonId) {
// PlayerEntity player = Minecraft.getInstance().player;
// PlayerSave data = PlayerData.getDataFromPlayer(player);
// String id = this.chapter.getIdentifier();
//
// boolean completed = data.completedTrials.contains(id);
// if (completed) {
// data.completedTrials.remove(id);
// } else {
// data.completedTrials.add(id);
// }
// this.updateButton();
//
// PacketHandlerHelper.sendPlayerDataToServer(false, 2);
// } else {
// super.actionPerformed(gui, button);
// }
// }
//
// @OnlyIn(Dist.CLIENT)
// private void updateButton() {
// if (this.buttonId >= 0 && this.button != null) {
// PlayerEntity player = Minecraft.getInstance().player;
// PlayerSave data = PlayerData.getDataFromPlayer(player);
//
// boolean completed = data.completedTrials.contains(this.chapter.getIdentifier());
// if (completed) {
// this.button.displayString = TextFormatting.DARK_GREEN + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".trialFinishButton.completed.name");
// } else {
// this.button.displayString = TextFormatting.DARK_RED + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".trialFinishButton.uncompleted.name");
// }
//
// }
// }
//}

View file

@ -10,57 +10,48 @@
package de.ellpeck.actuallyadditions.mod.config;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntListValues;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
import net.minecraft.block.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.config.Configuration;
public final class ConfigValues {
//
public static Item itemRedstoneTorchConfigurator;
public static Item itemCompassConfigurator;
public static void defineConfigValues(Configuration config) {
for (ConfigIntValues currConf : ConfigIntValues.values()) {
currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc, currConf.min, currConf.max).getInt();
}
for (ConfigBoolValues currConf : ConfigBoolValues.values()) {
currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getBoolean();
}
for (ConfigIntListValues currConf : ConfigIntListValues.values()) {
currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getIntList();
}
for (ConfigStringListValues currConf : ConfigStringListValues.values()) {
currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getStringList();
}
parseConfiguratorConfig();
}
private static void parseConfiguratorConfig() {
itemRedstoneTorchConfigurator = null;
itemCompassConfigurator = null;
String[] conf = ConfigStringListValues.CONFIGURE_ITEMS.getValue();
if (conf.length == 2) {
itemRedstoneTorchConfigurator = Item.REGISTRY.getObject(new ResourceLocation(conf[0]));
itemCompassConfigurator = Item.REGISTRY.getObject(new ResourceLocation(conf[1]));
}
if (itemRedstoneTorchConfigurator == null || itemCompassConfigurator == null) {
ActuallyAdditions.LOGGER.error("Parsing the Configuration Items config failed, reverting back to the default settings!");
itemRedstoneTorchConfigurator = Item.byBlock(Blocks.REDSTONE_TORCH);
itemCompassConfigurator = Items.COMPASS;
}
}
//
// public static void defineConfigValues(Configuration config) {
// for (ConfigIntValues currConf : ConfigIntValues.values()) {
// currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc, currConf.min, currConf.max).getInt();
// }
//
// for (ConfigBoolValues currConf : ConfigBoolValues.values()) {
// currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getBoolean();
// }
//
// for (ConfigIntListValues currConf : ConfigIntListValues.values()) {
// currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getIntList();
// }
//
// for (ConfigStringListValues currConf : ConfigStringListValues.values()) {
// currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getStringList();
// }
//
// parseConfiguratorConfig();
// }
//
// private static void parseConfiguratorConfig() {
// itemRedstoneTorchConfigurator = null;
// itemCompassConfigurator = null;
//
// String[] conf = ConfigStringListValues.CONFIGURE_ITEMS.getValue();
// if (conf.length == 2) {
// itemRedstoneTorchConfigurator = Item.REGISTRY.getObject(new ResourceLocation(conf[0]));
// itemCompassConfigurator = Item.REGISTRY.getObject(new ResourceLocation(conf[1]));
// }
//
// if (itemRedstoneTorchConfigurator == null || itemCompassConfigurator == null) {
// ActuallyAdditions.LOGGER.error("Parsing the Configuration Items config failed, reverting back to the default settings!");
//
// itemRedstoneTorchConfigurator = Item.byBlock(Blocks.REDSTONE_TORCH);
// itemCompassConfigurator = Items.COMPASS;
// }
// }
}

View file

@ -10,39 +10,33 @@
package de.ellpeck.actuallyadditions.mod.config;
import java.io.File;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.SubscribeEvent;
public class ConfigurationHandler {
public static Configuration config;
public ConfigurationHandler(File configFile) {
ActuallyAdditions.LOGGER.info("Grabbing Configurations...");
MinecraftForge.EVENT_BUS.register(this);
config = new Configuration(configFile);
config.load();
redefineConfigs();
}
public static void redefineConfigs() {
ConfigValues.defineConfigValues(config);
if (config.hasChanged()) {
config.save();
}
}
@SubscribeEvent
public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event) {
if (event.getModID().equalsIgnoreCase(ActuallyAdditions.MODID)) {
redefineConfigs();
}
}
//
// public static Configuration config;
//
// public ConfigurationHandler(File configFile) {
// ActuallyAdditions.LOGGER.info("Grabbing Configurations...");
//
// MinecraftForge.EVENT_BUS.register(this);
//
// config = new Configuration(configFile);
// config.load();
//
// redefineConfigs();
// }
//
// public static void redefineConfigs() {
// ConfigValues.defineConfigValues(config);
//
// if (config.hasChanged()) {
// config.save();
// }
// }
//
// @SubscribeEvent
// public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event) {
// if (event.getModID().equalsIgnoreCase(ActuallyAdditions.MODID)) {
// redefineConfigs();
// }
// }
}

View file

@ -1,5 +1,6 @@
package de.ellpeck.actuallyadditions.mod.crafting;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import net.minecraft.data.IFinishedRecipe;
@ -16,39 +17,44 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.registries.ForgeRegistryEntry;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class CrushingRecipe implements IRecipe<IInventory> {
public static String NAME = "crushing";
private ResourceLocation id;
private final ResourceLocation id;
protected Ingredient input;
protected ItemStack outputOne;
protected ItemStack outputTwo;
protected int outputChance;
protected float chance1;
protected float chance2;
public CrushingRecipe(ResourceLocation id, Ingredient input, ItemStack outputOne, ItemStack outputTwo, int outputChance) {
public CrushingRecipe(ResourceLocation id, Ingredient input, ItemStack outputOne, float chance1, ItemStack outputTwo, float chance2) {
this.id = id;
this.input = input;
this.outputOne = outputOne;
this.outputTwo = outputTwo;
this.outputChance = outputChance;
this.chance1 = chance1;
this.chance2 = chance2;
}
public CrushingRecipe(Ingredient input, ItemStack outputOne, ItemStack outputTwo, int outputChance) {
public CrushingRecipe(Ingredient input, ItemStack outputOne, float chance1, ItemStack outputTwo, float chance2) {
this.id = new ResourceLocation(ActuallyAdditions.MODID, input.getItems()[0].getItem().getRegistryName().getPath() + "_crushing");
this.input = input;
this.outputOne = outputOne;
this.outputTwo = outputTwo;
this.outputChance = outputChance;
this.chance1 = chance1;
this.chance2 = chance2;
}
@Override
public boolean matches(IInventory pInv, World pLevel) {
public boolean matches(IInventory pInv, @Nonnull World pLevel) {
return input.test(pInv.getItem(0));
}
@Override
public ItemStack assemble(IInventory pInv) {
@Nonnull
public ItemStack assemble(@Nonnull IInventory pInv) {
return ItemStack.EMPTY;
}
@ -58,21 +64,25 @@ public class CrushingRecipe implements IRecipe<IInventory> {
}
@Override
@Nonnull
public ItemStack getResultItem() {
return outputOne;
}
@Override
@Nonnull
public ResourceLocation getId() {
return id;
}
@Override
@Nonnull
public IRecipeSerializer<?> getSerializer() {
return ActuallyRecipes.CRUSHING_RECIPE.get();
}
@Override
@Nonnull
public IRecipeType<?> getType() {
return ActuallyRecipes.Types.CRUSHING;
}
@ -85,8 +95,11 @@ public class CrushingRecipe implements IRecipe<IInventory> {
return this.outputTwo;
}
public int getSecondChance() {
return this.outputChance;
public float getFirstChance() {
return this.chance1;
}
public float getSecondChance() {
return this.chance2;
}
public Ingredient getInput() {
@ -96,64 +109,96 @@ public class CrushingRecipe implements IRecipe<IInventory> {
public static class Serializer extends ForgeRegistryEntry<IRecipeSerializer<?>> implements IRecipeSerializer<CrushingRecipe> {
@Override
public CrushingRecipe fromJson(ResourceLocation pRecipeId, JsonObject pJson) {
Ingredient ingredient = Ingredient.fromJson(JSONUtils.getAsJsonObject(pJson, "input"));
ItemStack output1 = new ItemStack(JSONUtils.getAsItem(pJson, "output_one"));
ItemStack output2 = new ItemStack(JSONUtils.getAsItem(pJson, "output_two"));
int chance = JSONUtils.getAsInt(pJson, "second_chance");
@Nonnull
public CrushingRecipe fromJson(@Nonnull ResourceLocation pRecipeId, @Nonnull JsonObject pJson) {
Ingredient ingredient = Ingredient.fromJson(JSONUtils.getAsJsonObject(pJson, "ingredient"));
return new CrushingRecipe(pRecipeId, ingredient, output1, output2, chance);
JsonArray resultList = JSONUtils.getAsJsonObject(pJson, "result").getAsJsonArray();
if (resultList.size() < 1)
throw new IllegalStateException(pRecipeId.toString() + ": Recipe must contain at least 1 result item");
ItemStack output1 = new ItemStack(JSONUtils.getAsItem(resultList.get(0).getAsJsonObject(), "item"));
float chance1 = JSONUtils.getAsFloat(resultList.get(0).getAsJsonObject(), "chance");
ItemStack output2 = ItemStack.EMPTY;
float chance2 = 1.0f;
if (resultList.size() > 1) {
output2 = new ItemStack(JSONUtils.getAsItem(resultList.get(1).getAsJsonObject(), "item"));
chance2 = JSONUtils.getAsFloat(resultList.get(1).getAsJsonObject(), "chance");
}
return new CrushingRecipe(pRecipeId, ingredient, output1, chance1, output2, chance2);
}
@Nullable
@Override
public CrushingRecipe fromNetwork(ResourceLocation pRecipeId, PacketBuffer pBuffer) {
public CrushingRecipe fromNetwork(@Nonnull ResourceLocation pRecipeId, @Nonnull PacketBuffer pBuffer) {
Ingredient ingredient = Ingredient.fromNetwork(pBuffer);
ItemStack output1 = pBuffer.readItem();
ItemStack output2 = pBuffer.readItem();
int chance = pBuffer.readInt();
float chance1 = pBuffer.readFloat();
float chance2 = pBuffer.readFloat();
return new CrushingRecipe(pRecipeId, ingredient, output1, output2, chance);
return new CrushingRecipe(pRecipeId, ingredient, output1, chance1, output2, chance2);
}
@Override
public void toNetwork(PacketBuffer pBuffer, CrushingRecipe pRecipe) {
public void toNetwork(@Nonnull PacketBuffer pBuffer, CrushingRecipe pRecipe) {
pRecipe.input.toNetwork(pBuffer);
pBuffer.writeItem(pRecipe.outputOne);
pBuffer.writeItem(pRecipe.outputTwo);
pBuffer.writeInt(pRecipe.outputChance);
pBuffer.writeFloat(pRecipe.chance1);
pBuffer.writeFloat(pRecipe.chance2);
}
}
public static class FinishedRecipe implements IFinishedRecipe {
private ResourceLocation id;
private final ResourceLocation id;
protected Ingredient input;
protected IItemProvider outputOne;
protected int countOne;
protected float outputChance1;
protected IItemProvider outputTwo;
protected int outputChance;
protected int countTwo;
protected float outputChance2;
public FinishedRecipe(ResourceLocation id, Ingredient input, IItemProvider outputOne, IItemProvider outputTwo, int outputChance) {
public FinishedRecipe(ResourceLocation id, Ingredient input, IItemProvider outputOne, int countOne, float outputChance1, IItemProvider outputTwo, int countTwo, float outputChance2) {
this.id = id;
this.countOne = countOne;
this.countTwo = countTwo;
this.input = input;
this.outputOne = outputOne;
this.outputTwo = outputTwo;
this.outputChance = outputChance;
this.outputChance1 = outputChance1;
this.outputChance2 = outputChance2;
}
@Override
public void serializeRecipeData(JsonObject pJson) {
pJson.add("input", input.toJson());
pJson.addProperty("output_one", outputOne.asItem().getRegistryName().toString());
pJson.addProperty("output_two", outputTwo.asItem().getRegistryName().toString());
pJson.addProperty("second_chance", outputChance);
pJson.add("ingredient", input.toJson());
JsonObject result1 = new JsonObject();
result1.addProperty("item", outputOne.asItem().getRegistryName().toString());
result1.addProperty("chance", outputChance1);
JsonObject result2 = new JsonObject();
result1.addProperty("item", outputTwo.asItem().getRegistryName().toString());
result1.addProperty("chance", outputChance2);
JsonArray resultList = new JsonArray();
resultList.add(result1);
resultList.add(result2);
pJson.add("result", resultList);
}
@Override
@Nonnull
public ResourceLocation getId() {
return id;
}
@Override
@Nonnull
public IRecipeSerializer<?> getType() {
return ActuallyRecipes.CRUSHING_RECIPE.get();
}

View file

@ -15,13 +15,14 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.registries.ForgeRegistryEntry;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
public class EmpowererRecipe implements IRecipe<IInventory> {
public static String NAME = "empowering";
private ResourceLocation id;
private final ResourceLocation id;
protected final Ingredient input;
protected final ItemStack output;
@ -73,12 +74,13 @@ public class EmpowererRecipe implements IRecipe<IInventory> {
}
@Override
public boolean matches(IInventory pInv, World pLevel) {
public boolean matches(@Nonnull IInventory pInv, @Nonnull World pLevel) {
return false;
}
@Override
public ItemStack assemble(IInventory pInv) {
@Nonnull
public ItemStack assemble(@Nonnull IInventory pInv) {
return output.copy();
}
@ -88,21 +90,25 @@ public class EmpowererRecipe implements IRecipe<IInventory> {
}
@Override
@Nonnull
public ItemStack getResultItem() {
return output;
}
@Override
@Nonnull
public ResourceLocation getId() {
return id;
}
@Override
@Nonnull
public IRecipeSerializer<?> getSerializer() {
return ActuallyRecipes.EMPOWERING_RECIPE.get();
}
@Override
@Nonnull
public IRecipeType<?> getType() {
return ActuallyRecipes.Types.EMPOWERING;
}
@ -145,8 +151,8 @@ public class EmpowererRecipe implements IRecipe<IInventory> {
public static class Serializer extends ForgeRegistryEntry<IRecipeSerializer<?>> implements IRecipeSerializer<EmpowererRecipe> {
@Override
public EmpowererRecipe fromJson(ResourceLocation pRecipeId, JsonObject pJson) {
ItemStack result = new ItemStack(JSONUtils.getAsItem(pJson, "result"));
@Nonnull
public EmpowererRecipe fromJson(@Nonnull ResourceLocation pRecipeId, @Nonnull JsonObject pJson) {
Ingredient base = Ingredient.fromJson(JSONUtils.getAsJsonObject(pJson, "base"));
Ingredient mod1 = Ingredient.fromJson(JSONUtils.getAsJsonObject(pJson, "modifier1"));
Ingredient mod2 = Ingredient.fromJson(JSONUtils.getAsJsonObject(pJson, "modifier2"));
@ -155,13 +161,15 @@ public class EmpowererRecipe implements IRecipe<IInventory> {
int energy = JSONUtils.getAsInt(pJson, "energy");
int color = JSONUtils.getAsInt(pJson, "color");
int time = JSONUtils.getAsInt(pJson, "time");
JsonObject resultObject = JSONUtils.getAsJsonObject(pJson, "result");
ItemStack result = new ItemStack(JSONUtils.getAsItem(resultObject, "item"));
return new EmpowererRecipe(pRecipeId, result, base, mod1, mod2, mod3, mod4, energy, color, time);
}
@Nullable
@Override
public EmpowererRecipe fromNetwork(ResourceLocation pRecipeId, PacketBuffer pBuffer) {
public EmpowererRecipe fromNetwork(@Nonnull ResourceLocation pRecipeId, PacketBuffer pBuffer) {
ItemStack result = pBuffer.readItem();
Ingredient input = Ingredient.fromNetwork(pBuffer);
Ingredient mod1 = Ingredient.fromNetwork(pBuffer);
@ -190,16 +198,16 @@ public class EmpowererRecipe implements IRecipe<IInventory> {
}
public static class FinishedRecipe implements IFinishedRecipe {
private ResourceLocation id;
private Ingredient base;
private Ingredient mod1;
private Ingredient mod2;
private Ingredient mod3;
private Ingredient mod4;
private int energy;
private int color;
private int time;
private IItemProvider output;
private final ResourceLocation id;
private final Ingredient base;
private final Ingredient mod1;
private final Ingredient mod2;
private final Ingredient mod3;
private final Ingredient mod4;
private final int energy;
private final int color;
private final int time;
private final IItemProvider output;
public FinishedRecipe(ResourceLocation id, IItemProvider output, Ingredient input, Ingredient modifier1, Ingredient modifier2, Ingredient modifier3, Ingredient modifier4, int energyPerStand, int particleColor, int time) {
this.id = id;
@ -224,15 +232,21 @@ public class EmpowererRecipe implements IRecipe<IInventory> {
pJson.addProperty("energy", energy);
pJson.addProperty("time", time);
pJson.addProperty("color", color);
pJson.addProperty("result", output.asItem().getRegistryName().toString());
JsonObject resultObject = new JsonObject();
resultObject.addProperty("item", output.asItem().getRegistryName().toString());
pJson.add("result", resultObject);
}
@Override
@Nonnull
public ResourceLocation getId() {
return id;
}
@Override
@Nonnull
public IRecipeSerializer<?> getType() {
return ActuallyRecipes.EMPOWERING_RECIPE.get();
}

View file

@ -4,7 +4,10 @@ import com.google.gson.JsonObject;
import net.minecraft.data.IFinishedRecipe;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.*;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.IItemProvider;
import net.minecraft.util.JSONUtils;
@ -80,7 +83,8 @@ public class LaserRecipe implements IRecipe<IInventory> {
public LaserRecipe fromJson(ResourceLocation pRecipeId, JsonObject pJson) {
Ingredient ingredient = Ingredient.fromJson(JSONUtils.getAsJsonObject(pJson, "ingredient"));
int energy = JSONUtils.getAsInt(pJson, "energy");
ItemStack result = new ItemStack(JSONUtils.getAsItem(pJson, "result"));
JsonObject resultObject = JSONUtils.getAsJsonObject(pJson, "result");
ItemStack result = new ItemStack(JSONUtils.getAsItem(resultObject, "item"));
return new LaserRecipe(pRecipeId, result, ingredient, energy);
}
@ -117,9 +121,13 @@ public class LaserRecipe implements IRecipe<IInventory> {
@Override
public void serializeRecipeData(JsonObject pJson) {
pJson.add("input", itemIngredient.toJson());
pJson.add("ingredient", itemIngredient.toJson());
pJson.addProperty("energy", energy);
pJson.addProperty("output", output.asItem().getRegistryName().toString());
JsonObject resultObject = new JsonObject();
resultObject.addProperty("item", output.asItem().getRegistryName().toString());
pJson.add("result", resultObject);
}
@Override

View file

@ -11,6 +11,7 @@ import net.minecraft.util.IItemProvider;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.crafting.IIngredientSerializer;
import javax.annotation.Nonnull;
import java.util.stream.Stream;
public class TargetNBTIngredient extends Ingredient {
@ -19,6 +20,7 @@ public class TargetNBTIngredient extends Ingredient {
}
@Override
@Nonnull
public IIngredientSerializer<? extends Ingredient> getSerializer() {
return SERIALIZER;
}
@ -29,13 +31,15 @@ public class TargetNBTIngredient extends Ingredient {
public static TargetNBTIngredient of(ItemStack itemStack) {
return new TargetNBTIngredient(Stream.of(new SingleItemList(itemStack)));
}
public static TargetNBTIngredient of(ITag tag) {
@Nonnull
public static TargetNBTIngredient of(@Nonnull ITag tag) {
return new TargetNBTIngredient(Stream.of(new TagList(tag)));
}
@Override
@Nonnull
public JsonElement toJson() {
JsonObject tmp = super.toJson().getAsJsonObject();
tmp.addProperty("type", Serializer.NAME.toString());
@ -48,12 +52,14 @@ public class TargetNBTIngredient extends Ingredient {
public static ResourceLocation NAME = new ResourceLocation(ActuallyAdditions.MODID, "nbt_target");
@Override
@Nonnull
public TargetNBTIngredient parse(PacketBuffer buffer) {
return new TargetNBTIngredient(Stream.generate(() -> new SingleItemList(buffer.readItem())).limit(buffer.readVarInt()));
}
@Override
public TargetNBTIngredient parse(JsonObject json) {
@Nonnull
public TargetNBTIngredient parse(@Nonnull JsonObject json) {
return new TargetNBTIngredient(Stream.of(Ingredient.valueFromJson(json)));
}

View file

@ -1,92 +0,0 @@
/*
* This file ("ToolCrafting.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.crafting;
// TODO: [port] MOVE TO DATA_GENERATOR
@Deprecated
public final class ToolCrafting {
//
// public static final ArrayList<IRecipe> RECIPES_PAXELS = new ArrayList<>();
//
// public static void init() {
//
// addToolAndArmorRecipes(new ItemStack(Items.EMERALD), InitItems.itemPickaxeEmerald, InitItems.itemSwordEmerald, InitItems.itemAxeEmerald, InitItems.itemShovelEmerald, InitItems.itemHoeEmerald, InitItems.itemHelmEmerald, InitItems.itemChestEmerald, InitItems.itemPantsEmerald, InitItems.itemBootsEmerald);
// addToolAndArmorRecipes("gemQuartzBlack", InitItems.itemPickaxeQuartz, InitItems.itemSwordQuartz, InitItems.itemAxeQuartz, InitItems.itemShovelQuartz, InitItems.itemHoeQuartz, InitItems.itemHelmQuartz, InitItems.itemChestQuartz, InitItems.itemPantsQuartz, InitItems.itemBootsQuartz);
// addToolAndArmorRecipes(new ItemStack(Blocks.OBSIDIAN), InitItems.itemPickaxeObsidian, InitItems.itemSwordObsidian, InitItems.itemAxeObsidian, InitItems.itemShovelObsidian, InitItems.itemHoeObsidian, InitItems.itemHelmObsidian, InitItems.itemChestObsidian, InitItems.itemPantsObsidian, InitItems.itemBootsObsidian);
//
// addToolAndArmorRecipes(new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), InitItems.itemPickaxeCrystalRed, InitItems.itemSwordCrystalRed, InitItems.itemAxeCrystalRed, InitItems.itemShovelCrystalRed, InitItems.itemHoeCrystalRed, InitItems.itemHelmCrystalRed, InitItems.itemChestCrystalRed, InitItems.itemPantsCrystalRed, InitItems.itemBootsCrystalRed);
// addToolAndArmorRecipes(new ItemStack(InitItems.itemCrystal, 1, TheCrystals.EMERALD.ordinal()), InitItems.itemPickaxeCrystalGreen, InitItems.itemSwordCrystalGreen, InitItems.itemAxeCrystalGreen, InitItems.itemShovelCrystalGreen, InitItems.itemHoeCrystalGreen, InitItems.itemHelmCrystalGreen, InitItems.itemChestCrystalGreen, InitItems.itemPantsCrystalGreen, InitItems.itemBootsCrystalGreen);
// addToolAndArmorRecipes(new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), InitItems.itemPickaxeCrystalWhite, InitItems.itemSwordCrystalWhite, InitItems.itemAxeCrystalWhite, InitItems.itemShovelCrystalWhite, InitItems.itemHoeCrystalWhite, InitItems.itemHelmCrystalWhite, InitItems.itemChestCrystalWhite, InitItems.itemPantsCrystalWhite, InitItems.itemBootsCrystalWhite);
// addToolAndArmorRecipes(new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), InitItems.itemPickaxeCrystalLightBlue, InitItems.itemSwordCrystalLightBlue, InitItems.itemAxeCrystalLightBlue, InitItems.itemShovelCrystalLightBlue, InitItems.itemHoeCrystalLightBlue, InitItems.itemHelmCrystalLightBlue, InitItems.itemChestCrystalLightBlue, InitItems.itemPantsCrystalLightBlue, InitItems.itemBootsCrystalLightBlue);
// addToolAndArmorRecipes(new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), InitItems.itemPickaxeCrystalBlue, InitItems.itemSwordCrystalBlue, InitItems.itemAxeCrystalBlue, InitItems.itemShovelCrystalBlue, InitItems.itemHoeCrystalBlue, InitItems.itemHelmCrystalBlue, InitItems.itemChestCrystalBlue, InitItems.itemPantsCrystalBlue, InitItems.itemBootsCrystalBlue);
// addToolAndArmorRecipes(new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), InitItems.itemPickaxeCrystalBlack, InitItems.itemSwordCrystalBlack, InitItems.itemAxeCrystalBlack, InitItems.itemShovelCrystalBlack, InitItems.itemHoeCrystalBlack, InitItems.itemHelmCrystalBlack, InitItems.itemChestCrystalBlack, InitItems.itemPantsCrystalBlack, InitItems.itemBootsCrystalBlack);
//
// //Paxels
// RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.woodenPaxel), new ItemStack(Items.WOODEN_AXE), new ItemStack(Items.WOODEN_PICKAXE), new ItemStack(Items.WOODEN_SHOVEL), new ItemStack(Items.WOODEN_SWORD), new ItemStack(Items.WOODEN_HOE));
// RECIPES_PAXELS.add(RecipeUtil.lastIRecipe());
// RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.stonePaxel), new ItemStack(Items.STONE_AXE), new ItemStack(Items.STONE_PICKAXE), new ItemStack(Items.STONE_SHOVEL), new ItemStack(Items.STONE_SWORD), new ItemStack(Items.STONE_HOE));
// RECIPES_PAXELS.add(RecipeUtil.lastIRecipe());
// RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.ironPaxel), new ItemStack(Items.IRON_AXE), new ItemStack(Items.IRON_PICKAXE), new ItemStack(Items.IRON_SHOVEL), new ItemStack(Items.IRON_SWORD), new ItemStack(Items.IRON_HOE));
// RECIPES_PAXELS.add(RecipeUtil.lastIRecipe());
// RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.goldPaxel), new ItemStack(Items.GOLDEN_AXE), new ItemStack(Items.GOLDEN_PICKAXE), new ItemStack(Items.GOLDEN_SHOVEL), new ItemStack(Items.GOLDEN_SWORD), new ItemStack(Items.GOLDEN_HOE));
// RECIPES_PAXELS.add(RecipeUtil.lastIRecipe());
// RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.diamondPaxel), new ItemStack(Items.DIAMOND_AXE), new ItemStack(Items.DIAMOND_PICKAXE), new ItemStack(Items.DIAMOND_SHOVEL), new ItemStack(Items.DIAMOND_SWORD), new ItemStack(Items.DIAMOND_HOE));
// RECIPES_PAXELS.add(RecipeUtil.lastIRecipe());
// RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.emeraldPaxel), new ItemStack(InitItems.itemAxeEmerald), new ItemStack(InitItems.itemPickaxeEmerald), new ItemStack(InitItems.itemSwordEmerald), new ItemStack(InitItems.itemShovelEmerald), new ItemStack(InitItems.itemHoeEmerald));
// RECIPES_PAXELS.add(RecipeUtil.lastIRecipe());
// RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.obsidianPaxel), new ItemStack(InitItems.itemAxeObsidian), new ItemStack(InitItems.itemPickaxeObsidian), new ItemStack(InitItems.itemSwordObsidian), new ItemStack(InitItems.itemShovelObsidian), new ItemStack(InitItems.itemHoeObsidian));
// RECIPES_PAXELS.add(RecipeUtil.lastIRecipe());
// RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.quartzPaxel), new ItemStack(InitItems.itemAxeQuartz), new ItemStack(InitItems.itemPickaxeQuartz), new ItemStack(InitItems.itemSwordQuartz), new ItemStack(InitItems.itemShovelQuartz), new ItemStack(InitItems.itemHoeQuartz));
// RECIPES_PAXELS.add(RecipeUtil.lastIRecipe());
//
// RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemPaxelCrystalRed), new ItemStack(InitItems.itemAxeCrystalRed), new ItemStack(InitItems.itemPickaxeCrystalRed), new ItemStack(InitItems.itemSwordCrystalRed), new ItemStack(InitItems.itemShovelCrystalRed), new ItemStack(InitItems.itemHoeCrystalRed));
// RECIPES_PAXELS.add(RecipeUtil.lastIRecipe());
// RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemPaxelCrystalGreen), new ItemStack(InitItems.itemAxeCrystalGreen), new ItemStack(InitItems.itemPickaxeCrystalGreen), new ItemStack(InitItems.itemSwordCrystalGreen), new ItemStack(InitItems.itemShovelCrystalGreen), new ItemStack(InitItems.itemHoeCrystalGreen));
// RECIPES_PAXELS.add(RecipeUtil.lastIRecipe());
// RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemPaxelCrystalBlue), new ItemStack(InitItems.itemAxeCrystalBlue), new ItemStack(InitItems.itemPickaxeCrystalBlue), new ItemStack(InitItems.itemSwordCrystalBlue), new ItemStack(InitItems.itemShovelCrystalBlue), new ItemStack(InitItems.itemHoeCrystalBlue));
// RECIPES_PAXELS.add(RecipeUtil.lastIRecipe());
// RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemPaxelCrystalLightBlue), new ItemStack(InitItems.itemAxeCrystalLightBlue), new ItemStack(InitItems.itemPickaxeCrystalLightBlue), new ItemStack(InitItems.itemSwordCrystalLightBlue), new ItemStack(InitItems.itemShovelCrystalLightBlue), new ItemStack(InitItems.itemHoeCrystalLightBlue));
// RECIPES_PAXELS.add(RecipeUtil.lastIRecipe());
// RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemPaxelCrystalBlack), new ItemStack(InitItems.itemAxeCrystalBlack), new ItemStack(InitItems.itemPickaxeCrystalBlack), new ItemStack(InitItems.itemSwordCrystalBlack), new ItemStack(InitItems.itemShovelCrystalBlack), new ItemStack(InitItems.itemHoeCrystalBlack));
// RECIPES_PAXELS.add(RecipeUtil.lastIRecipe());
// RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemPaxelCrystalWhite), new ItemStack(InitItems.itemAxeCrystalWhite), new ItemStack(InitItems.itemPickaxeCrystalWhite), new ItemStack(InitItems.itemSwordCrystalWhite), new ItemStack(InitItems.itemShovelCrystalWhite), new ItemStack(InitItems.itemHoeCrystalWhite));
// RECIPES_PAXELS.add(RecipeUtil.lastIRecipe());
// }
//
// public static void addToolAndArmorRecipes(Object base, Item pickaxe, Item sword, Item axe, Item shovel, Item hoe, Item helm, Item chest, Item pants, Item boots) {
// //Pickaxe
// RecipeHandler.addOreDictRecipe(new ItemStack(pickaxe), "EEE", " S ", " S ", 'E', base, 'S', new ItemStack(Items.STICK));
//
// //Sword
// RecipeHandler.addOreDictRecipe(new ItemStack(sword), "E", "E", "S", 'E', base, 'S', new ItemStack(Items.STICK));
//
// //Axe
// RecipeHandler.addOreDictRecipe(new ItemStack(axe), "EE", "ES", " S", 'E', base, 'S', new ItemStack(Items.STICK));
//
// //Shovel
// RecipeHandler.addOreDictRecipe(new ItemStack(shovel), "E", "S", "S", 'E', base, 'S', new ItemStack(Items.STICK));
//
// //Hoe
// RecipeHandler.addOreDictRecipe(new ItemStack(hoe), "EE", " S", " S", 'E', base, 'S', new ItemStack(Items.STICK));
//
// //Helm
// RecipeHandler.addShapedRecipe(new ItemStack(helm), "OOO", "O O", 'O', base);
//
// //Chest
// RecipeHandler.addShapedRecipe(new ItemStack(chest), "O O", "OOO", "OOO", 'O', base);
//
// //Legs
// RecipeHandler.addShapedRecipe(new ItemStack(pants), "OOO", "O O", "O O", 'O', base);
//
// //Boots
// RecipeHandler.addShapedRecipe(new ItemStack(boots), "O O", "O O", 'O', base);
// }
}

View file

@ -11,14 +11,10 @@
package de.ellpeck.actuallyadditions.mod.data;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.nbt.StringNBT;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import java.util.ArrayList;
import java.util.List;
@ -59,8 +55,8 @@ public final class PlayerData {
public IBookletPage[] bookmarks = new IBookletPage[12];
public List<String> completedTrials = new ArrayList<>();
@OnlyIn(Dist.CLIENT)
public GuiBooklet lastOpenBooklet;
// @OnlyIn(Dist.CLIENT)
// public GuiBooklet lastOpenBooklet;
public PlayerSave(UUID id) {
this.id = id;
@ -103,8 +99,8 @@ public final class PlayerData {
ListNBT bookmarks = new ListNBT();
for (IBookletPage bookmark : this.bookmarks) {
bookmarks.add(StringNBT.valueOf(bookmark == null
? ""
: bookmark.getIdentifier()));
? ""
: bookmark.getIdentifier()));
}
return bookmarks;
}
@ -113,8 +109,8 @@ public final class PlayerData {
for (int i = 0; i < bookmarks.size(); i++) {
String strg = bookmarks.getString(i);
if (!strg.isEmpty()) {
IBookletPage page = BookletUtils.getBookletPageById(strg);
this.bookmarks[i] = page;
// IBookletPage page = BookletUtils.getBookletPageById(strg);
this.bookmarks[i] = null; // page;
} else {
this.bookmarks[i] = null;
}

View file

@ -12,85 +12,71 @@ package de.ellpeck.actuallyadditions.mod.entity;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.DefaultFarmerBehavior;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.IGrowable;
import net.minecraft.block.*;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.IPacket;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.IPlantable;
public class EntityWorm extends Entity {
public int timer;
public EntityWorm(World world) {
super(world);
this.setEntityBoundingBox(new AxisAlignedBB(0, 0, 0, 0, 0, 0));
public EntityWorm(EntityType<?> type, World world) {
super(type, world);
this.setBoundingBox(new AxisAlignedBB(0, 0, 0, 0, 0, 0));
}
public static boolean canWormify(World world, BlockPos pos, BlockState state) {
Block block = state.getBlock();
boolean rightBlock = block instanceof BlockFarmland || block instanceof BlockDirt || block instanceof BlockGrass;
boolean rightBlock = block instanceof FarmlandBlock || block == Blocks.DIRT || block instanceof GrassBlock;
if (rightBlock) {
BlockPos posUp = pos.above();
BlockState stateUp = world.getBlockState(posUp);
Block blockUp = stateUp.getBlock();
return blockUp instanceof IPlantable || blockUp instanceof BlockBush || blockUp.canBeReplaced(world, posUp);
return blockUp instanceof IPlantable || blockUp instanceof BushBlock || stateUp.getMaterial().isReplaceable();
} else {
return false;
}
}
@Override
protected void entityInit() {
public boolean canUpdate() {
return true;
}
@Override
protected void readEntityFromNBT(CompoundNBT compound) {
this.timer = compound.getInt("Timer");
}
@Override
protected void writeEntityToNBT(CompoundNBT compound) {
compound.putInt("Timer", this.timer);
}
@Override
public void onUpdate() {
this.onEntityUpdate();
}
@Override
public void onEntityUpdate() {
public void tick() {
if (!this.level.isClientSide) {
this.timer++;
if (this.timer % 50 == 0) {
for (int x = -1; x <= 1; x++) {
for (int z = -1; z <= 1; z++) {
BlockPos pos = new BlockPos(this.posX + x, this.posY, this.posZ + z);
BlockPos pos = new BlockPos(this.getX() + x, this.getY(), this.getZ() + z);
BlockState state = this.level.getBlockState(pos);
Block block = state.getBlock();
boolean isMiddlePose = x == 0 && z == 0;
if (canWormify(this.level, pos, state)) {
boolean isFarmland = block instanceof BlockFarmland;
boolean isFarmland = block instanceof FarmlandBlock;
if (!isFarmland || state.getValue(BlockFarmland.MOISTURE) < 7) {
if (!isFarmland || state.getValue(FarmlandBlock.MOISTURE) < 7) {
if (isMiddlePose || this.level.random.nextFloat() >= 0.45F) {
if (!isFarmland) {
DefaultFarmerBehavior.useHoeAt(this.level, pos);
}
state = this.level.getBlockState(pos);
isFarmland = state.getBlock() instanceof BlockFarmland;
isFarmland = state.getBlock() instanceof FarmlandBlock;
if (isFarmland) {
this.level.setBlock(pos, state.withProperty(BlockFarmland.MOISTURE, 7), 2);
this.level.setBlock(pos, state.setValue(FarmlandBlock.MOISTURE, 7), 2);
}
}
}
@ -101,8 +87,8 @@ public class EntityWorm extends Entity {
BlockState plantState = this.level.getBlockState(plant);
Block plantBlock = plantState.getBlock();
if ((plantBlock instanceof IGrowable || plantBlock instanceof IPlantable) && !(plantBlock instanceof BlockGrass)) {
plantBlock.updateTick(this.level, plant, plantState, this.level.random);
if ((plantBlock instanceof IGrowable || plantBlock instanceof IPlantable) && !(plantBlock instanceof GrassBlock)) {
plantBlock.randomTick(plantState, (ServerWorld) this.level, plant, this.level.random);
BlockState newState = this.level.getBlockState(plant);
if (newState != plantState) {
@ -124,4 +110,24 @@ public class EntityWorm extends Entity {
}
}
}
@Override
protected void defineSynchedData() {
}
@Override
protected void readAdditionalSaveData(CompoundNBT compound) {
this.timer = compound.getInt("Timer");
}
@Override
protected void addAdditionalSaveData(CompoundNBT compound) {
compound.putInt("Timer", this.timer);
}
@Override
public IPacket<?> getAddEntityPacket() {
return null;
}
}

View file

@ -11,9 +11,8 @@
package de.ellpeck.actuallyadditions.mod.entity;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public final class InitEntities {
@ -21,12 +20,12 @@ public final class InitEntities {
public static void init() {
ActuallyAdditions.LOGGER.info("Initializing Entities...");
EntityRegistry.registerModEntity(new ResourceLocation(ActuallyAdditions.MODID, "worm"), EntityWorm.class, ActuallyAdditions.MODID + ".worm", 0, ActuallyAdditions.INSTANCE, 64, 1, false);
//EntityRegistry.registerModEntity(new ResourceLocation(ActuallyAdditions.MODID, "worm"), EntityWorm.class, ActuallyAdditions.MODID + ".worm", 0, ActuallyAdditions.INSTANCE, 64, 1, false);
}
@OnlyIn(Dist.CLIENT)
public static void initClient() {
RenderingRegistry.registerEntityRenderingHandler(EntityWorm.class, RenderWorm::new);
//RenderingRegistry.registerEntityRenderingHandler(EntityWorm.class, RenderWorm::new);
}
}

View file

@ -10,47 +10,69 @@
package de.ellpeck.actuallyadditions.mod.entity;
import com.mojang.blaze3d.matrix.MatrixStack;
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureMap;
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.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.inventory.container.PlayerContainer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Util;
import net.minecraft.util.math.vector.Quaternion;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class RenderWorm extends Render<EntityWorm> {
public class RenderWorm extends EntityRenderer<EntityWorm> {
private static ItemStack stack = ItemStack.EMPTY;
public RenderWorm(EntityRendererManager p_i46179_1_) {
super(p_i46179_1_);
}
public static void fixItemStack() {
stack = new ItemStack(ActuallyItems.WORM.get());
}
protected RenderWorm(RenderManager renderManager) {
super(renderManager);
@Override
public void render(EntityWorm entity, float partialTicks, float p_225623_3_, MatrixStack matrix, IRenderTypeBuffer buffer, int light) {
matrix.pushPose();
matrix.translate(0, 0.7F, 0);
double boop = Util.getMillis() / 70D;
matrix.mulPose(new Quaternion(-(float) (boop % 360), 0, 1, 0));
// stack.getDisplayName()
Minecraft.getInstance().getItemRenderer().renderStatic(
stack, ItemCameraTransforms.TransformType.FIXED, light, OverlayTexture.NO_OVERLAY, matrix, buffer
);
matrix.popPose();
}
@Override
protected ResourceLocation getEntityTexture(EntityWorm entity) {
return TextureMap.LOCATION_BLOCKS_TEXTURE;
}
// @Override
// public void doRender(EntityWorm entity, double x, double y, double z, float entityYaw, float partialTicks) {
// GlStateManager.pushMatrix();
// this.bindEntityTexture(entity);
// GlStateManager.translate(x, y + 0.7F, z);
// double boop = Minecraft.getSystemTime() / 70D;
// GlStateManager.rotate(-(float) (boop % 360), 0, 1, 0);
// GlStateManager.translate(0, 0, 0.4);
//
// stack.setStackDisplayName(entity.getName());
// AssetUtil.renderItemInWorld(stack, combinedLightIn, combinedOverlayIn, matrices, buffer);
//
// GlStateManager.popMatrix();
// }
@Override
public void doRender(EntityWorm entity, double x, double y, double z, float entityYaw, float partialTicks) {
GlStateManager.pushMatrix();
this.bindEntityTexture(entity);
GlStateManager.translate(x, y + 0.7F, z);
double boop = Minecraft.getSystemTime() / 70D;
GlStateManager.rotate(-(float) (boop % 360), 0, 1, 0);
GlStateManager.translate(0, 0, 0.4);
stack.setStackDisplayName(entity.getName());
AssetUtil.renderItemInWorld(stack, combinedLightIn, combinedOverlayIn, matrices, buffer);
GlStateManager.popMatrix();
public ResourceLocation getTextureLocation(EntityWorm pEntity) {
return PlayerContainer.BLOCK_ATLAS;
}
}

View file

@ -10,243 +10,243 @@
package de.ellpeck.actuallyadditions.mod.inventory;
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiMainPage;
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
import de.ellpeck.actuallyadditions.mod.inventory.gui.*;
import de.ellpeck.actuallyadditions.mod.items.ItemBooklet;
//import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
//import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiMainPage;
//import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@Deprecated
enum GuiTypes {
FEEDER,
GIANT_CHEST,
GIANT_CHEST_PAGE_2,
GIANT_CHEST_PAGE_3,
CRAFTER(false),
GRINDER,
GRINDER_DOUBLE,
FURNACE_DOUBLE,
INPUTTER,
REPAIRER,
INPUTTER_ADVANCED,
BREAKER,
DROPPER,
CANOLA_PRESS,
FERMENTING_BARREL,
COAL_GENERATOR,
OIL_GENERATOR,
PHANTOM_PLACER,
FLUID_COLLECTOR,
COFFEE_MACHINE,
DRILL(false),
ENERGIZER,
ENERVATOR,
XP_SOLIDIFIER,
CLOUD,
BOOK(false),
DIRECTIONAL_BREAKER,
RANGED_COLLECTOR,
MINER,
LASER_RELAY_ITEM_WHITELIST,
FILTER(false),
BAG(false),
VOID_BAG(false),
BIO_REACTOR,
FARMER,
FIREWORK_BOX;
public final boolean checkTileEntity;
GuiTypes() {
this(true);
}
GuiTypes(boolean checkTileEntity) {
this.checkTileEntity = checkTileEntity;
}
}
public class GuiHandler {
@Deprecated
public Object getServerGuiElement(int id, PlayerEntity player, World world, int x, int y, int z) {
TileEntityBase tile = null;
if (GuiTypes.values()[id].checkTileEntity) {
tile = (TileEntityBase) world.getBlockEntity(new BlockPos(x, y, z));
}
switch (GuiTypes.values()[id]) {
// case FEEDER:
// return new ContainerFeeder(player.inventory, tile);
// case GIANT_CHEST:
// return new ContainerGiantChest(player.inventory, tile, 0);
// case GIANT_CHEST_PAGE_2:
// return new ContainerGiantChest(player.inventory, tile, 1);
// case GIANT_CHEST_PAGE_3:
// return new ContainerGiantChest(player.inventory, tile, 2);
// case CRAFTER:
// return CompatUtil.getCrafterContainerElement(player, world, x, y, z);
// case GRINDER:
// return new ContainerGrinder(player.inventory, tile, false);
// case GRINDER_DOUBLE:
// return new ContainerGrinder(player.inventory, tile, true);
// case FURNACE_DOUBLE:
// return new ContainerFurnaceDouble(player.inventory, tile);
// case INPUTTER:
// return new ContainerInputter(player.inventory, tile, false);
// case INPUTTER_ADVANCED:
// return new ContainerInputter(player.inventory, tile, true);
// case REPAIRER:
// return new ContainerRepairer(player.inventory, tile);
// case BREAKER:
// return new ContainerBreaker(player.inventory, tile);
// case DROPPER:
// return new ContainerDropper(player, tile);
// case CANOLA_PRESS:
// return new ContainerCanolaPress(player.inventory, tile);
// case FERMENTING_BARREL:
// return new ContainerFermentingBarrel(player.inventory, tile);
// case COAL_GENERATOR:
// return new ContainerCoalGenerator(player.inventory, tile);
// case OIL_GENERATOR:
// return new ContainerOilGenerator(player.inventory, tile);
// case PHANTOM_PLACER:
// return new ContainerPhantomPlacer(player.inventory, tile);
// case FLUID_COLLECTOR:
// return new ContainerFluidCollector(player.inventory, tile);
// case COFFEE_MACHINE:
// return new ContainerCoffeeMachine(player.inventory, tile);
// case DRILL:
// return new ContainerDrill(player.inventory);
// case FILTER:
// return new ContainerFilter(player.inventory);
// case ENERGIZER:
// return new ContainerEnergizer(player, tile);
// case ENERVATOR:
// return new ContainerEnervator(player, tile);
// case XP_SOLIDIFIER:
// return new ContainerXPSolidifier(player.inventory, tile);
// case CLOUD:
// return new ContainerSmileyCloud();
// case DIRECTIONAL_BREAKER:
// return new ContainerDirectionalBreaker(player.inventory, tile);
// case RANGED_COLLECTOR:
// return new ContainerRangedCollector(player.inventory, tile);
// case MINER:
// return new ContainerMiner(player.inventory, tile);
// case LASER_RELAY_ITEM_WHITELIST:
// return new ContainerLaserRelayItemWhitelist(player.inventory, tile);
// case BAG:
// return new ContainerBag(player.getHeldItemMainhand(), player.inventory, false);
// case VOID_BAG:
// return new ContainerBag(player.getHeldItemMainhand(), player.inventory, true);
// case BIO_REACTOR:
// return new ContainerBioReactor(player.inventory, tile);
// case FARMER:
// return new ContainerFarmer(player.inventory, tile);
// case FIREWORK_BOX:
// return new ContainerFireworkBox();
default:
return null;
}
// if (GuiTypes.values()[id].checkTileEntity) {
// tile = (TileEntityBase) world.getBlockEntity(new BlockPos(x, y, z));
// }
// switch (GuiTypes.values()[id]) {
// case FEEDER:
// return new ContainerFeeder(player.inventory, tile);
// case GIANT_CHEST:
// return new ContainerGiantChest(player.inventory, tile, 0);
// case GIANT_CHEST_PAGE_2:
// return new ContainerGiantChest(player.inventory, tile, 1);
// case GIANT_CHEST_PAGE_3:
// return new ContainerGiantChest(player.inventory, tile, 2);
// case CRAFTER:
// return CompatUtil.getCrafterContainerElement(player, world, x, y, z);
// case GRINDER:
// return new ContainerGrinder(player.inventory, tile, false);
// case GRINDER_DOUBLE:
// return new ContainerGrinder(player.inventory, tile, true);
// case FURNACE_DOUBLE:
// return new ContainerFurnaceDouble(player.inventory, tile);
// case INPUTTER:
// return new ContainerInputter(player.inventory, tile, false);
// case INPUTTER_ADVANCED:
// return new ContainerInputter(player.inventory, tile, true);
// case REPAIRER:
// return new ContainerRepairer(player.inventory, tile);
// case BREAKER:
// return new ContainerBreaker(player.inventory, tile);
// case DROPPER:
// return new ContainerDropper(player, tile);
// case CANOLA_PRESS:
// return new ContainerCanolaPress(player.inventory, tile);
// case FERMENTING_BARREL:
// return new ContainerFermentingBarrel(player.inventory, tile);
// case COAL_GENERATOR:
// return new ContainerCoalGenerator(player.inventory, tile);
// case OIL_GENERATOR:
// return new ContainerOilGenerator(player.inventory, tile);
// case PHANTOM_PLACER:
// return new ContainerPhantomPlacer(player.inventory, tile);
// case FLUID_COLLECTOR:
// return new ContainerFluidCollector(player.inventory, tile);
// case COFFEE_MACHINE:
// return new ContainerCoffeeMachine(player.inventory, tile);
// case DRILL:
// return new ContainerDrill(player.inventory);
// case FILTER:
// return new ContainerFilter(player.inventory);
// case ENERGIZER:
// return new ContainerEnergizer(player, tile);
// case ENERVATOR:
// return new ContainerEnervator(player, tile);
// case XP_SOLIDIFIER:
// return new ContainerXPSolidifier(player.inventory, tile);
// case CLOUD:
// return new ContainerSmileyCloud();
// case DIRECTIONAL_BREAKER:
// return new ContainerDirectionalBreaker(player.inventory, tile);
// case RANGED_COLLECTOR:
// return new ContainerRangedCollector(player.inventory, tile);
// case MINER:
// return new ContainerMiner(player.inventory, tile);
// case LASER_RELAY_ITEM_WHITELIST:
// return new ContainerLaserRelayItemWhitelist(player.inventory, tile);
// case BAG:
// return new ContainerBag(player.getHeldItemMainhand(), player.inventory, false);
// case VOID_BAG:
// return new ContainerBag(player.getHeldItemMainhand(), player.inventory, true);
// case BIO_REACTOR:
// return new ContainerBioReactor(player.inventory, tile);
// case FARMER:
// return new ContainerFarmer(player.inventory, tile);
// case FIREWORK_BOX:
// return new ContainerFireworkBox();
// default:
// return null;
// }
return null;
}
@Deprecated
public Object getClientGuiElement(int id, PlayerEntity player, World world, int x, int y, int z) {
TileEntityBase tile = null;
if (GuiTypes.values()[id].checkTileEntity) {
tile = (TileEntityBase) world.getBlockEntity(new BlockPos(x, y, z));
}
switch (GuiTypes.values()[id]) {
case FEEDER:
return new GuiFeeder(player.inventory, tile);
case GIANT_CHEST:
return new GuiGiantChest(player.inventory, tile, 0);
case GIANT_CHEST_PAGE_2:
return new GuiGiantChest(player.inventory, tile, 1);
case GIANT_CHEST_PAGE_3:
return new GuiGiantChest(player.inventory, tile, 2);
case CRAFTER:
return CompatUtil.getCrafterGuiElement(player, world, x, y, z);
case GRINDER:
return new GuiGrinder(player.inventory, tile);
case GRINDER_DOUBLE:
return new GuiGrinder.GuiGrinderDouble(player.inventory, tile);
case FURNACE_DOUBLE:
return new GuiFurnaceDouble(player.inventory, tile);
case INPUTTER:
return new GuiInputter(player.inventory, tile, false);
case INPUTTER_ADVANCED:
return new GuiInputter(player.inventory, tile, true);
case REPAIRER:
return new GuiRepairer(player.inventory, tile);
// case BREAKER:
// return new GuiBreaker(player.inventory, tile);
case DROPPER:
return new GuiDropper(player, tile);
case CANOLA_PRESS:
return new GuiCanolaPress(player.inventory, tile);
case FERMENTING_BARREL:
return new GuiFermentingBarrel(player.inventory, tile);
case COAL_GENERATOR:
return new GuiCoalGenerator(player.inventory, tile);
case OIL_GENERATOR:
return new GuiOilGenerator(player.inventory, tile);
case PHANTOM_PLACER:
return new GuiPhantomPlacer(player.inventory, tile);
case FLUID_COLLECTOR:
return new GuiFluidCollector(player.inventory, tile);
case COFFEE_MACHINE:
return new GuiCoffeeMachine(player.inventory, tile);
case DRILL:
return new GuiDrill(player.inventory);
case FILTER:
return new GuiFilter(player.inventory);
case ENERGIZER:
return new GuiEnergizer(player, tile);
case ENERVATOR:
return new GuiEnervator(player, tile);
case XP_SOLIDIFIER:
return new GuiXPSolidifier(player.inventory, tile);
case CLOUD:
return new GuiSmileyCloud(tile, x, y, z, world);
case BOOK:
if (ItemBooklet.forcedPage != null) {
GuiBooklet gui = BookletUtils.createBookletGuiFromPage(null, ItemBooklet.forcedPage);
ItemBooklet.forcedPage = null;
return gui;
} else {
PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player);
if (data.lastOpenBooklet != null) {
return data.lastOpenBooklet;
} else {
return new GuiMainPage(null);
}
}
case DIRECTIONAL_BREAKER:
return new GuiDirectionalBreaker(player.inventory, tile);
case RANGED_COLLECTOR:
return new GuiRangedCollector(player.inventory, tile);
case MINER:
return new GuiMiner(player.inventory, tile);
case LASER_RELAY_ITEM_WHITELIST:
return new GuiLaserRelayItemWhitelist(player.inventory, tile);
// case BAG:
// return new GuiBag(player.getHeldItemMainhand(), player.inventory, false);
// case VOID_BAG:
// return new GuiBag(player.getHeldItemMainhand(), player.inventory, true);
case BIO_REACTOR:
return new GuiBioReactor(player.inventory, tile);
case FARMER:
return new GuiFarmer(player.inventory, tile);
case FIREWORK_BOX:
return new GuiFireworkBox(tile);
default:
return null;
}
}
// TileEntityBase tile = null;
// if (GuiTypes.values()[id].checkTileEntity) {
// tile = (TileEntityBase) world.getBlockEntity(new BlockPos(x, y, z));
// }
// switch (GuiTypes.values()[id]) {
// case FEEDER:
// return new GuiFeeder(player.inventory, tile);
// case GIANT_CHEST:
// return new GuiGiantChest(player.inventory, tile, 0);
// case GIANT_CHEST_PAGE_2:
// return new GuiGiantChest(player.inventory, tile, 1);
// case GIANT_CHEST_PAGE_3:
// return new GuiGiantChest(player.inventory, tile, 2);
// case CRAFTER:
// return CompatUtil.getCrafterGuiElement(player, world, x, y, z);
// case GRINDER:
// return new GuiGrinder(player.inventory, tile);
// case GRINDER_DOUBLE:
// return new GuiGrinder.GuiGrinderDouble(player.inventory, tile);
// case FURNACE_DOUBLE:
// return new GuiFurnaceDouble(player.inventory, tile);
// case INPUTTER:
// return new GuiInputter(player.inventory, tile, false);
// case INPUTTER_ADVANCED:
// return new GuiInputter(player.inventory, tile, true);
// case REPAIRER:
// return new GuiRepairer(player.inventory, tile);
// // case BREAKER:
// // return new GuiBreaker(player.inventory, tile);
// case DROPPER:
// return new GuiDropper(player, tile);
// case CANOLA_PRESS:
// return new GuiCanolaPress(player.inventory, tile);
// case FERMENTING_BARREL:
// return new GuiFermentingBarrel(player.inventory, tile);
// case COAL_GENERATOR:
// return new GuiCoalGenerator(player.inventory, tile);
// case OIL_GENERATOR:
// return new GuiOilGenerator(player.inventory, tile);
// case PHANTOM_PLACER:
// return new GuiPhantomPlacer(player.inventory, tile);
// case FLUID_COLLECTOR:
// return new GuiFluidCollector(player.inventory, tile);
// case COFFEE_MACHINE:
// return new GuiCoffeeMachine(player.inventory, tile);
// case DRILL:
// return new GuiDrill(player.inventory);
// case FILTER:
// return new GuiFilter(player.inventory);
// case ENERGIZER:
// return new GuiEnergizer(player, tile);
// case ENERVATOR:
// return new GuiEnervator(player, tile);
// case XP_SOLIDIFIER:
// return new GuiXPSolidifier(player.inventory, tile);
// case CLOUD:
// return new GuiSmileyCloud(tile, x, y, z, world);
// case BOOK:
// if (ItemBooklet.forcedPage != null) {
// GuiBooklet gui = BookletUtils.createBookletGuiFromPage(null, ItemBooklet.forcedPage);
// ItemBooklet.forcedPage = null;
// return gui;
// } else {
// PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player);
// if (data.lastOpenBooklet != null) {
// return data.lastOpenBooklet;
// } else {
// return new GuiMainPage(null);
// }
// }
// case DIRECTIONAL_BREAKER:
// return new GuiDirectionalBreaker(player.inventory, tile);
// case RANGED_COLLECTOR:
// return new GuiRangedCollector(player.inventory, tile);
// case MINER:
// return new GuiMiner(player.inventory, tile);
// case LASER_RELAY_ITEM_WHITELIST:
// return new GuiLaserRelayItemWhitelist(player.inventory, tile);
// // case BAG:
// // return new GuiBag(player.getHeldItemMainhand(), player.inventory, false);
// // case VOID_BAG:
// // return new GuiBag(player.getHeldItemMainhand(), player.inventory, true);
// case BIO_REACTOR:
// return new GuiBioReactor(player.inventory, tile);
// case FARMER:
// return new GuiFarmer(player.inventory, tile);
// case FIREWORK_BOX:
// return new GuiFireworkBox(tile);
// default:
// return null;
@Deprecated
public enum GuiTypes {
FEEDER,
GIANT_CHEST,
GIANT_CHEST_PAGE_2,
GIANT_CHEST_PAGE_3,
CRAFTER(false),
GRINDER,
GRINDER_DOUBLE,
FURNACE_DOUBLE,
INPUTTER,
REPAIRER,
INPUTTER_ADVANCED,
BREAKER,
DROPPER,
CANOLA_PRESS,
FERMENTING_BARREL,
COAL_GENERATOR,
OIL_GENERATOR,
PHANTOM_PLACER,
FLUID_COLLECTOR,
COFFEE_MACHINE,
DRILL(false),
ENERGIZER,
ENERVATOR,
XP_SOLIDIFIER,
CLOUD,
BOOK(false),
DIRECTIONAL_BREAKER,
RANGED_COLLECTOR,
MINER,
LASER_RELAY_ITEM_WHITELIST,
FILTER(false),
BAG(false),
VOID_BAG(false),
BIO_REACTOR,
FARMER,
FIREWORK_BOX;
public final boolean checkTileEntity;
GuiTypes() {
this(true);
}
GuiTypes(boolean checkTileEntity) {
this.checkTileEntity = checkTileEntity;
}
return null;
}
}

View file

@ -171,17 +171,18 @@ public final class ActuallyItems {
public static final RegistryObject<Item> PANTS_QUARTZ = ITEMS.register("pants_quartz", () -> new ItemArmorAA(ArmorMaterials.QUARTZ, EquipmentSlotType.LEGS));
public static final RegistryObject<Item> BOOTS_QUARTZ = ITEMS.register("boots_quartz", () -> new ItemArmorAA(ArmorMaterials.QUARTZ, EquipmentSlotType.FEET));
public static final RegistryObject<Item> PICKAXE_QUARTZ = ITEMS.register("pickaxe_quartz", () -> new ItemPickaxeAA(ToolMaterials.QUARTZ));
public static final RegistryObject<Item> AXE_QUARTZ = ITEMS.register("axe_quartz", () -> new ItemAxeAA(ToolMaterials.QUARTZ));
public static final RegistryObject<Item> SHOVEL_QUARTZ = ITEMS.register("shovel_quartz", () -> new ItemShovelAA(ToolMaterials.QUARTZ));
public static final RegistryObject<Item> SWORD_QUARTZ = ITEMS.register("sword_quartz", () -> new ItemSwordAA(ToolMaterials.QUARTZ));
public static final RegistryObject<Item> HOE_QUARTZ = ITEMS.register("hoe_quartz", () -> new ItemHoeAA(ToolMaterials.QUARTZ));
public static final RegistryObject<Item> PICKAXE_QUARTZ = ITEMS.register("pickaxe_quartz", () -> new ItemPickaxeAA(ToolMaterials.BLACK_QUARTZ));
public static final RegistryObject<Item> AXE_QUARTZ = ITEMS.register("axe_quartz", () -> new ItemAxeAA(ToolMaterials.BLACK_QUARTZ));
public static final RegistryObject<Item> SHOVEL_QUARTZ = ITEMS.register("shovel_quartz", () -> new ItemShovelAA(ToolMaterials.BLACK_QUARTZ));
public static final RegistryObject<Item> SWORD_QUARTZ = ITEMS.register("sword_quartz", () -> new ItemSwordAA(ToolMaterials.BLACK_QUARTZ));
public static final RegistryObject<Item> HOE_QUARTZ = ITEMS.register("hoe_quartz", () -> new ItemHoeAA(ToolMaterials.BLACK_QUARTZ));
public static final RegistryObject<Item> WOODEN_PAXEL = ITEMS.register("wooden_paxel", () -> new ItemAllToolAA(ItemTier.WOOD));
public static final RegistryObject<Item> STONE_PAXEL = ITEMS.register("stone_paxel", () -> new ItemAllToolAA(ItemTier.STONE));
public static final RegistryObject<Item> IRON_PAXEL = ITEMS.register("iron_paxel", () -> new ItemAllToolAA(ItemTier.IRON));
public static final RegistryObject<Item> GOLD_PAXEL = ITEMS.register("gold_paxel", () -> new ItemAllToolAA(ItemTier.GOLD));
public static final RegistryObject<Item> DIAMOND_PAXEL = ITEMS.register("diamond_paxel", () -> new ItemAllToolAA(ItemTier.DIAMOND));
public static final RegistryObject<Item> QUARTZ_PAXEL = ITEMS.register("quartz_paxel", () -> new ItemAllToolAA(ToolMaterials.QUARTZ));
public static final RegistryObject<Item> NETHERITE_PAXEL = ITEMS.register("netherite_paxel", () -> new ItemAllToolAA(ItemTier.NETHERITE));
public static final RegistryObject<Item> QUARTZ_PAXEL = ITEMS.register("quartz_paxel", () -> new ItemAllToolAA(ToolMaterials.BLACK_QUARTZ));
public static final RegistryObject<Item> PICKAXE_CRYSTAL_RESTONIA = ITEMS.register("pickaxe_crystal_restonia", () -> new ItemPickaxeAA(ToolMaterials.RESTONIA));
public static final RegistryObject<Item> AXE_CRYSTAL_RESTONIA = ITEMS.register("axe_crystal_restonia", () -> new ItemAxeAA(ToolMaterials.RESTONIA));

View file

@ -14,14 +14,7 @@ import com.mojang.blaze3d.matrix.MatrixStack;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.IHudDisplay;
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.client.MainWindow;
import net.minecraft.client.Minecraft;
import net.minecraft.client.util.ITooltipFlag;
@ -53,30 +46,30 @@ public class ItemBooklet extends ItemBase implements IHudDisplay {
@Override
public ActionResultType useOn(ItemUseContext context) {
if (context.getPlayer().isShiftKeyDown()) {
BlockState state = context.getLevel().getBlockState(context.getClickedPos());
Block block = state.getBlock();
ItemStack blockStack = new ItemStack(block);
IBookletPage page = BookletUtils.findFirstPageForStack(blockStack);
if (page != null) {
if (context.getLevel().isClientSide) {
forcedPage = page;
}
this.use(context.getLevel(), context.getPlayer(), context.getHand());
return ActionResultType.SUCCESS;
}
}
// if (context.getPlayer().isShiftKeyDown()) {
// BlockState state = context.getLevel().getBlockState(context.getClickedPos());
// Block block = state.getBlock();
// ItemStack blockStack = new ItemStack(block);
// IBookletPage page = BookletUtils.findFirstPageForStack(blockStack);
// if (page != null) {
// if (context.getLevel().isClientSide) {
// forcedPage = page;
// }
// this.use(context.getLevel(), context.getPlayer(), context.getHand());
// return ActionResultType.SUCCESS;
// }
// }
return ActionResultType.FAIL;
}
@Override
public ActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.BOOK.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ);
if (!world.isClientSide) {
//TheAchievements.OPEN_BOOKLET.get(player);
//TheAchievements.OPEN_BOOKLET_MILESTONE.get(player);
}
// player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.BOOK.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ);
//
// if (!world.isClientSide) {
// //TheAchievements.OPEN_BOOKLET.get(player);
// //TheAchievements.OPEN_BOOKLET_MILESTONE.get(player);
// }
return ActionResult.success(player.getItemInHand(hand));
}
@ -87,46 +80,46 @@ public class ItemBooklet extends ItemBase implements IHudDisplay {
// TODO: this is bad
for (int i = 1; i <= 4; i++) {
tooltip.add(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + "." + this.getDescription().getString() + ".sub." + i).withStyle(i == 4
? TextFormatting.GOLD
: TextFormatting.RESET).withStyle(i == 4
? TextFormatting.ITALIC
: TextFormatting.RESET));
? TextFormatting.GOLD
: TextFormatting.RESET).withStyle(i == 4
? TextFormatting.ITALIC
: TextFormatting.RESET));
}
}
@Override
@OnlyIn(Dist.CLIENT)
public void displayHud(MatrixStack matrices, Minecraft minecraft, PlayerEntity player, ItemStack stack, RayTraceResult rayCast, MainWindow resolution) {
if (rayCast != null && rayCast.getBlockPos() != null) {
BlockState state = minecraft.level.getBlockState(rayCast.getBlockPos());
Block block = state.getBlock();
if (block != null && !block.isAir(minecraft.level.getBlockState(rayCast.getBlockPos()), minecraft.level, rayCast.getBlockPos())) {
ItemStack blockStack = new ItemStack(block, 1, block.getMetaFromState(state));
int height = resolution.getGuiScaledHeight() / 5 * 3;
if (player.isShiftKeyDown()) {
IBookletPage page = BookletUtils.findFirstPageForStack(blockStack);
if (page != null) {
String strg1 = page.getChapter().getLocalizedName();
String strg2 = StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.page") + " " + (page.getChapter().getPageIndex(page) + 1);
String strg3 = StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.open");
AssetUtil.renderStackToGui(StackUtil.isValid(page.getChapter().getDisplayItemStack())
? page.getChapter().getDisplayItemStack()
: new ItemStack(ActuallyItems.ITEM_BOOKLET.get()), resolution.getGuiScaledWidth() / 2 - 10, height + 41, 1F);
minecraft.font.drawShadow(TextFormatting.YELLOW + "" + TextFormatting.ITALIC + strg1, resolution.getGuiScaledWidth() / 2 - minecraft.font.width(strg1) / 2, height + 20, StringUtil.DECIMAL_COLOR_WHITE);
minecraft.font.drawShadow(TextFormatting.YELLOW + "" + TextFormatting.ITALIC + strg2, resolution.getGuiScaledWidth() / 2 - minecraft.font.width(strg2) / 2, height + 30, StringUtil.DECIMAL_COLOR_WHITE);
minecraft.font.drawShadow(TextFormatting.GOLD + strg3, resolution.getGuiScaledWidth() / 2 - minecraft.font.width(strg3) / 2, height + 60, StringUtil.DECIMAL_COLOR_WHITE);
} else {
String strg1 = TextFormatting.DARK_RED + StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.noInfo");
String strg2 = TextFormatting.DARK_GREEN + "" + TextFormatting.ITALIC + StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.noInfo.desc.1");
String strg3 = TextFormatting.DARK_GREEN + "" + TextFormatting.ITALIC + StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.noInfo.desc.2");
minecraft.font.drawShadow(strg1, resolution.getGuiScaledWidth() / 2 - minecraft.font.width(strg1) / 2, height + 30, StringUtil.DECIMAL_COLOR_WHITE);
minecraft.font.drawShadow(strg2, resolution.getGuiScaledWidth() / 2 - minecraft.font.width(strg2) / 2, height + 50, StringUtil.DECIMAL_COLOR_WHITE);
minecraft.font.drawShadow(strg3, resolution.getGuiScaledWidth() / 2 - minecraft.font.width(strg3) / 2, height + 60, StringUtil.DECIMAL_COLOR_WHITE);
}
}
}
}
// if (rayCast != null && rayCast.getBlockPos() != null) {
// BlockState state = minecraft.level.getBlockState(rayCast.getBlockPos());
// Block block = state.getBlock();
// if (block != null && !block.isAir(minecraft.level.getBlockState(rayCast.getBlockPos()), minecraft.level, rayCast.getBlockPos())) {
// ItemStack blockStack = new ItemStack(block, 1, block.getMetaFromState(state));
// int height = resolution.getGuiScaledHeight() / 5 * 3;
// if (player.isShiftKeyDown()) {
// IBookletPage page = BookletUtils.findFirstPageForStack(blockStack);
// if (page != null) {
// String strg1 = page.getChapter().getLocalizedName();
// String strg2 = StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.page") + " " + (page.getChapter().getPageIndex(page) + 1);
// String strg3 = StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.open");
//
// AssetUtil.renderStackToGui(StackUtil.isValid(page.getChapter().getDisplayItemStack())
// ? page.getChapter().getDisplayItemStack()
// : new ItemStack(ActuallyItems.ITEM_BOOKLET.get()), resolution.getGuiScaledWidth() / 2 - 10, height + 41, 1F);
// minecraft.font.drawShadow(TextFormatting.YELLOW + "" + TextFormatting.ITALIC + strg1, resolution.getGuiScaledWidth() / 2 - minecraft.font.width(strg1) / 2, height + 20, StringUtil.DECIMAL_COLOR_WHITE);
// minecraft.font.drawShadow(TextFormatting.YELLOW + "" + TextFormatting.ITALIC + strg2, resolution.getGuiScaledWidth() / 2 - minecraft.font.width(strg2) / 2, height + 30, StringUtil.DECIMAL_COLOR_WHITE);
// minecraft.font.drawShadow(TextFormatting.GOLD + strg3, resolution.getGuiScaledWidth() / 2 - minecraft.font.width(strg3) / 2, height + 60, StringUtil.DECIMAL_COLOR_WHITE);
// } else {
// String strg1 = TextFormatting.DARK_RED + StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.noInfo");
// String strg2 = TextFormatting.DARK_GREEN + "" + TextFormatting.ITALIC + StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.noInfo.desc.1");
// String strg3 = TextFormatting.DARK_GREEN + "" + TextFormatting.ITALIC + StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.noInfo.desc.2");
//
// minecraft.font.drawShadow(strg1, resolution.getGuiScaledWidth() / 2 - minecraft.font.width(strg1) / 2, height + 30, StringUtil.DECIMAL_COLOR_WHITE);
// minecraft.font.drawShadow(strg2, resolution.getGuiScaledWidth() / 2 - minecraft.font.width(strg2) / 2, height + 50, StringUtil.DECIMAL_COLOR_WHITE);
// minecraft.font.drawShadow(strg3, resolution.getGuiScaledWidth() / 2 - minecraft.font.width(strg3) / 2, height + 60, StringUtil.DECIMAL_COLOR_WHITE);
// }
// }
// }
// }
}
}

View file

@ -1,82 +1,82 @@
/*
* This file ("ItemCrystalShard.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.BlockCrystal;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.common.IRarity;
public class ItemCrystalShard extends ItemBase implements IColorProvidingItem {
public ItemCrystalShard() {
super(name);
this.setHasSubtypes(true);
this.setMaxDamage(0);
}
@Override
public int getMetadata(int damage) {
return damage;
}
@Override
public String getDescriptionId(ItemStack stack) {
return stack.getItemDamage() >= BlockCrystal.ALL_CRYSTALS.length
? StringUtil.BUGGED_ITEM_NAME
: this.getDescriptionId() + "_" + BlockCrystal.ALL_CRYSTALS[stack.getItemDamage()].name;
}
@Override
public IRarity getForgeRarity(ItemStack stack) {
return stack.getItemDamage() >= BlockCrystal.ALL_CRYSTALS.length
? EnumRarity.COMMON
: BlockCrystal.ALL_CRYSTALS[stack.getItemDamage()].rarity;
}
@Override
@OnlyIn(Dist.CLIENT)
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> list) {
if (this.isInCreativeTab(tab)) {
for (int j = 0; j < BlockCrystal.ALL_CRYSTALS.length; j++) {
list.add(new ItemStack(this, 1, j));
}
}
}
@Override
protected void registerRendering() {
for (int i = 0; i < BlockCrystal.ALL_CRYSTALS.length; i++) {
ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), "inventory");
}
}
@Override
@OnlyIn(Dist.CLIENT)
public IItemColor getItemColor() {
return (stack, tintIndex) -> {
int damage = stack.getItemDamage();
if (damage >= 0 && damage < BlockCrystal.ALL_CRYSTALS.length) {
return BlockCrystal.ALL_CRYSTALS[damage].clusterColor;
} else {
return 0;
}
};
}
}
///*
// * This file ("ItemCrystalShard.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.items;
//
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
//import de.ellpeck.actuallyadditions.mod.blocks.BlockCrystal;
//import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
//import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem;
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
//import net.minecraft.client.renderer.color.IItemColor;
//import net.minecraft.creativetab.CreativeTabs;
//import net.minecraft.item.EnumRarity;
//import net.minecraft.item.ItemStack;
//import net.minecraft.util.NonNullList;
//import net.minecraftforge.common.IRarity;
//
//
//public class ItemCrystalShard extends ItemBase implements IColorProvidingItem {
//
// public ItemCrystalShard() {
// super(name);
// this.setHasSubtypes(true);
// this.setMaxDamage(0);
// }
//
// @Override
// public int getMetadata(int damage) {
// return damage;
// }
//
// @Override
// public String getDescriptionId(ItemStack stack) {
// return stack.getItemDamage() >= BlockCrystal.ALL_CRYSTALS.length
// ? StringUtil.BUGGED_ITEM_NAME
// : this.getDescriptionId() + "_" + BlockCrystal.ALL_CRYSTALS[stack.getItemDamage()].name;
// }
//
// @Override
// public IRarity getForgeRarity(ItemStack stack) {
// return stack.getItemDamage() >= BlockCrystal.ALL_CRYSTALS.length
// ? EnumRarity.COMMON
// : BlockCrystal.ALL_CRYSTALS[stack.getItemDamage()].rarity;
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> list) {
// if (this.isInCreativeTab(tab)) {
// for (int j = 0; j < BlockCrystal.ALL_CRYSTALS.length; j++) {
// list.add(new ItemStack(this, 1, j));
// }
// }
// }
//
// @Override
// protected void registerRendering() {
// for (int i = 0; i < BlockCrystal.ALL_CRYSTALS.length; i++) {
// ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), "inventory");
// }
// }
//
// @Override
// @OnlyIn(Dist.CLIENT)
// public IItemColor getItemColor() {
// return (stack, tintIndex) -> {
// int damage = stack.getItemDamage();
// if (damage >= 0 && damage < BlockCrystal.ALL_CRYSTALS.length) {
// return BlockCrystal.ALL_CRYSTALS[damage].clusterColor;
// } else {
// return 0;
// }
// };
// }
//}

View file

@ -14,7 +14,6 @@ import com.google.common.collect.Multimap;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerDrill;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
@ -26,11 +25,13 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.material.Material;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.ai.attributes.Attribute;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.ai.attributes.Attributes;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.inventory.container.SimpleNamedContainerProvider;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.nbt.CompoundNBT;
@ -38,18 +39,14 @@ import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
import javax.annotation.Nullable;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class ItemDrill extends ItemEnergy {
@ -57,10 +54,7 @@ public class ItemDrill extends ItemEnergy {
private static final int ENERGY_USE = 100;
public ItemDrill() {
super(ActuallyItems.defaultProps().defaultDurability(0).stacksTo(1), 250000, 1000);
this.setHasSubtypes(true);
this.setHarvestLevel("shovel", HARVEST_LEVEL);
this.setHarvestLevel("pickaxe", HARVEST_LEVEL);
super(ActuallyItems.defaultProps().defaultDurability(0).stacksTo(1).addToolType(ToolType.SHOVEL, HARVEST_LEVEL).addToolType(ToolType.PICKAXE, HARVEST_LEVEL), 250000, 1000);
}
/**
@ -153,25 +147,21 @@ public class ItemDrill extends ItemEnergy {
@Override
public ActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
if (!world.isClientSide && player.isShiftKeyDown() && hand == Hand.MAIN_HAND) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.DRILL.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ);
player.openMenu(new SimpleNamedContainerProvider((id, inv, p) -> new ContainerDrill(id, inv), new StringTextComponent("")));
// player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.DRILL.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ);
}
return new ActionResult<>(ActionResultType.PASS, player.getItemInHand(hand));
}
@Override
public int getMetadata(int damage) {
return damage;
}
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase entity1, EntityLivingBase entity2) {
public ActionResultType interactLivingEntity(ItemStack stack, PlayerEntity player, LivingEntity entityHit, Hand hand) {
int use = this.getEnergyUsePerBlock(stack);
if (!(entity2 instanceof PlayerEntity) || !((PlayerEntity) entity2).isCreative()) {
if (!(entityHit instanceof PlayerEntity) || !((PlayerEntity) entityHit).isCreative()) {
if (this.getEnergyStored(stack) >= use) {
this.extractEnergyInternal(stack, use, false);
}
}
return true;
return ActionResultType.SUCCESS;
}
@Override
@ -192,7 +182,7 @@ public class ItemDrill extends ItemEnergy {
@Override
public float getDestroySpeed(ItemStack stack, BlockState state) {
return this.getEnergyStored(stack) >= this.getEnergyUsePerBlock(stack)
? this.hasExtraWhitelist(state.getBlock()) || state.getBlock().getHarvestTool(state) == null || state.getBlock().getHarvestTool(state) || this.getToolClasses(stack).contains(state.getBlock().getHarvestTool(state))
? (this.hasExtraWhitelist(state.getBlock()) || state.getBlock().getHarvestTool(state) == null || state.getBlock().getHarvestTool(state) == ToolType.PICKAXE || state.getBlock().getHarvestTool(state) == ToolType.SHOVEL)
? this.getEfficiencyFromUpgrade(stack)
: 1.0F
: 0.1F;
@ -240,7 +230,7 @@ public class ItemDrill extends ItemEnergy {
@Override
public boolean canHarvestBlock(ItemStack stack, BlockState state) {
Block block = state.getBlock();
return this.getEnergyStored(stack) >= this.getEnergyUsePerBlock(stack) && (this.hasExtraWhitelist(block) || state.getMaterial().isToolNotRequired() || block == Blocks.SNOW_LAYER || block == Blocks.SNOW || (block == Blocks.OBSIDIAN
return this.getEnergyStored(stack) >= this.getEnergyUsePerBlock(stack) && (this.hasExtraWhitelist(block) || state.getMaterial().isReplaceable() || block == Blocks.SNOW_BLOCK || block == Blocks.SNOW || (block == Blocks.OBSIDIAN
? HARVEST_LEVEL >= 3
: block != Blocks.DIAMOND_BLOCK && block != Blocks.DIAMOND_ORE
? block != Blocks.EMERALD_ORE && block != Blocks.EMERALD_BLOCK
@ -257,14 +247,6 @@ public class ItemDrill extends ItemEnergy {
: HARVEST_LEVEL >= 2));
}
@Override
public Set<String> getToolClasses(ItemStack stack) {
HashSet<String> hashSet = new HashSet<>();
hashSet.add("pickaxe");
hashSet.add("shovel");
return hashSet;
}
@Override
public int getHarvestLevel(ItemStack stack, ToolType p_getHarvestLevel_2_, @Nullable PlayerEntity p_getHarvestLevel_3_, @Nullable BlockState p_getHarvestLevel_4_) {
return HARVEST_LEVEL;
@ -325,25 +307,25 @@ public class ItemDrill extends ItemEnergy {
return StackUtil.isValid(this.getHasUpgradeAsStack(stack, upgrade));
}
@Override
@OnlyIn(Dist.CLIENT)
public void getSubItems(CreativeTabs tabs, NonNullList<ItemStack> list) {
if (this.isInCreativeTab(tabs)) {
for (int i = 0; i < 16; i++) {
this.addDrillStack(list, i);
}
}
}
// @Override
// @OnlyIn(Dist.CLIENT)
// public void getSubItems(CreativeTabs tabs, NonNullList<ItemStack> list) {
// if (this.isInCreativeTab(tabs)) {
// for (int i = 0; i < 16; i++) {
// this.addDrillStack(list, i);
// }
// }
// }
private void addDrillStack(List<ItemStack> list, int meta) {
ItemStack stackFull = new ItemStack(this, 1, meta);
this.setEnergy(stackFull, this.getMaxEnergyStored(stackFull));
list.add(stackFull);
ItemStack stackEmpty = new ItemStack(this, 1, meta);
this.setEnergy(stackEmpty, 0);
list.add(stackEmpty);
}
// private void addDrillStack(List<ItemStack> list, int meta) {
// ItemStack stackFull = new ItemStack(this, 1, meta);
// this.setEnergy(stackFull, this.getMaxEnergyStored(stackFull));
// list.add(stackFull);
//
// ItemStack stackEmpty = new ItemStack(this, 1, meta);
// this.setEnergy(stackEmpty, 0);
// list.add(stackEmpty);
// }
/**
* Gets the Mining Speed of the Drill

View file

@ -17,6 +17,7 @@ import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Rarity;
import net.minecraft.util.NonNullList;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@ -44,7 +45,7 @@ public class ItemDust extends ItemBase implements IColorProvidingItem {
}
@Override
public EnumRarity getRarity(ItemStack stack) {
public Rarity getRarity(ItemStack stack) {
return stack.getItemDamage() >= ALL_DUSTS.length
? EnumRarity.COMMON
: ALL_DUSTS[stack.getItemDamage()].rarity;

View file

@ -18,9 +18,8 @@ import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.EnumAction;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Rarity;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
@ -99,9 +98,9 @@ public class ItemFoods extends ItemFoodBase {
}
@Override
public EnumRarity getRarity(ItemStack stack) {
public Rarity getRarity(ItemStack stack) {
return stack.getItemDamage() >= ALL_FOODS.length
? EnumRarity.COMMON
? Rarity.COMMON
: ALL_FOODS[stack.getItemDamage()].rarity;
}

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.entity.EntityWorm;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
@ -51,7 +52,7 @@ public class ItemWorm extends ItemBase {
List<EntityWorm> worms = context.getLevel().getEntitiesOfClass(EntityWorm.class, new AxisAlignedBB(pos.getX() - 1, pos.getY(), pos.getZ() - 1, pos.getX() + 2, pos.getY() + 1, pos.getZ() + 2));
if (worms.isEmpty()) {
if (!context.getLevel().isClientSide) {
EntityWorm worm = new EntityWorm(context.getLevel());
EntityWorm worm = new EntityWorm(ActuallyAdditions.ENTITY_WORM.get(), context.getLevel());
worm.setPos(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
worm.setCustomName(stack.getHoverName()); // TODO: WHAT DOES THIS EVEN DO?
context.getLevel().addFreshEntity(worm);

View file

@ -11,12 +11,13 @@
package de.ellpeck.actuallyadditions.mod.items.base;
import de.ellpeck.actuallyadditions.api.misc.IDisableableItem;
import de.ellpeck.actuallyadditions.mod.config.ConfigurationHandler;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.Block;
import net.minecraft.item.*;
import net.minecraft.item.IItemTier;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ToolItem;
import net.minecraft.tags.ITag;
import java.util.Set;
@ -28,23 +29,32 @@ public class ItemToolAA extends ToolItem implements IDisableableItem {
private final ITag<Item> repairTag;
private final boolean disabled;
public ItemToolAA(float attack, float speed, IItemTier toolMat, String repairItem, String unlocalizedName, Rarity rarity, Set<Block> effectiveStuff) {
this(attack, speed, toolMat, ItemStack.EMPTY, unlocalizedName, rarity, effectiveStuff);
this.repairOredict = repairItem;
}
public ItemToolAA(float attack, float speed, ToolMaterial toolMat, ItemStack repairItem, String unlocalizedName, IRarity rarity, Set<Block> effectiveStuff) {
super(attack, speed, toolMat, effectiveStuff);
public ItemToolAA(float p_i48512_1_, float p_i48512_2_, IItemTier p_i48512_3_, Set<Block> p_i48512_4_, Properties p_i48512_5_, String name, ItemStack repairItem, ITag<Item> repairTag) {
super(p_i48512_1_, p_i48512_2_, p_i48512_3_, p_i48512_4_, p_i48512_5_);
this.name = name;
this.repairItem = repairItem;
this.name = unlocalizedName;
this.rarity = rarity;
this.disabled = ConfigurationHandler.config.getBoolean("Disable: " + StringUtil.badTranslate(unlocalizedName), "Tool Control", false, "This will disable the " + StringUtil.badTranslate(unlocalizedName) + ". It will not be registered.");
if (!this.disabled) {
this.register();
}
this.repairTag = repairTag;
this.disabled = false;
}
// public ItemToolAA(float attack, float speed, IItemTier toolMat, String repairItem, String unlocalizedName, Rarity rarity, Set<Block> effectiveStuff) {
// this(attack, speed, toolMat, ItemStack.EMPTY, unlocalizedName, rarity, effectiveStuff);
// this.repairOredict = repairItem;
// }
// public ItemToolAA(float attack, float speed, ToolMaterial toolMat, ItemStack repairItem, String unlocalizedName, Rarity rarity, Set<Block> effectiveStuff) {
// super(attack, speed, toolMat, effectiveStuff);
//
// this.repairItem = repairItem;
// this.name = unlocalizedName;
// this.rarity = rarity;
//// this.disabled = ConfigurationHandler.config.getBoolean("Disable: " + StringUtil.badTranslate(unlocalizedName), "Tool Control", false, "This will disable the " + StringUtil.badTranslate(unlocalizedName) + ". It will not be registered.");
//// if (!this.disabled) {
//// this.register();
//// }
// }
private void register() {
}

View file

@ -13,7 +13,7 @@ import java.util.function.Supplier;
* todo: review to ensure all values act as intended
*/
public enum ToolMaterials implements IItemTier {
QUARTZ(2, 280, 6.5f, 2.0f, 10, () -> Ingredient.of(ActuallyItems.BLACK_QUARTZ.get())),
BLACK_QUARTZ(2, 280, 6.5f, 2.0f, 10, () -> Ingredient.of(ActuallyItems.BLACK_QUARTZ.get())),
RESTONIA(2, 300, 7.0f, 2.25f, 12, () -> Ingredient.of(ActuallyItems.RESTONIA_CRYSTAL.get())),
PALIS(2, 300, 7.0f, 2.25f, 12, () -> Ingredient.of(ActuallyItems.PALIS_CRYSTAL.get())),
DIAMATINE(3, 1600, 9.0f, 4.0f, 14, () -> Ingredient.of(ActuallyItems.DIAMATINE_CRYSTAL.get())),

View file

@ -20,12 +20,6 @@ import de.ellpeck.actuallyadditions.api.lens.Lens;
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
import de.ellpeck.actuallyadditions.mod.blocks.BlockLaserRelay;
import de.ellpeck.actuallyadditions.mod.booklet.chapter.BookletChapter;
import de.ellpeck.actuallyadditions.mod.booklet.chapter.BookletChapterTrials;
import de.ellpeck.actuallyadditions.mod.booklet.page.PageCrafting;
import de.ellpeck.actuallyadditions.mod.booklet.page.PageFurnace;
import de.ellpeck.actuallyadditions.mod.booklet.page.PagePicture;
import de.ellpeck.actuallyadditions.mod.booklet.page.PageTextOnly;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
import de.ellpeck.actuallyadditions.mod.items.lens.LensRecipeHandler;
import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry;
@ -39,8 +33,8 @@ import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.potion.Effect;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Potion;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.ResourceLocation;
@ -97,12 +91,12 @@ public class MethodHandler implements IMethodHandler {
for (int i = 0; i < effects.length; i++) {
if (effects[i].getEffect() == effect.getEffect()) {
effects[i] = new EffectInstance(effects[i].getEffect(), effects[i].getDuration() + (addDur
? effect.getDuration()
: 0), effects[i].getAmplifier() + (addAmp
? effect.getAmplifier() > 0
? effect.getAmplifier()
: 1
: 0));
? effect.getDuration()
: 0), effects[i].getAmplifier() + (addAmp
? effect.getAmplifier() > 0
? effect.getAmplifier()
: 1
: 0));
}
this.addEffectToStack(stack, effects[i]);
}
@ -112,7 +106,7 @@ public class MethodHandler implements IMethodHandler {
public void addEffectToStack(ItemStack stack, EffectInstance effect) {
CompoundNBT tag = stack.getOrCreateTag();
int prevCounter = tag.putInt("Counter");
int prevCounter = tag.getInt("Counter");
CompoundNBT compound = new CompoundNBT();
//compound.putInt("ID", Potion.getIdFromPotion(effect.getEffect())); //TODO ?!
compound.putInt("Duration", effect.getDuration());
@ -132,13 +126,13 @@ public class MethodHandler implements IMethodHandler {
int counter = tag.getInt("Counter");
while (counter > 0) {
CompoundNBT compound = (CompoundNBT) tag.get(counter + "");
EffectInstance effect = new EffectInstance(Potion.getPotionById(compound.getInt("ID")), compound.getInt("Duration"), compound.getByte("Amplifier"));
EffectInstance effect = new EffectInstance(Effect.byId(compound.getInt("ID")), compound.getInt("Duration"), compound.getByte("Amplifier"));
effects.add(effect);
counter--;
}
return effects.size() > 0
? effects.toArray(new EffectInstance[effects.size()])
: null;
? effects.toArray(new EffectInstance[effects.size()])
: null;
}
@Override

View file

@ -1,56 +1,56 @@
package de.ellpeck.actuallyadditions.mod.recipe;
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
import de.ellpeck.actuallyadditions.api.recipe.IColorLensChanger;
import net.minecraft.block.BlockState;
import net.minecraft.item.DyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ColorLensRotator implements IColorLensChanger {
public static final Map<String, DyeColor> STRING_TO_ENUM = new HashMap<>();
static {
String[] dyes = {"White", "Orange", "Magenta", "LightBlue", "Yellow", "Lime", "Pink", "Gray", "LightGray", "Cyan", "Purple", "Blue", "Brown", "Green", "Red", "Black"};
for (int i = 0; i < dyes.length; i++) {
STRING_TO_ENUM.put("dye" + dyes[i], DyeColor.byMetadata(i));
}
}
final List<ItemStack> rotations;
public ColorLensRotator(List<ItemStack> rotations) {
this.rotations = rotations;
}
@Override
public ItemStack modifyItem(ItemStack stack, BlockState hitBlockState, BlockPos hitBlock, IAtomicReconstructor tile) {
int idx = -1;
for (int i : OreDictionary.getOreIDs(stack)) {
String s = OreDictionary.getOreName(i);
if (s.startsWith("dye")) {
DyeColor color = STRING_TO_ENUM.get(s);
if (color != null) {
idx = color.getMetadata();
break;
}
}
}
if (idx == -1) {
return ItemStack.EMPTY;
}
ItemStack s = this.rotations.get((idx + 1) % this.rotations.size()).copy();
s.setCount(stack.getCount());
return s;
}
}
//package de.ellpeck.actuallyadditions.mod.recipe;
//
//import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
//import de.ellpeck.actuallyadditions.api.recipe.IColorLensChanger;
//import net.minecraft.block.BlockState;
//import net.minecraft.item.DyeColor;
//import net.minecraft.item.ItemStack;
//import net.minecraft.util.math.BlockPos;
//
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//public class ColorLensRotator implements IColorLensChanger {
//
// public static final Map<String, DyeColor> STRING_TO_ENUM = new HashMap<>();
//
// static {
// String[] dyes = {"White", "Orange", "Magenta", "LightBlue", "Yellow", "Lime", "Pink", "Gray", "LightGray", "Cyan", "Purple", "Blue", "Brown", "Green", "Red", "Black"};
// for (int i = 0; i < dyes.length; i++) {
// STRING_TO_ENUM.put("dye" + dyes[i], DyeColor.byMetadata(i));
// }
// }
//
// final List<ItemStack> rotations;
//
// public ColorLensRotator(List<ItemStack> rotations) {
// this.rotations = rotations;
// }
//
// @Override
// public ItemStack modifyItem(ItemStack stack, BlockState hitBlockState, BlockPos hitBlock, IAtomicReconstructor tile) {
//
// int idx = -1;
//
// for (int i : OreDictionary.getOreIDs(stack)) {
// String s = OreDictionary.getOreName(i);
// if (s.startsWith("dye")) {
// DyeColor color = STRING_TO_ENUM.get(s);
// if (color != null) {
// idx = color.getMetadata();
// break;
// }
// }
// }
//
// if (idx == -1) {
// return ItemStack.EMPTY;
// }
//
// ItemStack s = this.rotations.get((idx + 1) % this.rotations.size()).copy();
// s.setCount(stack.getCount());
// return s;
// }
//
//}

View file

@ -187,7 +187,7 @@ public class TileEntityCrusher extends TileEntityInventoryBase implements IButto
public boolean canCrushOn(int theInput, int theFirstOutput, int theSecondOutput) {
if (StackUtil.isValid(this.inv.getStackInSlot(theInput))) {
CrushingRecipe recipe = CrusherRecipeRegistry.getRecipeFromInput(this.inv.getStackInSlot(theInput));
CrushingRecipe recipe = null;//CrusherRecipeRegistry.getRecipeFromInput(this.inv.getStackInSlot(theInput)); //TODO
if (recipe == null) {
return false;
}
@ -202,7 +202,7 @@ public class TileEntityCrusher extends TileEntityInventoryBase implements IButto
outputTwo.setDamage(0);
}
*/
if ((!StackUtil.isValid(this.inv.getStackInSlot(theFirstOutput)) || this.inv.getStackInSlot(theFirstOutput).sameItem(outputOne) && this.inv.getStackInSlot(theFirstOutput).getCount() <= this.inv.getStackInSlot(theFirstOutput).getMaxStackSize() - outputOne.getCount()) && (!StackUtil.isValid(outputTwo) || !StackUtil.isValid(this.inv.getStackInSlot(theSecondOutput)) || this.inv.getStackInSlot(theSecondOutput).isItemEqual(outputTwo) && this.inv.getStackInSlot(theSecondOutput).getCount() <= this.inv.getStackInSlot(theSecondOutput).getMaxStackSize() - outputTwo.getCount())) {
if ((!StackUtil.isValid(this.inv.getStackInSlot(theFirstOutput)) || this.inv.getStackInSlot(theFirstOutput).sameItem(outputOne) && this.inv.getStackInSlot(theFirstOutput).getCount() <= this.inv.getStackInSlot(theFirstOutput).getMaxStackSize() - outputOne.getCount()) && (!StackUtil.isValid(outputTwo) || !StackUtil.isValid(this.inv.getStackInSlot(theSecondOutput)) || this.inv.getStackInSlot(theSecondOutput).sameItem(outputTwo) && this.inv.getStackInSlot(theSecondOutput).getCount() <= this.inv.getStackInSlot(theSecondOutput).getMaxStackSize() - outputTwo.getCount())) {
return true;
}
}
@ -217,7 +217,7 @@ public class TileEntityCrusher extends TileEntityInventoryBase implements IButto
}
public void finishCrushing(int theInput, int theFirstOutput, int theSecondOutput) {
CrushingRecipe recipe = CrusherRecipeRegistry.getRecipeFromInput(this.inv.getStackInSlot(theInput));
CrushingRecipe recipe = null; //CrusherRecipeRegistry.getRecipeFromInput(this.inv.getStackInSlot(theInput));//TODO
if (recipe == null) {
return;
}
@ -242,7 +242,7 @@ public class TileEntityCrusher extends TileEntityInventoryBase implements IButto
outputTwo.setDamage(0);
}
*/
int rand = this.level.random.nextInt(100) + 1;
float rand = this.level.random.nextFloat();
if (rand <= recipe.getSecondChance()) {
if (!StackUtil.isValid(this.inv.getStackInSlot(theSecondOutput))) {
this.inv.setStackInSlot(theSecondOutput, outputTwo.copy());

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerEnergizer;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
@ -29,8 +30,6 @@ import net.minecraftforge.energy.IEnergyStorage;
import javax.annotation.Nullable;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase.NBTType;
public class TileEntityEnergizer extends TileEntityInventoryBase implements INamedContainerProvider {
public final CustomEnergyStorage storage = new CustomEnergyStorage(50000, 1000, 0);
@ -38,7 +37,7 @@ public class TileEntityEnergizer extends TileEntityInventoryBase implements INam
private int lastEnergy;
public TileEntityEnergizer() {
super(ActuallyTiles.ENERGIZER_TILE.get(), 2);
super(ActuallyBlocks.ENERGIZER.getTileEntityType(), 2);
}
@Override

View file

@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.farmer.FarmerResult;
import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior;
import de.ellpeck.actuallyadditions.api.internal.IFarmer;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerFarmer;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
@ -41,8 +42,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase.NBTType;
public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer, INamedContainerProvider {
private static final List<IFarmerBehavior> SORTED_FARMER_BEHAVIORS = new ArrayList<>();
@ -55,7 +54,7 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer
private int lastEnergy;
public TileEntityFarmer() {
super(ActuallyTiles.FARMER_TILE.get(), 12);
super(ActuallyBlocks.FARMER.getTileEntityType(), 12);
}
@Override

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerFeeder;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
import net.minecraft.entity.passive.AnimalEntity;
@ -32,8 +33,6 @@ import javax.annotation.Nullable;
import java.util.List;
import java.util.Optional;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase.NBTType;
public class TileEntityFeeder extends TileEntityInventoryBase implements INamedContainerProvider {
public static final int THRESHOLD = 30;
@ -44,7 +43,7 @@ public class TileEntityFeeder extends TileEntityInventoryBase implements INamedC
private int lastTimer;
public TileEntityFeeder() {
super(ActuallyTiles.FEEDER_TILE.get(), 1);
super(ActuallyBlocks.FEEDER.getTileEntityType(), 1);
}
public int getCurrentTimerToScale(int i) {

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerFireworkBox;
import de.ellpeck.actuallyadditions.mod.network.gui.INumberReactor;
import net.minecraft.entity.player.PlayerEntity;
@ -36,8 +37,6 @@ import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase.NBTType;
public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisplay, INumberReactor, INamedContainerProvider {
public static final int USE_PER_SHOT = 500;
@ -59,7 +58,7 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisp
private int oldEnergy;
public TileEntityFireworkBox() {
super(ActuallyTiles.FIREWORKBOX_TILE.get());
super(ActuallyBlocks.FIREWORK_BOX.getTileEntityType());
}
@Override

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerFluidCollector;
import de.ellpeck.actuallyadditions.mod.util.Util;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
@ -41,9 +42,6 @@ import net.minecraftforge.fluids.capability.templates.FluidTank;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase.NBTType;
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
public class TileEntityFluidCollector extends TileEntityBase implements ISharingFluidHandler, INamedContainerProvider {
public boolean isPlacer;
@ -84,7 +82,7 @@ public class TileEntityFluidCollector extends TileEntityBase implements ISharing
}
public TileEntityFluidCollector() {
this(ActuallyTiles.FLUIDCOLLECTOR_TILE.get());
this(ActuallyBlocks.FLUID_COLLECTOR.getTileEntityType());
this.isPlacer = false;
}

View file

@ -10,10 +10,12 @@
package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
public class TileEntityFluidPlacer extends TileEntityFluidCollector {
public TileEntityFluidPlacer() {
super(ActuallyTiles.FLUIDPLACER_TILE.get());
super(ActuallyBlocks.FLUID_PLACER.getTileEntityType());
this.isPlacer = true;
}

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
@ -25,8 +26,6 @@ import net.minecraftforge.energy.IEnergyStorage;
import java.util.ArrayList;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase.NBTType;
public class TileEntityHeatCollector extends TileEntityBase implements ISharingEnergyProvider, IEnergyDisplay {
public static final int ENERGY_PRODUCE = 40;
@ -37,7 +36,7 @@ public class TileEntityHeatCollector extends TileEntityBase implements ISharingE
private int disappearTime;
public TileEntityHeatCollector() {
super(ActuallyTiles.HEATCOLLECTOR_TILE.get());
super(ActuallyBlocks.HEAT_COLLECTOR.getTileEntityType());
}
@Override

View file

@ -11,6 +11,7 @@
package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.api.laser.Network;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
import de.ellpeck.actuallyadditions.mod.network.PacketServerToClient;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
@ -66,9 +67,9 @@ public class TileEntityItemInterface extends TileEntityBase {
IItemHandlerInfo info = TileEntityItemInterface.this.getSwitchedIndexHandler(slot);
if (info != null && info.isLoaded() && TileEntityItemInterface.this.isWhitelisted(info, stack, false)) {
ItemStack remain = info.handler.insertItem(info.switchedIndex, stack, simulate);
if (!ItemStack.areItemStacksEqual(remain, stack) && !simulate) {
TileEntityItemInterface.this.markDirty();
TileEntityItemInterface.this.doItemParticle(stack, info.relayInQuestion.getPos(), TileEntityItemInterface.this.connectedRelay.getPos());
if (!ItemStack.isSame(remain, stack) && !simulate) {
TileEntityItemInterface.this.setChanged();
TileEntityItemInterface.this.doItemParticle(stack, info.relayInQuestion.getBlockPos(), TileEntityItemInterface.this.connectedRelay.getBlockPos());
}
return remain;
}
@ -83,8 +84,8 @@ public class TileEntityItemInterface extends TileEntityBase {
if (info != null && info.isLoaded() && TileEntityItemInterface.this.isWhitelisted(info, stackIn, true)) {
ItemStack extracted = info.handler.extractItem(info.switchedIndex, amount, simulate);
if (StackUtil.isValid(extracted) && !simulate) {
TileEntityItemInterface.this.markDirty();
TileEntityItemInterface.this.doItemParticle(extracted, TileEntityItemInterface.this.connectedRelay.getPos(), info.relayInQuestion.getPos());
TileEntityItemInterface.this.setChanged();
TileEntityItemInterface.this.doItemParticle(extracted, TileEntityItemInterface.this.connectedRelay.getBlockPos(), info.relayInQuestion.getBlockPos());
}
return extracted;
}
@ -118,7 +119,7 @@ public class TileEntityItemInterface extends TileEntityBase {
}
public TileEntityItemInterface() {
this(ActuallyTiles.ITEMVIEWER_TILE.get());
this(ActuallyBlocks.ITEM_INTERFACE.getTileEntityType());
}
@Override
@ -153,9 +154,9 @@ public class TileEntityItemInterface extends TileEntityBase {
}
public void doItemParticle(ItemStack stack, BlockPos input, BlockPos output) {
if (!this.world.isRemote) {
if (!this.level.isClientSide) {
CompoundNBT compound = new CompoundNBT();
stack.write(compound);
stack.save(compound);
compound.putDouble("InX", input.getX());
compound.putDouble("InY", input.getY());
@ -166,9 +167,9 @@ public class TileEntityItemInterface extends TileEntityBase {
compound.putDouble("OutZ", output.getZ());
int rangeSq = 16 * 16;
for (PlayerEntity player : this.world.getPlayers()) {
for (PlayerEntity player : this.level.players()) {
if (player instanceof ServerPlayerEntity) {
if (player.getDistanceSq(input.getX(), input.getY(), input.getZ()) <= rangeSq || player.getDistanceSq(output.getX(), output.getY(), output.getZ()) <= rangeSq) {
if (player.distanceToSqr(input.getX(), input.getY(), input.getZ()) <= rangeSq || player.distanceToSqr(output.getX(), output.getY(), output.getZ()) <= rangeSq) {
PacketHandler.sendTo(new PacketServerToClient(compound, PacketHandler.LASER_PARTICLE_HANDLER), (ServerPlayerEntity) player);
}
}
@ -249,13 +250,13 @@ public class TileEntityItemInterface extends TileEntityBase {
@Override
public void saveDataOnChangeOrWorldStart() {
TileEntityLaserRelayItem tileFound = null;
if (this.world != null) { //Why is that even possible..?
if (this.level != null) { //Why is that even possible..?
for (int i = 0; i <= 5; i++) {
Direction side = WorldUtil.getDirectionBySidesInOrder(i);
BlockPos pos = this.getPos().offset(side);
BlockPos pos = this.getBlockPos().relative(side);
if (this.world.isBlockLoaded(pos)) {
TileEntity tile = this.world.getTileEntity(pos);
if (this.level.isLoaded(pos)) {
TileEntity tile = this.level.getBlockEntity(pos);
if (tile instanceof TileEntityLaserRelayItem) {
if (tileFound != null) {
@ -312,7 +313,7 @@ public class TileEntityItemInterface extends TileEntityBase {
}
public boolean isLoaded() {
return this.relayInQuestion.hasWorld() && this.relayInQuestion.getWorld().isBlockLoaded(this.relayInQuestion.getPos());
return this.relayInQuestion.hasLevel() && this.relayInQuestion.getLevel().isLoaded(this.relayInQuestion.getBlockPos());
}
}
@ -326,7 +327,7 @@ public class TileEntityItemInterface extends TileEntityBase {
}
public boolean isLoaded() {
return this.relayInQuestion.hasWorld() && this.relayInQuestion.getWorld().isBlockLoaded(this.relayInQuestion.getPos());
return this.relayInQuestion.hasLevel() && this.relayInQuestion.getLevel().isLoaded(this.relayInQuestion.getBlockPos());
}
@Override

View file

@ -11,15 +11,18 @@
package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper;
import net.minecraft.block.BlockState;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.EntityPredicates;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.common.util.LazyOptional;
@ -34,7 +37,7 @@ public class TileEntityItemInterfaceHopping extends TileEntityItemInterface {
private SlotlessableItemHandlerWrapper handlerToPushTo;
public TileEntityItemInterfaceHopping() {
super(ActuallyTiles.ITEMVIEWERHOPPING_TILE.get());
super(ActuallyBlocks.ITEM_INTERFACE_HOPPING.getTileEntityType());
}
@Override
@ -42,12 +45,14 @@ public class TileEntityItemInterfaceHopping extends TileEntityItemInterface {
super.updateEntity();
// TODO: [port] validate this is the correct way to get total game time getGameTime
if (!this.world.isRemote && this.world.getWorldInfo().getGameTime() % 10 == 0) {
if (!this.level.isClientSide && this.level.getLevelData().getGameTime() % 10 == 0) {
if (this.handlerToPullFrom != null) {
WorldUtil.doItemInteraction(this.handlerToPullFrom, this.itemHandler, 4);
} else {
if (this.world.getWorldInfo().getGameTime() % 20 == 0) {
List<ItemEntity> items = this.world.getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(this.pos.getX(), this.pos.getY() + 0.5, this.pos.getZ(), this.pos.getX() + 1, this.pos.getY() + 2, this.pos.getZ() + 1));
if (this.level.getLevelData().getGameTime() % 20 == 0) {
//TODO hmm?
AxisAlignedBB axisAlignedBB = new AxisAlignedBB(this.getBlockPos().getX(), this.getBlockPos().getY() + 0.5, this.getBlockPos().getZ(), this.getBlockPos().getX() + 1, this.getBlockPos().getY() + 2, this.getBlockPos().getZ() + 1);
List<ItemEntity> items = this.level.getEntities(EntityType.ITEM, axisAlignedBB, EntityPredicates.ENTITY_STILL_ALIVE);
if (items != null && !items.isEmpty()) {
for (ItemEntity item : items) {
if (item != null && item.isAlive()) {
@ -96,7 +101,7 @@ public class TileEntityItemInterfaceHopping extends TileEntityItemInterface {
this.handlerToPullFrom = null;
this.handlerToPushTo = null;
TileEntity from = this.world.getTileEntity(this.pos.offset(Direction.UP));
TileEntity from = this.level.getBlockEntity(this.getBlockPos().relative(Direction.UP));
if (from != null && !(from instanceof TileEntityItemInterface)) {
LazyOptional<IItemHandler> normal = from.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.DOWN);
@ -112,12 +117,12 @@ public class TileEntityItemInterfaceHopping extends TileEntityItemInterface {
this.handlerToPullFrom = new SlotlessableItemHandlerWrapper(normal, slotless);
}
BlockState state = this.world.getBlockState(this.pos);
Direction facing = state.get(BlockStateProperties.FACING);
BlockState state = this.level.getBlockState(this.getBlockPos());
Direction facing = state.getValue(BlockStateProperties.FACING);
BlockPos toPos = this.pos.offset(facing);
if (this.world.isBlockLoaded(toPos)) {
TileEntity to = this.world.getTileEntity(toPos);
BlockPos toPos = this.getBlockPos().relative(facing);
if (this.level.isLoaded(toPos)) {
TileEntity to = this.level.getBlockEntity(toPos);
if (to != null && !(to instanceof TileEntityItemInterface)) {
LazyOptional<IItemHandler> normal = to.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite());

View file

@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.api.laser.IConnectionPair;
import de.ellpeck.actuallyadditions.api.laser.LaserType;
import de.ellpeck.actuallyadditions.api.laser.Network;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
@ -36,8 +37,6 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase.NBTType;
public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay {
public static final int CAP = 1000;
@ -85,7 +84,7 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay {
}
public TileEntityLaserRelayEnergy() {
this(ActuallyTiles.LASERRELAYENERGY_TILE.get());
this(ActuallyBlocks.LASER_RELAY.getTileEntityType());
}
private int transmitEnergy(Direction from, int maxTransmit, boolean simulate) {

View file

@ -10,12 +10,14 @@
package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
public class TileEntityLaserRelayEnergyAdvanced extends TileEntityLaserRelayEnergy {
public static final int CAP = 10000;
public TileEntityLaserRelayEnergyAdvanced() {
super(ActuallyTiles.LASERRELAYENERGYADVANCED_TILE.get());
super(ActuallyBlocks.LASER_RELAY_ADVANCED.getTileEntityType());
}
@Override

View file

@ -10,12 +10,14 @@
package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
public class TileEntityLaserRelayEnergyExtreme extends TileEntityLaserRelayEnergy {
public static final int CAP = 100000;
public TileEntityLaserRelayEnergyExtreme() {
super(ActuallyTiles.LASERRELAYENERGYEXTREME_TILE.get());
super(ActuallyBlocks.LASER_RELAY_EXTREME.getTileEntityType());
}
@Override

View file

@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.api.laser.IConnectionPair;
import de.ellpeck.actuallyadditions.api.laser.LaserType;
import de.ellpeck.actuallyadditions.api.laser.Network;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergy.Mode;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
@ -37,9 +38,6 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase.NBTType;
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
public class TileEntityLaserRelayFluids extends TileEntityLaserRelay {
public final ConcurrentHashMap<Direction, TileEntity> handlersAround = new ConcurrentHashMap<>();
@ -47,7 +45,7 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay {
private Mode mode = Mode.BOTH;
public TileEntityLaserRelayFluids() {
super(ActuallyTiles.LASERRELAYFLUIDS_TILE.get(), LaserType.FLUID);
super(ActuallyBlocks.LASER_RELAY_FLUIDS.getTileEntityType(), LaserType.FLUID);
for (int i = 0; i < this.fluidHandlers.length; i++) {
Direction facing = Direction.values()[i];

View file

@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.api.laser.IConnectionPair;
import de.ellpeck.actuallyadditions.api.laser.LaserType;
import de.ellpeck.actuallyadditions.api.laser.Network;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemInterface.GenericItemHandlerInfo;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
@ -35,8 +36,6 @@ import net.minecraftforge.items.IItemHandler;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase.NBTType;
public class TileEntityLaserRelayItem extends TileEntityLaserRelay {
public final Map<BlockPos, SlotlessableItemHandlerWrapper> handlersAround = new ConcurrentHashMap<>();
@ -47,7 +46,7 @@ public class TileEntityLaserRelayItem extends TileEntityLaserRelay {
}
public TileEntityLaserRelayItem() {
this(ActuallyTiles.LASERRELAYITEM_TILE.get());
this(ActuallyBlocks.LASER_RELAY_ITEM.getTileEntityType());
}
public int getPriority() {
@ -74,7 +73,7 @@ public class TileEntityLaserRelayItem extends TileEntityLaserRelay {
BlockPos pos = this.getBlockPos().relative(side);
if (this.level.hasChunkAt(pos)) {
TileEntity tile = this.level.getBlockEntity(pos);
if (tile != null && !(tile instanceof TileEntityItemViewer) && !(tile instanceof TileEntityLaserRelay)) {
if (tile != null && !(tile instanceof TileEntityItemInterface) && !(tile instanceof TileEntityLaserRelay)) {
LazyOptional<IItemHandler> itemHandler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side.getOpposite());
Object slotlessHandler = null;

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerFilter;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerLaserRelayItemWhitelist;
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotFilter;
@ -35,7 +36,7 @@ public class TileEntityLaserRelayItemAdvanced extends TileEntityLaserRelayItem i
public FilterSettings rightFilter = new FilterSettings(12, true, true, false, false, 0, -2000);
public TileEntityLaserRelayItemAdvanced() {
super(ActuallyTiles.LASERRELAYITEMWHITELIST_TILE.get());
super(ActuallyBlocks.LASER_RELAY_ITEM_ADVANCED.getTileEntityType());
}
@Override
@ -131,7 +132,7 @@ public class TileEntityLaserRelayItemAdvanced extends TileEntityLaserRelayItem i
public void updateEntity() {
super.updateEntity();
if (!this.world.isRemote) {
if (!this.level.isClientSide) {
if ((this.leftFilter.needsUpdateSend() || this.rightFilter.needsUpdateSend()) && this.sendUpdateWithInterval()) {
this.leftFilter.updateLasts();
this.rightFilter.updateLasts();

View file

@ -21,8 +21,6 @@ import net.minecraft.util.math.BlockPos;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.energy.IEnergyStorage;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase.NBTType;
public class TileEntityLavaFactoryController extends TileEntityBase implements IEnergyDisplay {
public static final int NOT_MULTI = 0;
@ -36,7 +34,7 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I
private int oldEnergy;
public TileEntityLavaFactoryController() {
super(ActuallyTiles.LAVAFACTORYCONTROLLER_TILE.get());
super(ActuallyBlocks.LAVA_FACTORY_CONTROLLER.getTileEntityType());
}
@Override
@ -82,7 +80,7 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I
BlockPos thisPos = this.worldPosition;
BlockPos[] positions = new BlockPos[]{thisPos.offset(1, 1, 0), thisPos.offset(-1, 1, 0), thisPos.offset(0, 1, 1), thisPos.offset(0, 1, -1)};
if (this.level != null && WorldUtil.hasBlocksInPlacesGiven(positions, ActuallyBlocks.LAVA_CASING.get(), this.level)) {
if (this.level != null && WorldUtil.hasBlocksInPlacesGiven(positions, ActuallyBlocks.LAVA_FACTORY_CASING.get(), this.level)) {
BlockPos pos = thisPos.above();
BlockState state = this.level.getBlockState(pos);
Block block = state.getBlock();

View file

@ -37,9 +37,6 @@ import net.minecraftforge.fluids.capability.templates.FluidTank;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase.NBTType;
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
public class TileEntityOilGenerator extends TileEntityBase implements ISharingEnergyProvider, ISharingFluidHandler, INamedContainerProvider {
int[] i = ConfigIntListValues.OIL_POWER.getValue();
@ -59,12 +56,12 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn
return FluidStack.EMPTY;
}
@Override
//@Override
public boolean canFillFluidType(FluidStack stack) {
Fluid fluid = stack == null
? null
: stack.getFluid();
return fluid != null && getRecipeForFluid(fluid.getName()) != null;
return fluid != null && getRecipeForFluid(fluid.getRegistryName().toString()) != null;
}
};
public final LazyOptional<IFluidHandler> lazyTank = LazyOptional.of(() -> this.tank);
@ -103,7 +100,7 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn
if (stack != null) {
Fluid fluid = stack.getFluid();
if (fluid != null) {
return getRecipeForFluid(fluid.getName());
return getRecipeForFluid(fluid.getRegistryName().toString());
}
}
return null;

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerFurnaceDouble;
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
@ -23,13 +24,12 @@ import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipe;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.Direction;
import net.minecraft.util.datafix.fixes.FurnaceRecipes;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.energy.IEnergyStorage;
@ -55,7 +55,7 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements
private boolean lastSmelted;
public TileEntityPoweredFurnace() {
super(ActuallyTiles.FURNACE_DOUBLE_TILE.get(), 4);
super(ActuallyBlocks.POWERED_FURNACE.getTileEntityType(), 4);
}
public static void autoSplit(ItemStackHandlerAA inv, int slot1, int slot2) {
@ -111,7 +111,7 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements
@Override
public void updateEntity() {
super.updateEntity();
if (!this.world.isRemote) {
if (!this.level.isClientSide) {
if (this.isAutoSplit) {
autoSplit(this.inv, SLOT_INPUT_1, SLOT_INPUT_2);
}
@ -149,8 +149,8 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements
this.secondSmeltTime = 0;
}
BlockState currState = this.world.getBlockState(this.pos);
boolean current = currState.get(BlockStateProperties.LIT);
BlockState currState = this.level.getBlockState(this.getBlockPos());
boolean current = currState.getValue(BlockStateProperties.LIT);
boolean changeTo = current;
if (this.lastSmelted != smelted) {
changeTo = smelted;
@ -163,7 +163,7 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements
}
if (changeTo != current) {
this.world.setBlockState(this.pos, currState.with(BlockStateProperties.LIT, changeTo));
this.level.setBlock(this.worldPosition, currState.setValue(BlockStateProperties.LIT, changeTo), Constants.BlockFlags.DEFAULT);
}
this.lastSmelted = smelted;
@ -179,7 +179,7 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements
@Override
public IAcceptor getAcceptor() {
return (slot, stack, automation) -> !automation || (slot == SLOT_INPUT_1 || slot == SLOT_INPUT_2) && StackUtil.isValid(FurnaceRecipes.instance().getSmeltingResult(stack));
return (slot, stack, automation) -> !automation || (slot == SLOT_INPUT_1 || slot == SLOT_INPUT_2); //&& StackUtil.isValid(FurnaceRecipes.instance().getSmeltingResult(stack)); //TODO
}
@Override
@ -189,9 +189,9 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements
public boolean canSmeltOn(int theInput, int theOutput) {
if (StackUtil.isValid(this.inv.getStackInSlot(theInput))) {
ItemStack output = FurnaceRecipes.instance().getSmeltingResult(this.inv.getStackInSlot(theInput));
ItemStack output = ItemStack.EMPTY; //FurnaceRecipes.instance().getSmeltingResult(this.inv.getStackInSlot(theInput)); //TODO
if (StackUtil.isValid(output)) {
if (!StackUtil.isValid(this.inv.getStackInSlot(theOutput)) || this.inv.getStackInSlot(theOutput).isItemEqual(output) && this.inv.getStackInSlot(theOutput).getCount() <= this.inv.getStackInSlot(theOutput).getMaxStackSize() - output.getCount()) {
if (!StackUtil.isValid(this.inv.getStackInSlot(theOutput)) || this.inv.getStackInSlot(theOutput).sameItem(output) && this.inv.getStackInSlot(theOutput).getCount() <= this.inv.getStackInSlot(theOutput).getMaxStackSize() - output.getCount()) {
return true;
}
}
@ -201,7 +201,7 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements
}
public void finishBurning(int theInput, int theOutput) {
ItemStack output = FurnaceRecipe.instance().getSmeltingResult(this.inv.getStackInSlot(theInput));
ItemStack output = ItemStack.EMPTY; //FurnaceRecipe.instance().getSmeltingResult(this.inv.getStackInSlot(theInput)); //TODO
if (!StackUtil.isValid(this.inv.getStackInSlot(theOutput))) {
this.inv.setStackInSlot(theOutput, output.copy());
} else if (this.inv.getStackInSlot(theOutput).getItem() == output.getItem()) {
@ -223,7 +223,7 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements
public void onButtonPressed(int buttonID, PlayerEntity player) {
if (buttonID == 0) {
this.isAutoSplit = !this.isAutoSplit;
this.markDirty();
this.setChanged();
}
}

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerRangedCollector;
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
@ -31,15 +32,13 @@ import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase.NBTType;
public class TileEntityRangedCollector extends TileEntityInventoryBase implements IButtonReactor, INamedContainerProvider {
public static final int RANGE = 6;
public FilterSettings filter = new FilterSettings(12, true, true, false, false, 0, -1000);
public TileEntityRangedCollector() {
super(ActuallyTiles.RANGEDCOLLECTOR_TILE.get(), 6);
super(ActuallyBlocks.RANGED_COLLECTOR.getTileEntityType(), 6);
}
@Override

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.Direction;
import net.minecraftforge.common.util.LazyOptional;
@ -18,8 +19,6 @@ import net.minecraftforge.energy.IEnergyStorage;
import java.util.ArrayList;
import java.util.List;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase.NBTType;
public class TileEntityShockSuppressor extends TileEntityBase implements IEnergyDisplay {
public static final List<TileEntityShockSuppressor> SUPPRESSORS = new ArrayList<>();
@ -32,7 +31,7 @@ public class TileEntityShockSuppressor extends TileEntityBase implements IEnergy
private int oldEnergy;
public TileEntityShockSuppressor() {
super(ActuallyTiles.SHOCKSUPPRESSOR_TILE.get());
super(ActuallyBlocks.SHOCK_SUPPRESSOR.getTileEntityType());
}
@Override

View file

@ -28,7 +28,9 @@ import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.particles.IParticleData;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@ -165,60 +167,60 @@ public final class AssetUtil {
GlStateManager.enableTexture2D();
}
@OnlyIn(Dist.CLIENT)
public static void renderNameTag(String tag, double x, double y, double z) {
FontRenderer fontrenderer = Minecraft.getInstance().font;
float f = 1.6F;
float f1 = 0.016666668F * f;
GlStateManager._pushMatrix();
GlStateManager.translate(x, y, z);
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
GlStateManager.rotate(-Minecraft.getInstance().getEntityRenderDispatcher().playerViewY, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(Minecraft.getInstance().getEntityRenderDispatcher().playerViewX, 1.0F, 0.0F, 0.0F);
GlStateManager.scale(-f1, -f1, f1);
GlStateManager._disableLighting();
GlStateManager._depthMask(false);
GlStateManager.disableDepth();
GlStateManager._enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder renderer = tessellator.getBuilder();
int i = 0;
int j = fontrenderer.width(tag) / 2;
GlStateManager.disableTexture2D();
renderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
renderer.vertex(-j - 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
renderer.vertex(-j - 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
renderer.vertex(j + 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
renderer.vertex(j + 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
tessellator.end();
GlStateManager.enableTexture2D();
fontrenderer.draw(tag, -fontrenderer.width(tag) / 2, i, 553648127);
GlStateManager.enableDepth();
GlStateManager._depthMask(true);
fontrenderer.draw(tag, -fontrenderer.width(tag) / 2, i, -1);
GlStateManager._enableLighting();
GlStateManager._disableBlend();
GlStateManager.color3arg(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager._popMatrix();
}
// @OnlyIn(Dist.CLIENT)
// public static void renderNameTag(String tag, double x, double y, double z) {
// FontRenderer fontrenderer = Minecraft.getInstance().font;
// float f = 1.6F;
// float f1 = 0.016666668F * f;
// GlStateManager._pushMatrix();
// GlStateManager.translate(x, y, z);
// GL11.glNormal3f(0.0F, 1.0F, 0.0F);
// GlStateManager.rotate(-Minecraft.getInstance().getEntityRenderDispatcher().playerViewY, 0.0F, 1.0F, 0.0F);
// GlStateManager.rotate(Minecraft.getInstance().getEntityRenderDispatcher().playerViewX, 1.0F, 0.0F, 0.0F);
// GlStateManager.scale(-f1, -f1, f1);
// GlStateManager._disableLighting();
// GlStateManager._depthMask(false);
// GlStateManager.disableDepth();
// GlStateManager._enableBlend();
// GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
// Tessellator tessellator = Tessellator.getInstance();
// BufferBuilder renderer = tessellator.getBuilder();
// int i = 0;
// int j = fontrenderer.width(tag) / 2;
// GlStateManager.disableTexture2D();
// renderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
// renderer.vertex(-j - 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
// renderer.vertex(-j - 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
// renderer.vertex(j + 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
// renderer.vertex(j + 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
// tessellator.end();
// GlStateManager.enableTexture2D();
// fontrenderer.draw(tag, -fontrenderer.width(tag) / 2, i, 553648127);
// GlStateManager.enableDepth();
// GlStateManager._depthMask(true);
// fontrenderer.draw(tag, -fontrenderer.width(tag) / 2, i, -1);
// GlStateManager._enableLighting();
// GlStateManager._disableBlend();
// GlStateManager.color3arg(1.0F, 1.0F, 1.0F, 1.0F);
// GlStateManager._popMatrix();
// }
public static void spawnLaserWithTimeServer(World world, double startX, double startY, double startZ, double endX, double endY, double endZ, float[] color, int maxAge, double rotationTime, float size, float alpha) {
if (!world.isClientSide) {
CompoundNBT data = new CompoundNBT();
data.setDouble("StartX", startX);
data.setDouble("StartY", startY);
data.setDouble("StartZ", startZ);
data.setDouble("EndX", endX);
data.setDouble("EndY", endY);
data.setDouble("EndZ", endZ);
data.setFloat("Color1", color[0]);
data.setFloat("Color2", color[1]);
data.setFloat("Color3", color[2]);
data.setDouble("RotationTime", rotationTime);
data.setFloat("Size", size);
data.setInteger("MaxAge", maxAge);
data.setFloat("Alpha", alpha);
data.putDouble("StartX", startX);
data.putDouble("StartY", startY);
data.putDouble("StartZ", startZ);
data.putDouble("EndX", endX);
data.putDouble("EndY", endY);
data.putDouble("EndZ", endZ);
data.putFloat("Color1", color[0]);
data.putFloat("Color2", color[1]);
data.putFloat("Color3", color[2]);
data.putDouble("RotationTime", rotationTime);
data.putFloat("Size", size);
data.putInt("MaxAge", maxAge);
data.putFloat("Alpha", alpha);
PacketHandler.THE_NETWORK.sendToAllAround(new PacketServerToClient(data, PacketHandler.LASER_HANDLER), new NetworkRegistry.TargetPoint(world.provider.getDimension(), startX, startY, startZ, 96));
}
}
@ -227,9 +229,9 @@ public final class AssetUtil {
public static void spawnLaserWithTimeClient(double startX, double startY, double startZ, double endX, double endY, double endZ, float[] color, int maxAge, double rotationTime, float size, float alpha) {
Minecraft mc = Minecraft.getInstance();
if (mc.player.distanceTo(startX, startY, startZ) <= 64 || mc.player.distanceTo(endX, endY, endZ) <= 64) {
if (mc.player.distanceToSqr(startX, startY, startZ) <= 64 || mc.player.distanceToSqr(endX, endY, endZ) <= 64) {
Particle fx = new ParticleBeam(mc.level, startX, startY, startZ, endX, endY, endZ, color, maxAge, rotationTime, size, alpha);
mc.effectRenderer.addEffect(fx);
mc.level.addParticle((IParticleData) fx, startX, startY, startZ, 0, 0, 0);
}
}
@ -245,12 +247,12 @@ public final class AssetUtil {
float g = color[1];
float b = color[2];
Vec3d vec1 = new Vec3d(firstX, firstY, firstZ);
Vec3d vec2 = new Vec3d(secondX, secondY, secondZ);
Vec3d combinedVec = vec2.subtract(vec1);
Vector3d vec1 = new Vector3d(firstX, firstY, firstZ);
Vector3d vec2 = new Vector3d(secondX, secondY, secondZ);
Vector3d combinedVec = vec2.subtract(vec1);
double rot = rotationTime > 0
? 360D * (world.getTotalWorldTime() % rotationTime / rotationTime)
? 360D * (world.getGameTime() % rotationTime / rotationTime)
: 0;
double pitch = Math.atan2(combinedVec.y, Math.sqrt(combinedVec.x * combinedVec.x + combinedVec.z * combinedVec.z));
double yaw = Math.atan2(-combinedVec.z, combinedVec.x);
@ -261,7 +263,7 @@ public final class AssetUtil {
GlStateManager._disableLighting();
GlStateManager._enableBlend();
GlStateManager._blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE);
GlStateManager._blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE);
int func = GL11.glGetInteger(GL11.GL_ALPHA_TEST_FUNC);
float ref = GL11.glGetFloat(GL11.GL_ALPHA_TEST_REF);
GlStateManager._alphaFunc(GL11.GL_ALWAYS, 0);

View file

@ -10,17 +10,13 @@
package de.ellpeck.actuallyadditions.mod.util;
import com.mojang.blaze3d.platform.GlStateManager;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.LanguageMap;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.util.List;
import net.minecraftforge.fml.ForgeI18n;
public final class StringUtil {
@ -28,6 +24,8 @@ public final class StringUtil {
public static final int DECIMAL_COLOR_GRAY_TEXT = 4210752;
public static final String BUGGED_ITEM_NAME = ActuallyAdditions.MODID + ".lolWutHowUDoDis";
//TODO: Remove
static LanguageMap cancerino;
/**
* Localizes a given String
@ -48,58 +46,59 @@ public final class StringUtil {
@SuppressWarnings("deprecation")
//TODO: delete this shit and move ItemPotionRing's getItemStackDisplayName into getUnlocalizedName
public static String localizeIllegallyOnTheServerDontUseMePls(String langKey) {
return net.minecraft.util.text.translation.I18n.translateToLocal(langKey);
return I18n.get(langKey);
}
// TODO: Move to official
@OnlyIn(Dist.CLIENT)
public static void drawSplitString(FontRenderer renderer, String strg, int x, int y, int width, int color, boolean shadow) {
List<String> list = renderer.listFormattedStringToWidth(strg, width);
for (int i = 0; i < list.size(); i++) {
String s1 = list.get(i);
renderer.draw(s1, x, y + i * renderer.lineHeight, color, shadow);
}
// ResourcePackList <- holds the correct way
// List<String> list = renderer.listFormattedStringToWidth(strg, width);
// for (int i = 0; i < list.size(); i++) {
// String s1 = list.get(i);
// renderer.draw(s1, x, y + i * renderer.lineHeight, color, shadow);
// }
}
// @OnlyIn(Dist.CLIENT)
// public static void renderSplitScaledAsciiString(FontRenderer font, String text, int x, int y, int color, boolean shadow, float scale, int length) {
// List<String> lines = font.listFormattedStringToWidth(text, (int) (length / scale));
// for (int i = 0; i < lines.size(); i++) {
// renderScaledAsciiString(font, lines.get(i), x, y + i * (int) (font.lineHeight * scale + 3), color, shadow, scale);
// }
// }
@OnlyIn(Dist.CLIENT)
public static void renderScaledAsciiString(FontRenderer font, String text, float x, float y, int color, boolean shadow, float scale) {
GlStateManager._pushMatrix();
GlStateManager.scale(scale, scale, scale);
boolean oldUnicode = font.getUnicodeFlag();
font.setUnicodeFlag(false);
font.draw(text, x / scale, y / scale, color, shadow);
font.setUnicodeFlag(oldUnicode);
GlStateManager._popMatrix();
// GlStateManager._pushMatrix();
// GlStateManager.scale(scale, scale, scale);
// boolean oldUnicode = font.getUnicodeFlag();
// font.setUnicodeFlag(false);
//
// font.draw(text, x / scale, y / scale, color, shadow);
//
// font.setUnicodeFlag(oldUnicode);
// GlStateManager._popMatrix();
}
@OnlyIn(Dist.CLIENT)
public static void renderSplitScaledAsciiString(FontRenderer font, String text, int x, int y, int color, boolean shadow, float scale, int length) {
List<String> lines = font.listFormattedStringToWidth(text, (int) (length / scale));
for (int i = 0; i < lines.size(); i++) {
renderScaledAsciiString(font, lines.get(i), x, y + i * (int) (font.lineHeight * scale + 3), color, shadow, scale);
}
}
//TODO: Remove
static LanguageMap cancerino;
static void setupLangMap() {
try {
Method m = LanguageMap.class.getDeclaredMethod("inject", LanguageMap.class, InputStream.class);
m.setAccessible(true);
m.invoke(null, cancerino = new LanguageMap(), ActuallyAdditions.class.getResourceAsStream("/assets/actuallyadditions/lang/en_US.lang"));
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Actually Additions failed to access LanguageMap.inject. Report this!");
}
}
// static void setupLangMap() {
// try {
// Method m = LanguageMap.class.getDeclaredMethod("inject", LanguageMap.class, InputStream.class);
// m.setAccessible(true);
// m.invoke(null, cancerino = new LanguageMap(), ActuallyAdditions.class.getResourceAsStream("/assets/actuallyadditions/lang/en_US.lang"));
// } catch (Exception e) {
// e.printStackTrace();
// throw new RuntimeException("Actually Additions failed to access LanguageMap.inject. Report this!");
// }
// }
// TODO: This might be wrong
public static String badTranslate(String someUnlocAAItemName) {
if (cancerino == null) {
cancerino = new LanguageMap();
setupLangMap();
}
return cancerino.translateKey("item.actuallyadditions." + someUnlocAAItemName + ".name");
// if (cancerino == null) {
// cancerino = new LanguageMap();
// setupLangMap();
// }
// return cancerino.translateKey("item.actuallyadditions." + someUnlocAAItemName + ".name");
return ForgeI18n.parseFormat("item.actuallyadditions." + someUnlocAAItemName + ".name");
}
}

View file

@ -1,9 +1,9 @@
package de.ellpeck.actuallyadditions.mod.util;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.server.ServerWorld;
public final class VanillaPacketDispatcher {
@ -11,16 +11,11 @@ public final class VanillaPacketDispatcher {
//Don't call from the client.
public static void dispatchTEToNearbyPlayers(TileEntity tile) {
ServerWorld world = (ServerWorld) tile.getLevel();
PlayerChunkMapEntry entry = world.getPlayerChunkMap().getEntry(tile.getBlockPos().getX() >> 4, tile.getBlockPos().getZ() >> 4);
if (entry == null) {
return;
}
for (ServerPlayerEntity player : entry.getWatchingPlayers()) {
player.connection.send(tile.getUpdatePacket());
}
Chunk chunk = world.getChunk(tile.getBlockPos().getX() >> 4, tile.getBlockPos().getZ() >> 4);
world.getChunkSource().chunkMap.getPlayers(chunk.getPos(), false).forEach(e -> {
e.connection.send(tile.getUpdatePacket());
});
}
public static void dispatchTEToNearbyPlayers(World world, BlockPos pos) {

View file

@ -28,6 +28,7 @@ import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.ForgeHooks;
@ -116,8 +117,8 @@ public final class WorldUtil {
public static void doEnergyInteraction(TileEntity tileFrom, TileEntity tileTo, Direction sideTo, int maxTransfer) {
if (maxTransfer > 0) {
Direction opp = sideTo == null
? null
: sideTo.getOpposite();
? null
: sideTo.getOpposite();
IEnergyStorage handlerFrom = tileFrom.getCapability(CapabilityEnergy.ENERGY, sideTo);
IEnergyStorage handlerTo = tileTo.getCapability(CapabilityEnergy.ENERGY, opp);
if (handlerFrom != null && handlerTo != null) {
@ -151,7 +152,6 @@ public final class WorldUtil {
* @param positions The Positions, an array of {x, y, z} arrays containing Positions
* @param block The Block
* @param world The World
*
* @return Is every block present?
*/
public static boolean hasBlocksInPlacesGiven(BlockPos[] positions, Block block, World world) {
@ -258,14 +258,14 @@ public final class WorldUtil {
double d0 = player.posX;
double d1 = player.posY + player.getEyeHeight();
double d2 = player.posZ;
Vec3d vec3 = new Vec3d(d0, d1, d2);
Vector3d vec3 = new Vector3d(d0, d1, d2);
float f2 = MathHelper.cos(-f1 * 0.017453292F - (float) Math.PI);
float f3 = MathHelper.sin(-f1 * 0.017453292F - (float) Math.PI);
float f4 = -MathHelper.cos(-f * 0.017453292F);
float f5 = MathHelper.sin(-f * 0.017453292F);
float f6 = f3 * f4;
float f7 = f2 * f4;
Vec3d vec31 = vec3.add(f6 * distance, f5 * distance, f7 * distance);
Vector3d vec31 = vec3.add(f6 * distance, f5 * distance, f7 * distance);
return world.clipWithInteractionOverride(vec3, vec31, p1, p2, p3);
}
@ -308,7 +308,6 @@ public final class WorldUtil {
* @param world The player's world.
* @param player The player that is breaking this block.
* @param pos The pos to break.
*
* @return If the break was successful.
*/
public static boolean breakExtraBlock(ItemStack stack, World world, PlayerEntity player, BlockPos pos) {