Skip to content

Commit

Permalink
* fixed recipe crashing
Browse files Browse the repository at this point in the history
 * added forum stuff
  • Loading branch information
SanAndreaP committed Oct 26, 2014
1 parent d71dbc1 commit 5d5d2a6
Show file tree
Hide file tree
Showing 35 changed files with 44 additions and 59 deletions.
Binary file added forum_stuff/Downloads.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forum_stuff/Information.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forum_stuff/LicenseCreditsLinks.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forum_stuff/Media.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forum_stuff/PSDs/crafting.psd
Binary file not shown.
Binary file added forum_stuff/PSDs/points.psd
Binary file not shown.
Binary file added forum_stuff/PSDs/title.psd
Binary file not shown.
Binary file added forum_stuff/craftings/bunnies.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forum_stuff/craftings/disruptor.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forum_stuff/craftings/geckos.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forum_stuff/craftings/harddisruptor.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forum_stuff/craftings/horses.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forum_stuff/craftings/nexus.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forum_stuff/craftings/pegasi.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forum_stuff/craftings/sblades.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forum_stuff/craftings/shears.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forum_stuff/craftings/soldiers.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forum_stuff/craftings/soldiers_clr.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forum_stuff/craftings/soldiers_multi.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forum_stuff/craftings/statdisplay.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forum_stuff/craftings/turtles.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forum_stuff/sshots/2014-10-25_17.31.14.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forum_stuff/sshots/2014-10-26_11.59.41.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forum_stuff/sshots/2014-10-26_12.02.26.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forum_stuff/sshots/2014-10-26_12.06.55.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added forum_stuff/sshots/2014-10-26_12.15.16.png
Binary file added forum_stuff/sshots/2014-10-26_13.30.21.png
Binary file added forum_stuff/sshots/2014-10-26_13.31.42.png
Binary file added forum_stuff/title.png
75 changes: 27 additions & 48 deletions java/de/sanandrew/mods/claysoldiers/crafting/RecipeBunnies.java
Expand Up @@ -6,73 +6,36 @@
*******************************************************************************************************************/
package de.sanandrew.mods.claysoldiers.crafting;

import de.sanandrew.mods.claysoldiers.item.ItemBunnyDoll;
import de.sanandrew.core.manpack.util.SAPUtils;
import de.sanandrew.mods.claysoldiers.util.RegistryItems;
import de.sanandrew.mods.claysoldiers.util.mount.EnumBunnyType;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;

