Made Drill coloring not lose all of the NBT.

Closes #153
This commit is contained in:
Ellpeck 2016-07-17 13:27:20 +02:00
parent 2f9b6aa8f7
commit edf870403f
5 changed files with 131 additions and 13 deletions

View file

@ -150,7 +150,7 @@ public final class InitBooklet{
new BookletChapter("itemFilter", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitItems.itemFilter), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeFilter).setNoText()).setImportant();
//RF Using Items
new BookletChapter("drill", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(InitItems.itemDrill, 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("drill", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(InitItems.itemDrill, 1, TheColoredLampColors.LIGHT_BLUE.ordinal()), new PageTextOnly(1), new PageTextOnly(2), new PageCrafting(3, ItemCrafting.recipeDrill).setNoText(), 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("staff", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(InitItems.itemTeleStaff), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeStaff).setNoText()).setImportant();
new BookletChapter("magnetRing", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(InitItems.itemMagnetRing), new PageCrafting(1, ItemCrafting.recipeMagnetRing));
new BookletChapter("growthRing", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(InitItems.itemGrowthRing), new PageCrafting(1, ItemCrafting.recipeGrowthRing));

View file

@ -11,11 +11,15 @@
package de.ellpeck.actuallyadditions.mod.crafting;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors;
import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.RecipeUtil;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.RecipeSorter;
public final class InitCrafting{
@ -30,6 +34,9 @@ public final class InitCrafting{
ActuallyAdditionsAPI.addCompostRecipe(new ItemStack(InitItems.itemMisc, 10, TheMiscItems.MASHED_FOOD.ordinal()), Blocks.LEAVES, new ItemStack(InitItems.itemFertilizer, 10), Blocks.DIRT);
ActuallyAdditionsAPI.addCompostRecipe(new ItemStack(InitItems.itemCanolaSeed, 20), Blocks.DIRT, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.BIOMASS.ordinal()), Blocks.SOUL_SAND);
RecipeSorter.register(ModUtil.MOD_ID+":drillColoring", RecipeDrillColor.class, RecipeSorter.Category.SHAPELESS, "");
GameRegistry.addRecipe(new RecipeDrillColor());
}
}

View file

@ -37,7 +37,6 @@ import java.util.ArrayList;
public final class ItemCrafting{
public static final ArrayList<IRecipe> RECIPES_MASHED_FOOD = new ArrayList<IRecipe>();
public static final ArrayList<IRecipe> RECIPES_DRILL_COLORING = new ArrayList<IRecipe>();
public static final ArrayList<IRecipe> RECIPES_POTION_RINGS = new ArrayList<IRecipe>();
public static IRecipe recipePhantomConnector;
public static IRecipe recipeCoil;
@ -181,21 +180,13 @@ public final class ItemCrafting{
//Drill
if(ConfigCrafting.DRILL.isEnabled()){
ItemStack lightBlueDrill = new ItemStack(InitItems.itemDrill, 1, TheColoredLampColors.LIGHT_BLUE.ordinal());
GameRegistry.addRecipe(new ShapedOreRecipe(lightBlueDrill.copy(),
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitItems.itemDrill, 1, TheColoredLampColors.LIGHT_BLUE.ordinal()),
"DDD", "CRC", "III",
'D', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()),
'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()),
'R', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.DRILL_CORE.ordinal()),
'I', new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.IRON.ordinal())));
recipeDrill = RecipeUtil.lastIRecipe();
for(int i = 0; i < 16; i++){
if(i != TheColoredLampColors.LIGHT_BLUE.ordinal()){
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(InitItems.itemDrill, 1, i), lightBlueDrill.copy(), "dye"+TheColoredLampColors.values()[i].name));
RECIPES_DRILL_COLORING.add(RecipeUtil.lastIRecipe());
}
}
}
//Drill Core

View file

