Fix Shulker Boxes losing their items when they are upgraded by crafting the next tier up and fix copper shulker boxes using a chest as the item needed to craft them. Closes #93, Closes #97

This commit is contained in:
alexbegt 2017-06-16 20:32:31 -04:00
parent f2c6dc965a
commit d4acdafa60
5 changed files with 102 additions and 26 deletions

View File

@ -19,7 +19,7 @@ import cpw.mods.ironchest.common.blocks.chest.BlockIronChest;
import cpw.mods.ironchest.common.blocks.chest.IronChestType;
import cpw.mods.ironchest.common.blocks.shulker.BlockIronShulkerBox;
import cpw.mods.ironchest.common.blocks.shulker.IronShulkerBoxType;
import cpw.mods.ironchest.common.crafting.IronShulkerBoxColoring;
import cpw.mods.ironchest.common.crafting.IronShulkerBoxColoringRecipe;
import cpw.mods.ironchest.common.items.ChestChangerType;
import cpw.mods.ironchest.common.items.ShulkerBoxChangerType;
import cpw.mods.ironchest.common.items.chest.ItemIronChest;
@ -132,8 +132,8 @@ public class ICContent
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(block, new BehaviorDispenseIronShulkerBox());
}
GameRegistry.addRecipe(new IronShulkerBoxColoring());
RecipeSorter.register(IronChest.MOD_ID, IronShulkerBoxColoring.class, Category.SHAPELESS, "after:forge:shapelessore");
GameRegistry.addRecipe(new IronShulkerBoxColoringRecipe());
RecipeSorter.register(IronChest.MOD_ID, IronShulkerBoxColoringRecipe.class, Category.SHAPELESS, "after:forge:shapelessore");
ShulkerBoxChangerType.generateRecipes();
// Shulkers End

View File

@ -373,9 +373,37 @@ public class BlockIronShulkerBox extends Block
if (j - i > 0)
{
//@formatter:off
tooltip.add(String.format(TextFormatting.ITALIC + I18n.translateToLocal("container.shulkerBox.more"), new Object[] {Integer.valueOf(j - i)}));
//@formatter:on
//@formatter:off
tooltip.add(String.format(TextFormatting.ITALIC + I18n.translateToLocal("container.shulkerBox.more"), new Object[] { Integer.valueOf(j - i) }));
//@formatter:on
}
}
else
{
NonNullList<ItemStack> nonnulllist = NonNullList.<ItemStack> withSize(27, ItemStack.EMPTY);
ItemStackHelper.loadAllItems(nbttagcompound1, nonnulllist);
int i = 0;
int j = 0;
for (ItemStack itemstack : nonnulllist)
{
if (!itemstack.isEmpty())
{
++j;
if (i <= 4)
{
++i;
tooltip.add(String.format("%s x%d", new Object[] { itemstack.getDisplayName(), Integer.valueOf(itemstack.getCount()) }));
}
}
}
if (j - i > 0)
{
//@formatter:off
tooltip.add(String.format(TextFormatting.ITALIC + I18n.translateToLocal("container.shulkerBox.more"), new Object[] { Integer.valueOf(j - i) }));
//@formatter:on
}
}
}

View File

