I have two blocks that I am trying to use to craft items from my mod. The first block when right clicked, is supposed to check for an item above it in this case a glass block, then check for a ball of magma cream and a modded item I made in the first two slots of the container. However, nothing is happening when the block is right clicked so I assume one of the if statements is faulty.
Here's my onblockactivated method (idk why indents are weird in eclipse they look fine):
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if(!playerIn.isSneaking()) {
if(worldIn.getBlockState(pos.down(1)) == ModBlocks.Magic_Sponge.getDefaultState()) {
List<EntityItem> entities = worldIn.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos.getX(), pos.getY(), pos.getZ(), pos.getX()+1,pos.getY() + 1, pos.getZ()+1));
for (EntityItem entity : entities) {
if(entity.getItem().getItem() == glass.getItem()) {
TileEntityMagicSponge tileentity = (TileEntityMagicSponge)worldIn.getTileEntity(pos.down());
Item Magma_cream = tileentity.getStackInSlot(1).getItem();
Item Magic_Caytalist = tileentity.getStackInSlot(2).getItem();
ItemStack stack = entity.getItem();
if(Magma_cream == Items.MAGMA_CREAM.getItemById(378) && Magic_Caytalist == ModItems.CAYTALIST.getItemById(4110)) {
if(!worldIn.isRemote) {
while (stack.getCount() > 0) {
EntityItem item = new EntityItem(worldIn, pos.getX()+0.5F, pos.getY(), pos.getZ()+0.5F, Magic_orb);
worldIn.spawnEntity(item);
stack.shrink(1);
tileentity.removeStackFromSlot(0);
tileentity.removeStackFromSlot(1);
worldIn.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENTITY_FIREWORK_LAUNCH, entity.getSoundCategory(), 0.8F, 0.8F + entity.world.rand.nextFloat() * 0.4F);
}
}
}
}
}
}
}
return enableStats;
}
}