-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
128606a
commit 9ded1e8
Showing
10 changed files
with
293 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/java/mod/chiselsandbits/client/ItemColorBitBag.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package mod.chiselsandbits.client; | ||
|
||
import mod.chiselsandbits.core.ChiselsAndBits; | ||
import net.minecraft.client.renderer.color.IItemColor; | ||
import net.minecraft.item.EnumDyeColor; | ||
import net.minecraft.item.ItemStack; | ||
|
||
public class ItemColorBitBag implements IItemColor | ||
{ | ||
|
||
@Override | ||
public int getColorFromItemstack( | ||
ItemStack stack, | ||
int tintIndex ) | ||
{ | ||
if ( tintIndex == 1 ) | ||
{ | ||
EnumDyeColor color = ChiselsAndBits.getItems().itemBitBag.getDyedColor( stack ); | ||
if ( color != null ) | ||
return color.func_193350_e(); | ||
} | ||
|
||
return -1; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
166 changes: 166 additions & 0 deletions
166
src/main/java/mod/chiselsandbits/crafting/BagDyeing.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
package mod.chiselsandbits.crafting; | ||
|
||
import mod.chiselsandbits.core.ChiselsAndBits; | ||
import mod.chiselsandbits.helpers.ModUtil; | ||
import mod.chiselsandbits.items.ItemBitBag; | ||
import net.minecraft.init.Items; | ||
import net.minecraft.inventory.InventoryCrafting; | ||
import net.minecraft.item.EnumDyeColor; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.ResourceLocation; | ||
import net.minecraft.world.World; | ||
import net.minecraftforge.oredict.OreDictionary; | ||
|
||
public class BagDyeing extends CustomRecipe | ||
{ | ||
|
||
public BagDyeing( | ||
ResourceLocation name ) | ||
{ | ||
super( name ); | ||
} | ||
|
||
private static class dyed_output | ||
{ | ||
ItemStack bag; | ||
EnumDyeColor color; | ||
|
||
public dyed_output( | ||
ItemStack bag, | ||
EnumDyeColor dye ) | ||
{ | ||
this.bag = bag; | ||
this.color = dye; | ||
} | ||
|
||
}; | ||
|
||
@Override | ||
public boolean matches( | ||
InventoryCrafting inv, | ||
World worldIn ) | ||
{ | ||
return getOutput( inv ) != null; | ||
} | ||
|
||
@Override | ||
public ItemStack getCraftingResult( | ||
InventoryCrafting inv ) | ||
{ | ||
dyed_output output = getOutput( inv ); | ||
|
||
if ( output != null ) | ||
{ | ||
return ChiselsAndBits.getItems().itemBitBag.dyeBag( output.bag, output.color ); | ||
} | ||
|
||
return ModUtil.getEmptyStack(); | ||
} | ||
|
||
private dyed_output getOutput( | ||
InventoryCrafting inv ) | ||
{ | ||
ItemStack bag = null; | ||
ItemStack dye = null; | ||
|
||
for ( int x = 0; x < inv.getSizeInventory(); ++x ) | ||
{ | ||
ItemStack is = inv.getStackInSlot( x ); | ||
if ( is != null && !ModUtil.isEmpty( is ) ) | ||
{ | ||
if ( is.getItem() == Items.WATER_BUCKET || getDye( is ) != null ) | ||
{ | ||
if ( dye == null ) | ||
dye = is; | ||
else | ||
return null; | ||
} | ||
else if ( is.getItem() instanceof ItemBitBag ) | ||
{ | ||
if ( bag == null ) | ||
bag = is; | ||
else | ||
return null; | ||
} | ||
else | ||
return null; | ||
} | ||
} | ||
|
||
if ( bag != null && dye != null ) | ||
{ | ||
return new dyed_output( bag, getDye( dye ) ); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
private EnumDyeColor getDye( | ||
ItemStack is ) | ||
{ | ||
if ( testDye( "dyeWhite", is ) ) | ||
return EnumDyeColor.WHITE; | ||
if ( testDye( "dyeOrange", is ) ) | ||
return EnumDyeColor.ORANGE; | ||
if ( testDye( "dyeMagenta", is ) ) | ||
return EnumDyeColor.MAGENTA; | ||
if ( testDye( "dyeLightBlue", is ) ) | ||
return EnumDyeColor.LIGHT_BLUE; | ||
if ( testDye( "dyeLime", is ) ) | ||
return EnumDyeColor.LIME; | ||
if ( testDye( "dyePink", is ) ) | ||
return EnumDyeColor.PINK; | ||
if ( testDye( "dyeGray", is ) ) | ||
return EnumDyeColor.GRAY; | ||
if ( testDye( "dyeLightGray", is ) ) | ||
return EnumDyeColor.SILVER; | ||
if ( testDye( "dyeCyan", is ) ) | ||
return EnumDyeColor.CYAN; | ||
if ( testDye( "dyePurple", is ) ) | ||
return EnumDyeColor.PURPLE; | ||
if ( testDye( "dyeBlue", is ) ) | ||
return EnumDyeColor.BLUE; | ||
if ( testDye( "dyeBrown", is ) ) | ||
return EnumDyeColor.BROWN; | ||
if ( testDye( "dyeGreen", is ) ) | ||
return EnumDyeColor.GREEN; | ||
if ( testDye( "dyeRed", is ) ) | ||
return EnumDyeColor.RED; | ||
if ( testDye( "dyeBlack", is ) ) | ||
return EnumDyeColor.BLACK; | ||
|
||
return null; | ||
} | ||
|
||
private boolean testDye( | ||
String string, | ||
ItemStack is ) | ||
{ | ||
if ( OreDictionary.doesOreNameExist( string ) ) | ||
{ | ||
int ore = OreDictionary.getOreID( string ); | ||
int[] list = OreDictionary.getOreIDs( is ); | ||
for ( int x = 0; x < list.length; ++x ) | ||
if ( list[x] == ore ) | ||
return true; | ||
return false; | ||
} | ||
else | ||
throw new RuntimeException( "Invalid dye: " + string ); | ||
} | ||
|
||
@Override | ||
public boolean func_194133_a( | ||
int p_194133_1_, | ||
int p_194133_2_ ) | ||
{ | ||
return p_194133_1_ * p_194133_2_ >= 2; | ||
} | ||
|
||
@Override | ||
public ItemStack getRecipeOutput() | ||
{ | ||
return ModUtil.getEmptyStack(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/main/resources/assets/chiselsandbits/models/item/bit_bag_dyed.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"parent":"item/generated", | ||
"textures": { | ||
"layer0":"chiselsandbits:items/bit_bag_string", | ||
"layer1":"chiselsandbits:items/bit_bag_dyeable" | ||
} | ||
} |
Binary file added
BIN
+322 Bytes
src/main/resources/assets/chiselsandbits/textures/items/bit_bag_dyeable.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
BIN
+270 Bytes
src/main/resources/assets/chiselsandbits/textures/items/bit_bag_string.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.