@ -14,6 +14,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import cpw.mods.ironchest.common.crafting.IronShulkerBoxRecipe;
import cpw.mods.ironchest.common.gui.shulker.slot.ValidatingShulkerBoxSlot;
import cpw.mods.ironchest.common.tileentity.shulker.TileEntityCopperShulkerBox;
import cpw.mods.ironchest.common.tileentity.shulker.TileEntityCrystalShulkerBox;
@ -30,7 +31,6 @@ import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IStringSerializable;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.ShapedOreRecipe;
public enum IronShulkerBoxType implements IStringSerializable
{
@ -38,7 +38,7 @@ public enum IronShulkerBoxType implements IStringSerializable
IRON(54, 9, true, "_iron.png", TileEntityIronShulkerBox.class, 184, 202, Arrays.asList("ingotIron", "ingotRefinedIron"), "mmmmPmmmm", "mGmG3GmGm"),
GOLD(81, 9, true, "_gold.png", TileEntityGoldShulkerBox.class, 184, 256, Collections.singleton("ingotGold"), "mmmmPmmmm", "mGmG4GmGm"),
DIAMOND(108, 12, true, "_diamond.png", TileEntityDiamondShulkerBox.class, 184, 256, Collections.singleton("gemDiamond"), "GGGmPmGGG", "GGGG4Gmmm"),
COPPER(45, 9, false, "_copper.png", TileEntityCopperShulkerBox.class, 184, 184, Collections.singleton("ingotCopper"), "mmmmCmmmm"),
COPPER(45, 9, false, "_copper.png", TileEntityCopperShulkerBox.class, 184, 184, Collections.singleton("ingotCopper"), "mmmmSmmmm"),
SILVER(72, 9, false, "_silver.png", TileEntitySilverShulkerBox.class, 184, 238, Collections.singleton("ingotSilver"), "mmmm3mmmm", "mGmG0GmGm"),
CRYSTAL(108, 12, true, "_crystal.png", TileEntityCrystalShulkerBox.class, 238, 256, Collections.singleton("blockGlass"), "GGGGPGGGG"),
OBSIDIAN(108, 12, false, "_obsidian.png", TileEntityObsidianShulkerBox.class, 238, 256, Collections.singleton("obsidian"), "mmmm2mmmm"),
@ -53,7 +53,7 @@ public enum IronShulkerBoxType implements IStringSerializable
public final int rowLength;
public final boolean tieredChest;
public final boolean tieredShulkerBox;
public final String modelTexture;
@ -70,13 +70,13 @@ public enum IronShulkerBoxType implements IStringSerializable
private String breakTexture;
//@formatter:off
IronShulkerBoxType(int size, int rowLength, boolean tieredChest, String modelTexture, Class<? extends TileEntityIronShulkerBox> clazz, int xSize, int ySize, Collection<String> mats, String... recipes)
IronShulkerBoxType(int size, int rowLength, boolean tieredShulkerBox, String modelTexture, Class<? extends TileEntityIronShulkerBox> clazz, int xSize, int ySize, Collection<String> mats, String... recipes)
//@formatter:on
{
this.name = this.name().toLowerCase();
this.size = size;
this.rowLength = rowLength;
this.tieredChest = tieredChest;
this.tieredShulkerBox = tieredShulkerBox;
this.modelTexture = modelTexture;
this.clazz = clazz;
this.xSize = xSize;
@ -123,18 +123,18 @@ public enum IronShulkerBoxType implements IStringSerializable
for (IronShulkerBoxType typ : values())
{
generateRecipesForType(blockResult, previous, typ);
generateRecipesForType(blockResult, previous, typ, shulkerBox);
ItemStack chest = new ItemStack(blockResult, 1, typ.ordinal());
ItemStack newShulkerBox = new ItemStack(blockResult, 1, typ.ordinal());
if (typ.tieredChest)
if (typ.tieredShulkerBox)
{
previous = chest;
previous = newShulkerBox;
}
}
}
public static void generateRecipesForType(BlockIronShulkerBox blockResult, Object previousTier, IronShulkerBoxType type)
public static void generateRecipesForType(BlockIronShulkerBox blockResult, Object previousTier, IronShulkerBoxType type, BlockShulkerBox shulkerBox)
{
for (String recipe : type.recipes)
{
@ -147,14 +147,14 @@ public enum IronShulkerBoxType implements IStringSerializable
//@formatter:off
addRecipe(new ItemStack(blockResult, 1, type.ordinal()), recipeSplit,
'm', mainMaterial,
'P', previousTier, /* previous tier of chest */
'P', previousTier, /* previous tier of shulker box */
'G', "blockGlass",
'C', "chestWood",
'0', new ItemStack(blockResult, 1, 0), /* Iron Chest */
'1', new ItemStack(blockResult, 1, 1), /* Gold Chest */
'2', new ItemStack(blockResult, 1, 2), /* Diamond Chest */
'3', new ItemStack(blockResult, 1, 3), /* Copper Chest */
'4', new ItemStack(blockResult, 1, 4) /* Silver Chest */
'S', shulkerBox,
'0', new ItemStack(blockResult, 1, 0), /* Iron Shulker Box */
'1', new ItemStack(blockResult, 1, 1), /* Gold Shulker Box */
'2', new ItemStack(blockResult, 1, 2), /* Diamond Shulker Box */
'3', new ItemStack(blockResult, 1, 3), /* Copper Shulker Box */
'4', new ItemStack(blockResult, 1, 4) /* Silver Shulker Box */
);
//@formatter:on
}
@ -178,7 +178,7 @@ public enum IronShulkerBoxType implements IStringSerializable
public static void addRecipe(ItemStack is, Object... parts)
{
ShapedOreRecipe oreRecipe = new ShapedOreRecipe(is, parts);
IronShulkerBoxRecipe oreRecipe = new IronShulkerBoxRecipe(is, parts);
GameRegistry.addRecipe(oreRecipe);
}

View File

@ -20,9 +20,9 @@ import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
public class IronShulkerBoxColoring implements IRecipe
public class IronShulkerBoxColoringRecipe implements IRecipe
{
public IronShulkerBoxColoring()
public IronShulkerBoxColoringRecipe()
{
}

View File

@ -0,0 +1,48 @@
package cpw.mods.ironchest.common.crafting;
import javax.annotation.Nonnull;
import cpw.mods.ironchest.common.blocks.shulker.BlockIronShulkerBox;
import net.minecraft.block.Block;
import net.minecraft.block.BlockShulkerBox;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.ShapedOreRecipe;
public class IronShulkerBoxRecipe extends ShapedOreRecipe
{
public IronShulkerBoxRecipe(@Nonnull ItemStack result, Object... recipe)
{
super(result, recipe);
}
@Override
@Nonnull
public ItemStack getCraftingResult(@Nonnull InventoryCrafting var1)
{
ItemStack newOutput = this.output.copy();
ItemStack itemstack = ItemStack.EMPTY;
for (int i = 0; i < var1.getSizeInventory(); ++i)
{
ItemStack stack = var1.getStackInSlot(i);
if (!stack.isEmpty())
{
if (Block.getBlockFromItem(stack.getItem()) instanceof BlockIronShulkerBox
|| Block.getBlockFromItem(stack.getItem()) instanceof BlockShulkerBox)
{
itemstack = stack;
}
}
}
if (itemstack.hasTagCompound())
{
newOutput.setTagCompound(itemstack.getTagCompound().copy());
}
return newOutput;
}
}