public class RecipeBunnies
implements IRecipe
{
private final Item p_soulSand = Item.getItemFromBlock(Blocks.soul_sand);
private final Item p_wool = Item.getItemFromBlock(Blocks.wool);
private final ItemStack p_soulSand = new ItemStack(Blocks.soul_sand);
private final ItemStack p_wool = new ItemStack(Blocks.wool, 1, OreDictionary.WILDCARD_VALUE);

@Override
public boolean matches(InventoryCrafting invCrafting, World world) {
if( invCrafting.getSizeInventory() < 9 ) {
return false;
}

boolean hasRightPattern = false;

for( int i = 0; i < 9; i += 3 ) {
ItemStack[] row = new ItemStack[] {invCrafting.getStackInSlot(i), invCrafting.getStackInSlot(i+1), invCrafting.getStackInSlot(i+2)};

if( row[0] == null && row[1] == null && row[2] == null) {
continue;
}

if( !hasRightPattern ) {
if( row[0].getItem() == this.p_wool && row[1].getItem() == this.p_soulSand && row[2].getItem() == this.p_wool
&& row[0].getItemDamage() == row[2].getItemDamage() )
{
hasRightPattern = true;
} else {
return false;
}
}
}
int slotR1 = getSngItemInCol(invCrafting, this.p_wool, 0);
int slotR2 = getSngItemInCol(invCrafting, this.p_soulSand, 1);
int slotR3 = getSngItemInCol(invCrafting, this.p_wool, 2);

return hasRightPattern;
return slotR1 >= 0 && slotR1 == slotR2 && slotR1 == slotR3
&& invCrafting.getStackInSlot(slotR1 * 3).getItemDamage() == invCrafting.getStackInSlot(slotR1 * 3 + 2).getItemDamage();
}

@Override
public ItemStack getCraftingResult(InventoryCrafting invCrafting) {
ItemStack wool = null;
for( int i = 0; i < 9; i += 3 ) {

This comment has been minimized.

Copy link
@ZakiGamerYT

ZakiGamerYT Jul 5, 2021

.

if( (wool = invCrafting.getStackInSlot(i)).getItem() != this.p_wool ) {
wool = null;
}
}

if( wool == null ) {
return null;
}

for( EnumBunnyType type : EnumBunnyType.VALUES ) {
if( type.woolMeta == wool.getItemDamage() ) {
ItemStack stack = new ItemStack(RegistryItems.dollBunnyMount, 2);
ItemBunnyDoll.setType(stack, type);
return stack;
}
}

return null;
ItemStack woolClr = invCrafting.getStackInSlot(getSngItemInCol(invCrafting, this.p_wool, 0) * 3);
return new ItemStack(RegistryItems.dollBunnyMount, 4, EnumBunnyType.getTypeFromItem(woolClr).woolMeta);
}

@Override
Expand All @@ -84,4 +47,20 @@ public int getRecipeSize() {
public ItemStack getRecipeOutput() {
return null;
}

private static int getSngItemInCol(InventoryCrafting invCrafting, ItemStack stack, int col) {
int slotFound = -1;
for(int i = 0; i < 3; i++) {
ItemStack item = invCrafting.getStackInSlot(col + i * 3);
if( item != null ) {
if( slotFound >= 0 ) {
return -1;
} else if( SAPUtils.areStacksEqualWithWCV(item, stack) ) {
slotFound = i;
}
}
}

return slotFound;
}
}
16 changes: 8 additions & 8 deletions java/de/sanandrew/mods/claysoldiers/crafting/RecipeGeckos.java
Expand Up @@ -19,24 +19,24 @@
public class RecipeGeckos
implements IRecipe
{
private final ItemStack sapling = new ItemStack(Blocks.sapling, 1, OreDictionary.WILDCARD_VALUE);
private final ItemStack soulSand = new ItemStack(Blocks.soul_sand);
private final ItemStack p_sapling = new ItemStack(Blocks.sapling, 1, OreDictionary.WILDCARD_VALUE);
private final ItemStack p_soulSand = new ItemStack(Blocks.soul_sand);

@Override
public boolean matches(InventoryCrafting invCrafting, World world) {
int slotR1 = getSngItemInRow(invCrafting, sapling, 0);
int slotR2 = getSngItemInRow(invCrafting, soulSand, 1);
int slotR3 = getSngItemInRow(invCrafting, sapling, 2);
int slotR1 = getSngItemInRow(invCrafting, this.p_sapling, 0);
int slotR2 = getSngItemInRow(invCrafting, this.p_soulSand, 1);
int slotR3 = getSngItemInRow(invCrafting, this.p_sapling, 2);

return slotR1 >= 0 && slotR1 == slotR2 && slotR1 == slotR3;
}

@Override
public ItemStack getCraftingResult(InventoryCrafting invCrafting) {
ItemStack sapOne = invCrafting.getStackInSlot(getSngItemInRow(invCrafting, sapling, 0));
ItemStack sapTwo = invCrafting.getStackInSlot(getSngItemInRow(invCrafting, sapling, 2) + 6);
ItemStack sapOne = invCrafting.getStackInSlot(getSngItemInRow(invCrafting, this.p_sapling, 0));
ItemStack sapTwo = invCrafting.getStackInSlot(getSngItemInRow(invCrafting, this.p_sapling, 2) + 6);

return new ItemStack(RegistryItems.dollGeckoMount, 1, EnumGeckoType.getTypeFromItem(sapOne, sapTwo).ordinal());
return new ItemStack(RegistryItems.dollGeckoMount, 2, EnumGeckoType.getTypeFromItem(sapOne, sapTwo).ordinal());
}

@Override
Expand Down
Expand Up @@ -11,8 +11,10 @@
import de.sanandrew.mods.claysoldiers.util.ClaySoldiersMod;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.oredict.OreDictionary;

public enum EnumHorseType
{
Expand All @@ -32,7 +34,7 @@ public enum EnumHorseType
SNOW(40.0F, 0.5F, 0xFFFFFF, new ItemStack(Blocks.snow), ClaySoldiersMod.MOD_ID + ":doll_horse", 0xFFFFFF,
new ResourceLocation(ClaySoldiersMod.MOD_ID, "textures/entity/mount/horses/snow.png")
),
GRASS(20.0F, 0.9F, 0x2ABA1A, new ItemStack(Blocks.tallgrass), ClaySoldiersMod.MOD_ID + ":doll_horse", 0x2ABA1A,
GRASS(20.0F, 0.9F, 0x2ABA1A, new ItemStack(Blocks.tallgrass, 1, OreDictionary.WILDCARD_VALUE), ClaySoldiersMod.MOD_ID + ":doll_horse", 0x2ABA1A,
new ResourceLocation(ClaySoldiersMod.MOD_ID, "textures/entity/mount/horses/grass1.png"),
new ResourceLocation(ClaySoldiersMod.MOD_ID, "textures/entity/mount/horses/grass2.png")
),
Expand All @@ -49,7 +51,7 @@ public enum EnumHorseType
SOULSAND(35.0F, 0.8F, 0x5C3100, new ItemStack(Blocks.soul_sand), ClaySoldiersMod.MOD_ID + ":doll_horse", 0x5C3100,
new ResourceLocation(ClaySoldiersMod.MOD_ID, "textures/entity/mount/horses/soulsand.png")
),
CAKE(30.0F, 1.1F, 0xFFFFFF, new ItemStack(Blocks.cake), ClaySoldiersMod.MOD_ID + ":doll_horse_cake", 0xFFFFFF,
CAKE(30.0F, 1.1F, 0xFFFFFF, new ItemStack(Items.cake), ClaySoldiersMod.MOD_ID + ":doll_horse_cake", 0xFFFFFF,
new ResourceLocation(ClaySoldiersMod.MOD_ID, "textures/entity/mount/horses/cake.png")
),
NIGHTMARE(50.0F, 1.2F, 0x000000, null,
Expand Down Expand Up @@ -89,6 +91,10 @@ public static EnumHorseType getTypeFromItem(ItemStack stack) {
return null;
}

if( stack.getItem() == Item.getItemFromBlock(Blocks.tallgrass) && stack.getItemDamage() == 0 ) {
return null;
}

for( EnumHorseType type : VALUES ) {
if( type.item == null ) {
return null;
Expand Down
Expand Up @@ -43,7 +43,7 @@ public enum EnumTurtleType
new ResourceLocation(ClaySoldiersMod.MOD_ID, "textures/entity/mount/turtle/pumpkin.png"),
new ResourceLocation(ClaySoldiersMod.MOD_ID, "textures/entity/mount/turtle/pumpkin.png")
),
LAPIS(35.0F, 0.6F, 0x270AC9, new ItemStack(Blocks.lapis_block), ClaySoldiersMod.MOD_ID + ":doll_turtle_shell", 0x4D3225, 0x270AC9,
LAPIS(35.0F, 0.6F, 0x270AC9, new ItemStack(Items.dye, 1, 4), ClaySoldiersMod.MOD_ID + ":doll_turtle_shell", 0x4D3225, 0x270AC9,
new ResourceLocation(ClaySoldiersMod.MOD_ID, "textures/entity/mount/turtle/lapis.png")
),
CAKE(30.0F, 0.6F, 0xFFA1A1, new ItemStack(Items.cake), ClaySoldiersMod.MOD_ID + ":doll_turtle_cakeshell", 0xA60000, 0xFFFFFF,
Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit 5d5d2a6

Please sign in to comment.