@ -0,0 +1,121 @@
/*
* This file ("RecipeDrillColor.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-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.crafting;
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors;
import de.ellpeck.actuallyadditions.mod.items.ItemDrill;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.oredict.OreDictionary;
import javax.annotation.Nullable;
public class RecipeDrillColor implements IRecipe{
@Override
public boolean matches(InventoryCrafting inv, World worldIn){
boolean hasDrill = false;
boolean hasColor = false;
for(int i = 0; i < inv.getSizeInventory(); i++){
ItemStack stack = inv.getStackInSlot(i);
if(stack != null && stack.getItem() != null){
if(stack.getItem() instanceof ItemDrill){
if(!hasDrill){
hasDrill = true;
}
else{
return false;
}
}
else{
int[] ids = OreDictionary.getOreIDs(stack);
if(ids != null){
for(int id : ids){
String name = OreDictionary.getOreName(id);
if(name != null){
TheColoredLampColors color = TheColoredLampColors.getColorFromDyeName(name);
if(color != null){
if(!hasColor){
hasColor = true;
}
else{
return false;
}
}
}
}
}
}
}
}
return hasDrill && hasColor;
}
@Nullable
@Override
public ItemStack getCraftingResult(InventoryCrafting inv){
ItemStack drillStack = null;
ItemStack colorStack = null;
for(int i = 0; i < inv.getSizeInventory(); i++){
ItemStack stack = inv.getStackInSlot(i);
if(stack != null && stack.getItem() != null){
if(stack.getItem() instanceof ItemDrill){
drillStack = stack.copy();
}
else{
colorStack = stack.copy();
}
}
}
if(drillStack != null && colorStack != null){
int[] ids = OreDictionary.getOreIDs(colorStack);
if(ids != null){
for(int id : ids){
String name = OreDictionary.getOreName(id);
if(name != null){
TheColoredLampColors color = TheColoredLampColors.getColorFromDyeName(name);
if(color != null){
if(color.ordinal() != drillStack.getItemDamage()){
drillStack.setItemDamage(color.ordinal());
return drillStack;
}
}
}
}
}
}
return null;
}
@Override
public int getRecipeSize(){
return 2;
}
@Nullable
@Override
public ItemStack getRecipeOutput(){
return null;
}
@Override
public ItemStack[] getRemainingItems(InventoryCrafting inv){
return ForgeHooks.defaultRecipeGetRemainingItems(inv);
}
}

View file

@ -812,8 +812,7 @@ booklet.actuallyadditions.chapter.potionRings.text.1=The <item>Potion Rings<r> h
booklet.actuallyadditions.chapter.drill.name=Drills
booklet.actuallyadditions.chapter.drill.text.1=The <item>Drill<r> works like a Pickaxe and a Shovel. It uses <imp>RF<r> per block. It can be <imp>charged in an Energizer<r> and upgraded by <imp>right-clicking<r> with it in your hand. There is <imp>a lot of upgrades<r>, but here is an explanation of some of them: <n>The <item>Mining Uprgades<r> enlarge the hole which the Drill digs. <n>The <item>Placement Upgrade<r>, after you right-click it in any slot of your hotbar, will make the Drill able to <imp>place a block from that slot by right-clicking<r>. You can also put a <item>Battery<r> inside the Drill to give it more charge.
booklet.actuallyadditions.chapter.drill.text.2=It should be noted that, in fact, the <item>Speed<r>, <item>Mining<r> and <item>Fortune Upgrades<r> <imp>need their previous tiers to be installed<r> for them to work. <n>This means that, if you want Speed III in the Drill, it needs Speed II and Speed I inside it as well.
booklet.actuallyadditions.chapter.drill.text.4=The <item>Drill<r> can also be <imp>dyed<r> in Minecraft's 16 colors. <n>It's only cosmetic and won't have any effect other than it looking different, however.
booklet.actuallyadditions.chapter.drill.text.2=It should be noted that, in fact, the <item>Speed<r>, <item>Mining<r> and <item>Fortune Upgrades<r> <imp>need their previous tiers to be installed<r> for them to work. <n>This means that, if you want Speed III in the Drill, it needs Speed II and Speed I inside it as well. <n><n>Additionally, the <item>Drill<r> can also be <imp>dyed<r> in Minecraft's 16 colors by crafting it together with one. <n>It's only cosmetic and won't have any effect other than it looking different, however.
booklet.actuallyadditions.chapter.staff.name=Staff
booklet.actuallyadditions.chapter.staff.text.1=The <item>Teleport Staff<r>, when charged in an Energizer, can be <imp>right-clicked<r> to <imp>teleport you to where you're looking<r>. When you are looking at a block, it will teleport you there, however, when you aren't looking at a block, you can only be looking upwards up to <imp>5 degrees<r>, otherwise the teleport will fail.