Skip to content

Commit

Permalink
Take two on, #163 - Apparently this wasn't nearly as simple as I expe…
Browse files Browse the repository at this point in the history
…cted.
  • Loading branch information
AlgorithmX2 committed Nov 5, 2016
1 parent 1f2119f commit e9f842d
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 32 deletions.
Expand Up @@ -80,7 +80,7 @@ public ItemStack getCraftingResult(

if ( req != null )
{
return ChiselsAndBits.getItems().itemPositiveprint.getPatternedItem( req.pattern );
return ChiselsAndBits.getItems().itemPositiveprint.getPatternedItem( req.pattern, true );
}

return null;
Expand Down
Expand Up @@ -65,7 +65,7 @@ public List<IToolMode> getAvailableModes()
{
final List<IToolMode> modes = new ArrayList<IToolMode>();
final EnumSet<ChiselMode> used = EnumSet.noneOf( ChiselMode.class );
final ChiselMode[] orderedModes = { ChiselMode.SINGLE, ChiselMode.LINE, ChiselMode.PLANE, ChiselMode.CONNECTED_PLANE, ChiselMode.DRAWN_REGION };
final ChiselMode[] orderedModes = { ChiselMode.SINGLE, ChiselMode.LINE, ChiselMode.PLANE, ChiselMode.CONNECTED_PLANE, ChiselMode.CONNECTED_MATERIAL, ChiselMode.DRAWN_REGION, ChiselMode.SAME_MATERIAL };

for ( final ChiselMode mode : orderedModes )
{
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/mod/chiselsandbits/helpers/ModUtil.java
Expand Up @@ -24,6 +24,7 @@
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
Expand Down Expand Up @@ -544,6 +545,12 @@ public static ItemStack getItemFromBlock(
final int damage = blk.damageDropped( state );
final Item blockVarient = Item.getItemFromBlock( blk );

// darn conversions...
if ( blk == Blocks.GRASS )
{
return new ItemStack( Blocks.GRASS );
}

if ( i == null )
{
return null;
Expand Down
Expand Up @@ -6,7 +6,8 @@ public interface IPatternItem
{

ItemStack getPatternedItem(
ItemStack stack );
ItemStack stack,
final boolean wantRealBlocks );

boolean isWritten(
ItemStack stack );
Expand Down
12 changes: 2 additions & 10 deletions src/main/java/mod/chiselsandbits/items/ItemMirrorPrint.java
Expand Up @@ -6,14 +6,12 @@
import mod.chiselsandbits.chiseledblock.NBTBlobConverter;
import mod.chiselsandbits.chiseledblock.TileEntityBlockChiseled;
import mod.chiselsandbits.chiseledblock.data.VoxelBlob;
import mod.chiselsandbits.chiseledblock.data.VoxelBlob.BlobStats;
import mod.chiselsandbits.core.ChiselsAndBits;
import mod.chiselsandbits.core.ClientSide;
import mod.chiselsandbits.helpers.LocalStrings;
import mod.chiselsandbits.helpers.ModUtil;
import mod.chiselsandbits.interfaces.IPatternItem;
import mod.chiselsandbits.render.helpers.SimpleInstanceCache;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
Expand Down Expand Up @@ -138,7 +136,8 @@ protected NBTTagCompound getCompoundFromBlock(

@Override
public ItemStack getPatternedItem(
final ItemStack stack )
final ItemStack stack,
final boolean wantRealItems )
{
if ( !isWritten( stack ) )
{
Expand All @@ -151,13 +150,6 @@ public ItemStack getPatternedItem(
final NBTBlobConverter conv = new NBTBlobConverter();
conv.readChisleData( tag );

final BlobStats common = conv.getBlob().getVoxelStats();
if ( common.isFullBlock )
{
final IBlockState state = Block.getStateById( common.mostCommonState );
return new ItemStack( state.getBlock(), 1, state.getBlock().getMetaFromState( state ) );
}

final IBlockState blk = conv.getPrimaryBlockState();
final ItemStack itemstack = new ItemStack( ChiselsAndBits.getBlocks().getConversionWithDefault( blk ), 1 );

Expand Down
23 changes: 6 additions & 17 deletions src/main/java/mod/chiselsandbits/items/ItemNegativePrint.java
Expand Up @@ -223,7 +223,8 @@ protected NBTTagCompound getCompoundFromBlock(

@Override
public ItemStack getPatternedItem(
final ItemStack stack )
final ItemStack stack,
final boolean craftingBlocks )
{
if ( !isWritten( stack ) )
{
Expand All @@ -236,29 +237,17 @@ public ItemStack getPatternedItem(
final NBTBlobConverter conv = new NBTBlobConverter();
conv.readChisleData( tag );

if ( ChiselsAndBits.getConfig().fullBlockCrafting )
if ( craftingBlocks && ChiselsAndBits.getConfig().fullBlockCrafting )
{
final BlobStats stats = conv.getBlob().getVoxelStats();
if ( stats.isFullBlock )
{
final IBlockState state = Block.getStateById( stats.mostCommonState );
final ItemStack is = ModUtil.getItemFromBlock( state );

try
{
// for an unknown reason its possible to generate mod blocks
// without
// proper state here...
final Block blk = state.getBlock();

final Item item = Item.getItemFromBlock( blk );
if ( item != null )
{
return new ItemStack( blk, 1, blk.damageDropped( state ) );
}
}
catch ( final IllegalArgumentException e )
if ( is != null )
{
// derp!
return is;
}
}
}
Expand Down
Expand Up @@ -157,7 +157,7 @@ public final EnumActionResult doItemUse(
{
if ( PositivePatternMode.getMode( stack ) == PositivePatternMode.PLACEMENT )
{
final ItemStack output = getPatternedItem( stack );
final ItemStack output = getPatternedItem( stack, false );
if ( output != null )
{
final VoxelBlob pattern = ModUtil.getBlobFromStack( stack, player );
Expand Down
Expand Up @@ -21,7 +21,7 @@ public PrintBaked(
{
itemName = itname;

final ItemStack blockItem = item.getPatternedItem( stack );
final ItemStack blockItem = item.getPatternedItem( stack, false );
IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel( blockItem );

model = model.getOverrides().handleItemState( model, blockItem, null, null );
Expand Down

0 comments on commit e9f842d

Please sign in to comment.